def test_enhancing_a_single_image_no_color_config(self): """ Enhancing a single Image with the default color configuration should run through without any errors """ img_name, img = get_test_image() enhanced = enhance(img, ColorConfiguration()) assert img.shape == enhanced.shape
def test_enhancing_a_single_image_only_fg_color(self): """ Enhancing a single Image with the default background color and a user specified foreground color should run through without any errors """ img_name, img = get_test_image() enhanced = enhance(img, ColorConfiguration(foreground_color="red")) assert img.shape == enhanced.shape
def test_colorspace_conversion_mask_to_rgb_fg_colors(self): img_name, img = get_test_image() mask = np.empty(img.shape[:2], dtype=np.bool) mask[:] = False mask[50:100, 100:150] = True out_img = mask_to_rgb_with_fg_colors_from_image( mask, (255, 255, 255), img) assert out_img.shape == img.shape assert np.all(out_img[~mask] == 255)
def test_enhancing_a_single_image_fg_and_bg_color(self): """ Enhancing a single Image with a user specified foreground and background color should run through without any errors """ img_name, img = get_test_image() enhanced = enhance( img, ColorConfiguration(foreground_color="black", background_color="white")) assert img.shape == enhanced.shape
def test_enhance_service(self, mocker: MockFixture): # mock the io module name, img = get_test_image() mock_io = mocker.patch("white_brush.io")() mock_io.read_image.return_value = img enhance_service.io = mock_io service = enhance_service.EnhanceService() service.enhance_file("input.jpg", "output.jpg", 0, ColorConfiguration()) mock_io.read_image.assert_called_with("input.jpg") mock_io.write_image.assert_called_once()
def test_resize_if_no_resizing(self): """ Given: an image which should not be changed based on its size When: resize_if is called Then: The image should stay the same """ img_name, img = get_test_image() # img.shape == (629, 919, 3) resized = resize_if(img, 500, 1000) assert_allclose(img, resized)
def test_resize_if_no_resizing(self): """ Given: an image which should be changed based on its size When: resize_if is called Then: The image should have the specified size """ img_name, img = get_test_image() # img.shape == (629, 919, 3) resized = resize_if(img, 500, 800) assert resized.shape == (342, 500, 3)