def test_sharpened_images(kernsize, fname): inpfile = os.path.join(TEST_DIRECTORY, 'test_images', '%s.png' % fname) expfile = os.path.join(TEST_DIRECTORY, 'test_results', '%s_sharp_%02d.png' % (fname, kernsize)) input_img = lab.load_image(inpfile) input_hash = object_hash(input_img) result = lab.sharpened(input_img, kernsize) expected = lab.load_image(expfile) assert object_hash( input_img ) == input_hash, "Be careful not to modify the original image!" compare_images(result, expected)
def test_sharpened(self): for kernsize in (1, 3, 9): for fname in ('mushroom', 'twocats', 'chess'): with self.subTest(k=kernsize, f=fname): inpfile = os.path.join(TEST_DIRECTORY, 'test_images', '%s.png' % fname) expfile = os.path.join(TEST_DIRECTORY, 'test_results', '%s_sharp_%02d.png' % (fname, kernsize)) input_img = lab.load_image(inpfile) input_hash = object_hash(input_img) result = lab.sharpened(input_img, kernsize) expected = lab.load_image(expfile) self.assertEqual(object_hash(input_img), input_hash, "Be careful not to modify the original image!") self.compare_images(result, expected)
def test_sharpened_1(self): im = lab.load_image('test_images/python.png') result = lab.sharpened(im, 11) lab.save_image(result, '/Users/yaxinliu/Downloads/lab0/sharpenedImage.png')