def test_grayscale_greater_than_1(): im = util.fill((4, 4), [174, 56, 3]) grayscaled_im = css.grayscale(im, 2) grayscaleed_im2 = css.grayscale(im, 1) assert list(grayscaled_im.getdata()) == list(grayscaleed_im2.getdata()) assert grayscaled_im.size == im.size assert grayscaled_im.mode == im.mode
def test_grayscale_hsv(): im = util.fill((4, 4), [174, 56, 3]) im2 = im.convert('HSV') grayscaled_im = css.grayscale(im) grayscaled_im2 = css.grayscale(im2) grayscaled_im2_rgb = grayscaled_im2.convert('RGB') assert list(grayscaled_im.getdata()) == list(grayscaled_im2_rgb.getdata()) assert grayscaled_im2.size == im2.size assert grayscaled_im2.mode == im2.mode
def test_grayscale_0(): im = util.fill((4, 4), [174, 56, 3]) grayscaled_im = css.grayscale(im, 0) assert list(grayscaled_im.getdata()) == list(im.getdata()) assert grayscaled_im.size == im.size assert grayscaled_im.mode == im.mode
def test_saturate_0(): im = util.fill((4, 4), [174, 56, 3]) saturated_im = css.saturate(im, 0) grayscaled_im = css.grayscale(im) assert list(saturated_im.getdata()) == list(grayscaled_im.getdata()) assert saturated_im.size == im.size assert saturated_im.mode == im.mode
def inkwell(im): """Applies Inkwell filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cr = css.sepia(cb, .3) cr = css.contrast(cr, 1.1) cr = css.brightness(cr, 1.1) cr = css.grayscale(cr) return cr
def moon(im): """Applies Moon filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs1 = util.fill(cb.size, [160, 160, 160]) cs = css.blending.soft_light(cb, cs1) cs2 = util.fill(cb.size, [56, 56, 56]) cr = css.blending.lighten(cs, cs2) cr = css.grayscale(cr) cr = css.contrast(cr, 1.1) cr = css.brightness(cr, 1.1) return cr
def willow(im): """Applies Willow filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs1 = util.radial_gradient(cb.size, [(212, 169, 175), (0, 0, 0)], [.55, 1.5]) cm1 = css.blending.overlay(cb, cs1) cs2 = util.fill(cb.size, [216, 205, 203]) cr = css.blending.color(cm1, cs2) cr = css.grayscale(cr, .5) cr = css.contrast(cr, .95) cr = css.brightness(cr, .9) return cr
def test_grayscale_less_than_0(): with pytest.raises(AssertionError): im = util.fill((4, 4), [174, 56, 3]) css.grayscale(im, -1)
def test_grayscale(): im = util.fill((4, 4), [174, 56, 3]) grayscaled_im = css.grayscale(im) assert grayscaled_im.size == im.size assert grayscaled_im.mode == im.mode