예제 #1
0
def test_small_cascade():
    color_edges = lab.color_filter_from_greyscale_filter(lab.edges)
    color_inverted = lab.color_filter_from_greyscale_filter(lab.inverted)
    color_blur_5 = lab.color_filter_from_greyscale_filter(lab.make_blur_filter(5))

    im = lab.load_color_image('test_images/centered_pixel.png')
    expected = {
        'height': 11,
        'width': 11,
        'pixels': [(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (254, 250, 252), (254, 244, 248), (253, 240, 246), (253, 240, 246), (253, 240, 246), (254, 244, 248), (254, 250, 252), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (254, 244, 248), (253, 238, 244), (252, 227, 238), (252, 227, 238), (252, 227, 238), (253, 238, 244), (254, 244, 248), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (253, 240, 246), (252, 227, 238), (250, 211, 228), (250, 211, 228), (250, 211, 228), (252, 227, 238), (253, 240, 246), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (253, 240, 246), (252, 227, 238), (250, 211, 228), (250, 211, 228), (250, 211, 228), (252, 227, 238), (253, 240, 246), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (253, 240, 246), (252, 227, 238), (250, 211, 228), (250, 211, 228), (250, 211, 228), (252, 227, 238), (253, 240, 246), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (254, 244, 248), (253, 238, 244), (252, 227, 238), (252, 227, 238), (252, 227, 238), (253, 238, 244), (254, 244, 248), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (254, 250, 252), (254, 244, 248), (253, 240, 246), (253, 240, 246), (253, 240, 246), (254, 244, 248), (254, 250, 252), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255),
                   (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)]
    }
    f_cascade = lab.filter_cascade([color_edges, color_inverted, color_blur_5])
    assert callable(f_cascade), 'filter_cascade should return a function.'
    result = f_cascade(im)
    compare_color_images(result, expected)
예제 #2
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_cascades(self):
     cascade0 = [
         self.color_edges,
         lab.color_filter_from_greyscale_filter(lab.make_sharpen_filter(3))
     ]
     cascade1 = [
         lab.color_filter_from_greyscale_filter(lab.make_blur_filter(5)),
         self.color_edges,
         lab.color_filter_from_greyscale_filter(lab.make_sharpen_filter(3))
     ]
     cascade3 = [self.color_edges] * 5 + [self.color_inverted]
     for fname in ('tree', ):
         for cix, cascade in enumerate([cascade0, cascade1]):
             inpfile = os.path.join(TEST_DIRECTORY, 'test_images',
                                    f'{fname}.png')
             expfile = os.path.join(TEST_DIRECTORY, 'test_results',
                                    f'{fname}_cascade{cix}.png')
             im = lab.load_color_image(inpfile)
             oim = object_hash(im)
             f_cascade = lab.filter_cascade(cascade)
             self.assertTrue(callable(f_cascade),
                             'filter_cascade should return a function.')
             result = f_cascade(im)
             expected = lab.load_color_image(expfile)
             self.assertEqual(
                 object_hash(im), oim,
                 'Be careful not to modify the original image!')
             self.compare_color_images(result, expected)
예제 #3
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_cascade_2(self):
     im = lab.load_color_image('test_images/frog.png')
     filter1 = lab.color_filter_from_greyscale_filter(lab.edges)
     filter2 = lab.color_filter_from_greyscale_filter(
         lab.make_blur_filter(5))
     filt = lab.filter_cascade([filter1, filter1, filter2, filter1])
     result = filt(im)
     lab.save_color_image(result,
                          '/Users/yaxinliu/Downloads/lab1/Cascade.png')
예제 #4
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_blur_filter_2(self):
     blur_filter = lab.make_blur_filter(9)
     self.assertTrue(callable(blur_filter),
                     'make_blur_filter should return a function.')
     color_blur = lab.color_filter_from_greyscale_filter(blur_filter)
     im = lab.load_color_image('test_images/python.png')
     result = color_blur(im)
     lab.save_color_image(
         result, '/Users/yaxinliu/Downloads/lab1/Make_Blurred.png')
예제 #5
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_sharpen_filters_1(self):
     sharpen_filter = lab.make_sharpen_filter(7)
     self.assertTrue(callable(sharpen_filter),
                     'make_sharpen_filter should return a function.')
     color_sharpen = lab.color_filter_from_greyscale_filter(sharpen_filter)
     im = lab.load_color_image('test_images/sparrowchick.png')
     result = color_sharpen(im)
     lab.save_color_image(
         result, '/Users/yaxinliu/Downloads/lab1/Make_Sharpen.png')
예제 #6
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_blur_filter_1(self):
     blur_filter = lab.make_blur_filter(3)
     self.assertTrue(callable(blur_filter),
                     'make_blur_filter should return a function.')
     color_blur = lab.color_filter_from_greyscale_filter(blur_filter)
     im = lab.load_color_image('test_images/centered_pixel.png')
     result = color_blur(im)
     expected = {
         'height':
         11,
         'width':
         11,
         'pixels': [(244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (245, 182, 193), (245, 182, 193), (245, 182, 193),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (245, 182, 193),
                    (245, 182, 193), (245, 182, 193), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (245, 182, 193), (245, 182, 193),
                    (245, 182, 193), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198), (244, 173, 198), (244, 173, 198),
                    (244, 173, 198)]
     }
     self.compare_color_images(result, expected)
예제 #7
0
def test_color_filter_images(fname, filter_info):
    filt, filt_name = filter_info
    inpfile = os.path.join(TEST_DIRECTORY, 'test_images', f'{fname}.png')
    expfile = os.path.join(TEST_DIRECTORY, 'test_results', f'{fname}_{filt_name}.png')
    im = lab.load_color_image(inpfile)
    oim = object_hash(im)
    color_filter = lab.color_filter_from_greyscale_filter(filt)
    assert callable(color_filter), 'color_filter_from_greyscale_filter should return a function.'
    result = color_filter(im)
    expected = lab.load_color_image(expfile)
    assert object_hash(im) == oim, 'Be careful not to modify the original image!'
    compare_color_images(result, expected)
예제 #8
0
def test_sharpen_filter_images(fname, ker_size):
    inpfile = os.path.join(TEST_DIRECTORY, 'test_images', f'{fname}.png')
    expfile = os.path.join(TEST_DIRECTORY, 'test_results', f'{fname}_sharpened{ker_size}.png')
    im = lab.load_color_image(inpfile)
    oim = object_hash(im)
    sharpen_filter = lab.make_sharpen_filter(ker_size)
    assert callable(sharpen_filter), 'make_sharpen_filter should return a function.'
    color_sharpen = lab.color_filter_from_greyscale_filter(sharpen_filter)
    result = color_sharpen(im)
    expected = lab.load_color_image(expfile)
    assert object_hash(im) == oim, 'Be careful not to modify the original image!'
    compare_color_images(result, expected)
예제 #9
0
def test_cascades(cascade, image):
    color_edges = lab.color_filter_from_greyscale_filter(lab.edges)
    color_inverted = lab.color_filter_from_greyscale_filter(lab.inverted)
    cascade0 = [color_edges,
                lab.color_filter_from_greyscale_filter(lab.make_sharpen_filter(3))]
    cascade1 = [lab.color_filter_from_greyscale_filter(lab.make_blur_filter(5)),
                color_edges,
                lab.color_filter_from_greyscale_filter(lab.make_sharpen_filter(3)),
                lambda im: {k: ([(i[1], i[0], i[2]) for i in v] if isinstance(v, list) else v) for k, v in im.items()}]
    cascade2 = [color_edges]*5 + [color_inverted]

    cascades = [cascade0, cascade1, cascade2]

    inpfile = os.path.join(TEST_DIRECTORY, 'test_images', f'{image}.png')
    expfile = os.path.join(TEST_DIRECTORY, 'test_results', f'{image}_cascade{cascade}.png')
    im = lab.load_color_image(inpfile)
    oim = object_hash(im)
    f_cascade = lab.filter_cascade(cascades[cascade])
    assert callable(f_cascade), 'filter_cascade should return a function.'
    result = f_cascade(im)
    expected = lab.load_color_image(expfile)
    assert object_hash(im) == oim, 'Be careful not to modify the original image!'
    compare_color_images(result, expected)
예제 #10
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_color_filter_inverted(self):
     im = lab.load_color_image('test_images/centered_pixel.png')
     color_inverted = lab.color_filter_from_greyscale_filter(lab.inverted)
     self.assertTrue(
         callable(color_inverted),
         'color_filter_from_greyscale_filter should return a function.')
     result = color_inverted(im)
     expected = {
         'height':
         11,
         'width':
         11,
         'pixels': [(11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (2, 2, 106), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                    (11, 82, 57)]
     }
     self.compare_color_images(result, expected)
예제 #11
0
def test_color_filter_inverted():
    im = lab.load_color_image(os.path.join(TEST_DIRECTORY, 'test_images', 'centered_pixel.png'))
    color_inverted = lab.color_filter_from_greyscale_filter(lab.inverted)
    assert callable(color_inverted), 'color_filter_from_greyscale_filter should return a function.'
    result = color_inverted(im)
    expected = {
        'height': 11,
        'width': 11,
        'pixels': [(11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),  (2, 2, 106), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57),
                   (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57), (11, 82, 57)]
    }
    compare_color_images(result, expected)
예제 #12
0
def test_color_filter_edges():
    im = lab.load_color_image('test_images/centered_pixel.png')
    color_edges = lab.color_filter_from_greyscale_filter(lab.edges)
    assert callable(color_edges), 'color_filter_from_greyscale_filter should return a function.'
    result = color_edges(im)
    expected = {
        'height': 11,
        'width': 11,
        'pixels': [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (13, 113, 69), (18, 160, 98), (13, 113, 69), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (18, 160, 98), (0, 0, 0), (18, 160, 98), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (13, 113, 69), (18, 160, 98), (13, 113, 69), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
                   (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
    }
    compare_color_images(result, expected)
예제 #13
0
def test_blur_filter():
    blur_filter = lab.make_blur_filter(3)
    assert callable(blur_filter), 'make_blur_filter should return a function.'
    color_blur = lab.color_filter_from_greyscale_filter(blur_filter)
    im = lab.load_color_image(os.path.join(TEST_DIRECTORY, 'test_images', 'centered_pixel.png'))
    result = color_blur(im)
    expected = {
        'height': 11,
        'width': 11,
        'pixels': [(244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (245, 182, 193), (245, 182, 193), (245, 182, 193), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (245, 182, 193), (245, 182, 193), (245, 182, 193), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (245, 182, 193), (245, 182, 193), (245, 182, 193), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198),
                   (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198), (244, 173, 198)]
    }
    compare_color_images(result, expected)
예제 #14
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_sharpen_filters(self):
     for fname in ('construct', 'bluegill'):
         for ker_size in {3, 5}:
             with self.subTest(f=fname):
                 inpfile = os.path.join(TEST_DIRECTORY, 'test_images',
                                        f'{fname}.png')
                 expfile = os.path.join(TEST_DIRECTORY, 'test_results',
                                        f'{fname}_sharpened{ker_size}.png')
                 im = lab.load_color_image(inpfile)
                 oim = object_hash(im)
                 sharpened_filter = lab.make_sharpen_filter(ker_size)
                 self.assertTrue(
                     callable(sharpened_filter),
                     'make_sharpen_filter should return a function.')
                 color_sharpen = lab.color_filter_from_greyscale_filter(
                     sharpened_filter)
                 result = color_sharpen(im)
                 expected = lab.load_color_image(expfile)
                 self.assertEqual(
                     object_hash(im), oim,
                     'Be careful not to modify the original image!')
                 self.compare_color_images(result, expected)
예제 #15
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_color_filters(self):
     for fname in ('frog', 'tree'):
         for filt, filt_name in {(lab.edges, 'edges'),
                                 (lab.inverted, 'inverted')}:
             with self.subTest(f=fname):
                 inpfile = os.path.join(TEST_DIRECTORY, 'test_images',
                                        f'{fname}.png')
                 expfile = os.path.join(TEST_DIRECTORY, 'test_results',
                                        f'{fname}_{filt_name}.png')
                 im = lab.load_color_image(inpfile)
                 oim = object_hash(im)
                 color_filter = lab.color_filter_from_greyscale_filter(filt)
                 self.assertTrue(
                     callable(color_filter),
                     'color_filter_from_greyscale_filter should return a function.'
                 )
                 result = color_filter(im)
                 expected = lab.load_color_image(expfile)
                 self.assertEqual(
                     object_hash(im), oim,
                     'Be careful not to modify the original image!')
                 self.compare_color_images(result, expected)
예제 #16
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def test_color_filter_inverted_2(self):
     im = lab.load_color_image('test_images/cat.png')
     color_inverted = lab.color_filter_from_greyscale_filter(lab.inverted)
     result = color_inverted(im)
     lab.save_color_image(
         result, '/Users/yaxinliu/Downloads/lab1/ColorFilterInverted.png')
예제 #17
0
파일: test.py 프로젝트: AnnieL66/MIT-6.009
 def setUp(self):
     self.color_edges = lab.color_filter_from_greyscale_filter(lab.edges)
     self.color_inverted = lab.color_filter_from_greyscale_filter(
         lab.inverted)
     self.color_blur_5 = lab.color_filter_from_greyscale_filter(
         lab.make_blur_filter(5))