Example #1
0
    def test_translate_points(self):
        horizontal_shift = 50
        vertical_shift = 40
        points = np.asarray([[100., 200.]])
        test_image = self.get_test_image()

        shape = test_image.shape

        translated_points = image_utils.translate_points(
            points,
            horizontal_shift=horizontal_shift,
            vertical_shift=vertical_shift)
        translated_test_image = image_utils.translate_image(
            test_image,
            horizontal_shift=horizontal_shift,
            vertical_shift=vertical_shift)

        print(points)
        print(translated_points)

        scaled_points = image_utils.downscale_points(points, shape=shape)
        scaled_translated_points = image_utils.downscale_points(
            translated_points, shape=shape)

        test_image_points = image_utils.get_image_with_points(
            test_image, scaled_points)
        translated_test_image_points = image_utils.get_image_with_points(
            translated_test_image, scaled_translated_points)
        image_utils.show_multiple_images(
            [test_image_points, translated_test_image_points])
Example #2
0
    def test_rotate_and_translate(self):
        rotation_angle = 30
        horizontal_shift = 50
        vertical_shift = 40
        points = np.asarray([[100., 200.]])
        test_image = self.get_test_image()

        shape = test_image.shape

        rotated_points = image_utils.rotate_points(
            points, rotation_angle=-rotation_angle)
        rotated_test_image = image_utils.rotate_image(
            test_image, rotation_angle=rotation_angle)
        translated_points = image_utils.translate_points(
            rotated_points,
            horizontal_shift=horizontal_shift,
            vertical_shift=vertical_shift)
        translated_test_image = image_utils.translate_image(
            rotated_test_image,
            horizontal_shift=horizontal_shift,
            vertical_shift=vertical_shift)

        scaled_points = image_utils.downscale_points(points, shape=shape)
        scaled_translated_points = image_utils.downscale_points(
            translated_points, shape=shape)

        test_image_points = image_utils.get_image_with_points(
            test_image, scaled_points)
        translated_test_image_points = image_utils.get_image_with_points(
            translated_test_image, scaled_translated_points)
        image_utils.show_multiple_images(
            [test_image_points, translated_test_image_points])
Example #3
0
def view_sample_data_list(X, y, num_sample=5):
    for i in range(num_sample):
        idx = np.random.randint(len(X))
        image = cv2.imread(X[idx], 0)
        points = y[idx]
        image_utils.show_image(image_utils.get_image_with_points(
            image, points))
Example #4
0
    def test_rotate_points(self):
        rotation_angle = 30
        points = np.asarray([[100., 200.]])
        test_image = self.get_test_image()

        shape = test_image.shape

        rotated_points = image_utils.rotate_points(
            points, rotation_angle=rotation_angle)
        rotated_test_image = image_utils.rotate_image(
            test_image, rotation_angle=rotation_angle)

        scaled_points = image_utils.downscale_points(points, shape=shape)
        scaled_rotated_points = image_utils.downscale_points(rotated_points,
                                                             shape=shape)

        test_image_points = image_utils.get_image_with_points(
            test_image, scaled_points)
        rotated_test_image_points = image_utils.get_image_with_points(
            rotated_test_image, scaled_rotated_points)
        image_utils.show_multiple_images(
            [test_image_points, rotated_test_image_points])
Example #5
0
def view_sample_data(data, num_sample):
    X = data["X"]
    y_skeleton = data["y_skel"]
    y_clf = data["y_clf"]

    for i in range(num_sample):
        idx = np.random.randint(X.shape[0])
        image = X[idx].copy()
        image = np.stack((image, ) * 3, axis=-1)
        print(y_skeleton[idx])
        image_with_points = image_utils.get_image_with_points(
            image, y_skeleton[idx])

        print("Class: " + str(y_clf[idx] + 1))
        image_utils.show_image(image_with_points, cmap=None)