def test_crop_rect_if_rect_equal_image(self): image = np.zeros((30, 40, 3)) crop_rect = CropRect({'type': 'crop_rect'}) assert np.array_equal( image, crop_rect(DataRepresentation(image), { 'rect': [0, 0, 40, 30] }).data)
def test_crop_rect_more_image_size_coordinates_of_rect(self): image = np.zeros((30, 40, 3)) image[:, 20:, :] = 1 expected_image = np.ones((30, 20, 3)) crop_rect = CropRect({'type': 'crop_rect'}) assert np.array_equal( expected_image, crop_rect(DataRepresentation(image), { 'rect': [20, 0, 40, 50] }).data)
def test_crop_rect_if_rect_not_provided(self): image = np.zeros((30, 40, 3)) crop_rect = CropRect({'type': 'crop_rect'}) assert np.array_equal(image, crop_rect(image, {}))