コード例 #1
0
    def test_inverted_2(self):
        # im = {
        #     'height': 1,
        #     'width': 4,
        #     'pixels': [15, 78, 141, 195]
        # }
        im = {
            'height': 2,
            'width': 4,
            'pixels': [15, 78, 141, 195, 15, 78, 141, 195]
        }

        result = lab.inverted(im)
        print('result:', result)
        #
        # expected = {
        #     'height': 1,
        #     'width': 4,
        #     'pixels': [240, 177, 114, 60]
        # }

        expected = {
            'height': 2,
            'width': 4,
            'pixels': [240, 177, 114, 60, 240, 177, 114, 60]
        }
        self.compare_images(result, expected)
コード例 #2
0
 def test_inverted_2(self):
     #
     im = {"height": 1, "width": 4, "pixels": [18, 69, 142, 216]}
     expected = {
         "height": 1,
         "width": 4,
         "pixels": [255 - 18, 255 - 69, 255 - 142, 255 - 216]
     }
     result = lab.inverted(im)
     self.compare_images(result, expected)
コード例 #3
0
def test_inverted_images(fname):
    inpfile = os.path.join(TEST_DIRECTORY, 'test_images', '%s.png' % fname)
    expfile = os.path.join(TEST_DIRECTORY, 'test_results',
                           '%s_invert.png' % fname)
    im = lab.load_image(inpfile)
    oim = object_hash(im)
    result = lab.inverted(im)
    expected = lab.load_image(expfile)
    assert object_hash(
        im) == oim, 'Be careful not to modify the original image!'
    compare_images(result, expected)
コード例 #4
0
 def test_inverted_images(self):
     for fname in ('mushroom', 'twocats', 'chess'):
         with self.subTest(f=fname):
             inpfile = os.path.join(TEST_DIRECTORY, 'test_images', '%s.png' % fname)
             expfile = os.path.join(TEST_DIRECTORY, 'test_results', '%s_invert.png' % fname)
             im = lab.load_image(inpfile)
             oim = object_hash(im)
             result = lab.inverted(im)
             expected = lab.load_image(expfile)
             self.assertEqual(object_hash(im), oim, 'Be careful not to modify the original image!')
             self.compare_images(result, expected)
コード例 #5
0
def test_inverted_2():
    im = {
        'height': 1,
        'width': 4,
        'pixels': [25, 69, 146, 215],
    }
    result = lab.inverted(im)
    expected = {
        'height': 1,
        'width': 4,
        'pixels': [230, 186, 109, 40],
    }
    compare_images(result, expected)
コード例 #6
0
 def test_inverted_1(self):
     im = lab.load_image('test_images/centered_pixel.png')
     print('im:', im)
     result = lab.inverted(im)
     print('result:', result)
     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, 0, 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],
     }
     self.compare_images(result, expected)
コード例 #7
0
def test_inverted_1():
    im = lab.load_image(
        os.path.join(TEST_DIRECTORY, 'test_images', 'centered_pixel.png'))
    result = lab.inverted(im)
    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, 0, 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
        ],
    }
    compare_images(result, expected)
コード例 #8
0
def test_inverted_2():
    input = {'height': 1, 'width': 4, 'pixels': [15, 75, 156, 193]}
    result = lab.inverted(input)
    expected = {'height': 1, 'width': 4, 'pixels': [240, 180, 99, 62]}
    compare_images(result, expected)
コード例 #9
0
 def test_inverted_2(self):
     # REPLACE THIS with your test case from section 3.1
     im = {'height': 1, 'width': 4, 'pixels': [21, 85, 153, 212]}
     exp = {'height': 1, 'width': 4, 'pixels': [234, 170, 102, 43]}
     self.compare_images(lab.inverted(im), exp)
コード例 #10
0
 def test_inverted_2(self):
     # REPLACE THIS with your test case from section 3.1
     im = {'height': 1, 'width': 4, 'pixels': [15, 91, 142, 201]}
     result = lab.inverted(im)
     expected = {'height': 1, 'width': 4, 'pixels': [240, 164, 113, 54]}
     self.compare_images(result, expected)
コード例 #11
0
 def test_inverted_2(self):
     im = {'height': 1, 'width': 4, 'pixels': [15, 75, 146, 195]}
     result = lab.inverted(im)
     expected = {'height': 1, 'width': 4, 'pixels': [240, 180, 109, 60]}
     self.compare_images(result, expected)
コード例 #12
0
 def test_inverted_3(self):
     im = lab.load_image('test_images/bluegill.png')
     result = lab.inverted(im)
     lab.save_image(result,
                    '/Users/yaxinliu/Downloads/lab0/InvertedImage.png')
コード例 #13
0
 def test_inverted_2(self):
     # 3.1: Inverting a 4x1 image
     im = {'height': 1, 'width': 4, 'pixels': [15, 78, 141, 195]}
     result = lab.inverted(im)
     expected = {'height': 1, 'width': 4, 'pixels': [240, 177, 114, 60]}
     self.compare_images(result, expected)
コード例 #14
0
ファイル: test.py プロジェクト: Aegis100/Coding-Projects
def test_inverted_2():
    im = lab.inverted({'height': 1, 'width': 4, 'pixels': [0, 73, 136, 203]})
    expected = {'height': 1, 'width': 4, 'pixels': [255, 182, 119, 52]}
    compare_images(im, expected)