Exemplo n.º 1
0
 def test_hash_distinct_images(self, hash_function):
     # Put in distinct images and check that hamming distance between hashes is large
     hash_im_1 = hash_function(PATH_SINGLE_IMAGE)
     hash_im_2 = hash_function(p.parent /
                               'data/mixed_images/ukbench09268.jpg')
     hamdist = Hashing.hamming_distance(hash_im_1, hash_im_2)
     assert hamdist > 20
Exemplo n.º 2
0
 def test_hash_small_rotation(self, hash_function):
     # Rotate image slightly (1 degree) and check that hamming distance between hashes is not too large
     orig_image = Image.open(PATH_SINGLE_IMAGE)
     rotated_image = np.array(orig_image.rotate(1))
     hash_im_1 = hash_function(image_array=np.array(orig_image))
     hash_im_2 = hash_function(image_array=rotated_image)
     hamdist = Hashing.hamming_distance(hash_im_1, hash_im_2)
     assert hamdist < 3
Exemplo n.º 3
0
 def test_hash_resize(self, hash_function):
     # Resize one image to (300, 300) and check that hamming distance between hashes is not too large
     hash_im_1 = hash_function(PATH_SINGLE_IMAGE)
     hash_im_2 = hash_function(PATH_SINGLE_IMAGE_RESIZED)
     hamdist = Hashing.hamming_distance(hash_im_1, hash_im_2)
     assert hamdist < 3