def test_gray_block(self): self.im.putpixel(( 0, 0, ), tuple(self.white)) self.im.putpixel(( 0, 1, ), tuple(self.white)) out = get_avg_for_em(self.px, 0, 0, 2, 2) self.assertColor(out, self.gray) out = get_avg_for_em(self.px, 2, 0, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 0, 2, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 2, 2, 2, 2) self.assertColor(out, self.black)
def test_default_black_block(self): out = get_avg_for_em(self.px, 0, 0, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 2, 0, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 0, 2, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 2, 2, 2, 2) self.assertColor(out, self.black)
def test_separate_color_channels(self): color1 = ( 0, 128, 255, ) color2 = ( 255, 128, 0, ) self.im.putpixel(( 0, 0, ), color1) self.im.putpixel(( 1, 0, ), color1) self.im.putpixel(( 0, 1, ), color1) self.im.putpixel(( 1, 1, ), color1) self.im.putpixel(( 2, 0, ), color1) self.im.putpixel(( 3, 0, ), color1) self.im.putpixel(( 2, 1, ), color2) self.im.putpixel(( 3, 1, ), color2) out = get_avg_for_em(self.px, 0, 0, 2, 2) self.assertColor(out, list(color1)) out = get_avg_for_em(self.px, 2, 0, 2, 2) self.assertColor(out, self.gray) out = get_avg_for_em(self.px, 0, 2, 2, 2) self.assertColor(out, self.black) out = get_avg_for_em(self.px, 2, 2, 2, 2) self.assertColor(out, self.black)