4141
4242def average_hash (image , hash_size = 8 , mean = numpy .mean ):
4343 # reduce size and complexity, then covert to grayscale
44- image = image .convert ("L" ).resize ((hash_size , hash_size ), Image .ANTIALIAS )
44+ image = image .convert ("L" ).resize ((hash_size , hash_size ), Image .LANCZOS )
4545 # find average pixel value; 'pixels' is an array of the pixel values, ranging from 0 (black) to 255 (white)
4646 pixels = numpy .asarray (image )
4747 avg = mean (pixels )
@@ -51,7 +51,7 @@ def average_hash(image, hash_size=8, mean=numpy.mean):
5151
5252def phash (image , hash_size = 8 , highfreq_factor = 4 ):
5353 img_size = hash_size * highfreq_factor
54- image = image .convert ("L" ).resize ((img_size , img_size ), Image .ANTIALIAS )
54+ image = image .convert ("L" ).resize ((img_size , img_size ), Image .LANCZOS )
5555 pixels = numpy .asarray (image )
5656 dct = scipy .fftpack .dct (scipy .fftpack .dct (pixels , axis = 0 ), axis = 1 )
5757 dctlowfreq = dct [:hash_size , :hash_size ]
@@ -62,7 +62,7 @@ def phash(image, hash_size=8, highfreq_factor=4):
6262
6363def phash_simple (image , hash_size = 8 , highfreq_factor = 4 ):
6464 img_size = hash_size * highfreq_factor
65- image = image .convert ("L" ).resize ((img_size , img_size ), Image .ANTIALIAS )
65+ image = image .convert ("L" ).resize ((img_size , img_size ), Image .LANCZOS )
6666 pixels = numpy .asarray (image )
6767 dct = scipy .fftpack .dct (pixels )
6868 dctlowfreq = dct [:hash_size , 1 : hash_size + 1 ]
@@ -72,15 +72,15 @@ def phash_simple(image, hash_size=8, highfreq_factor=4):
7272
7373
7474def dhash (image , hash_size = 8 ):
75- image = image .convert ("L" ).resize ((hash_size + 1 , hash_size ), Image .ANTIALIAS )
75+ image = image .convert ("L" ).resize ((hash_size + 1 , hash_size ), Image .LANCZOS )
7676 pixels = numpy .asarray (image )
7777 # compute differences between columns
7878 diff = pixels [:, 1 :] > pixels [:, :- 1 ]
7979 return diff
8080
8181
8282def dhash_vertical (image , hash_size = 8 ):
83- image = image .convert ("L" ).resize ((hash_size , hash_size + 1 ), Image .ANTIALIAS )
83+ image = image .convert ("L" ).resize ((hash_size , hash_size + 1 ), Image .LANCZOS )
8484 pixels = numpy .asarray (image )
8585 # compute differences between rows
8686 diff = pixels [1 :, :] > pixels [:- 1 , :]
@@ -101,7 +101,7 @@ def whash(image, hash_size=8, image_scale=None, mode="haar", remove_max_haar_ll=
101101 assert level <= ll_max_level , "hash_size in a wrong range"
102102 dwt_level = ll_max_level - level
103103
104- image = image .convert ("L" ).resize ((image_scale , image_scale ), Image .ANTIALIAS )
104+ image = image .convert ("L" ).resize ((image_scale , image_scale ), Image .LANCZOS )
105105 pixels = numpy .asarray (image ) / 255.0
106106
107107 # Remove low level frequency LL(max_ll) if @remove_max_haar_ll using haar filter
0 commit comments