def test_rotate_interpolation(interpolation): image = np.random.randint(low=0, high=256, size=(100, 100, 3), dtype=np.uint8) mask = np.random.randint(low=0, high=2, size=(100, 100), dtype=np.uint8) aug = A.Rotate(limit=(45, 45), interpolation=interpolation, p=1) data = aug(image=image, mask=mask) expected_image = FGeometric.rotate(image, 45, interpolation=interpolation, border_mode=cv2.BORDER_REFLECT_101) expected_mask = FGeometric.rotate(mask, 45, interpolation=cv2.INTER_NEAREST, border_mode=cv2.BORDER_REFLECT_101) assert np.array_equal(data["image"], expected_image) assert np.array_equal(data["mask"], expected_mask)
def test_maybe_process_in_chunks(): image = np.random.randint(0, 256, (100, 100, 6), np.uint8) for i in range(1, image.shape[-1] + 1): before = image[:, :, :i] after = FGeometric.rotate(before, angle=1) assert before.shape == after.shape
def test_compare_rotate_float_and_shift_scale_rotate_float(float_image): rotated_img_1 = FGeometric.rotate(float_image, angle=60) rotated_img_2 = FGeometric.shift_scale_rotate(float_image, angle=60, scale=1, dx=0, dy=0) assert np.array_equal(rotated_img_1, rotated_img_2)
def albumentations(self, img): return rotate(img, angle=-45)