Skip to content

Commit

Permalink
pinned last pillow version
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 committed Oct 20, 2023
1 parent 2fa2f04 commit 5a80152
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions python/imagehash.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

def average_hash(image, hash_size=8, mean=numpy.mean):
# reduce size and complexity, then covert to grayscale
image = image.convert("L").resize((hash_size, hash_size), Image.ANTIALIAS)
image = image.convert("L").resize((hash_size, hash_size), Image.LANCZOS)
# find average pixel value; 'pixels' is an array of the pixel values, ranging from 0 (black) to 255 (white)
pixels = numpy.asarray(image)
avg = mean(pixels)
Expand All @@ -51,7 +51,7 @@ def average_hash(image, hash_size=8, mean=numpy.mean):

def phash(image, hash_size=8, highfreq_factor=4):
img_size = hash_size * highfreq_factor
image = image.convert("L").resize((img_size, img_size), Image.ANTIALIAS)
image = image.convert("L").resize((img_size, img_size), Image.LANCZOS)
pixels = numpy.asarray(image)
dct = scipy.fftpack.dct(scipy.fftpack.dct(pixels, axis=0), axis=1)
dctlowfreq = dct[:hash_size, :hash_size]
Expand All @@ -62,7 +62,7 @@ def phash(image, hash_size=8, highfreq_factor=4):

def phash_simple(image, hash_size=8, highfreq_factor=4):
img_size = hash_size * highfreq_factor
image = image.convert("L").resize((img_size, img_size), Image.ANTIALIAS)
image = image.convert("L").resize((img_size, img_size), Image.LANCZOS)
pixels = numpy.asarray(image)
dct = scipy.fftpack.dct(pixels)
dctlowfreq = dct[:hash_size, 1 : hash_size + 1]
Expand All @@ -72,15 +72,15 @@ def phash_simple(image, hash_size=8, highfreq_factor=4):


def dhash(image, hash_size=8):
image = image.convert("L").resize((hash_size + 1, hash_size), Image.ANTIALIAS)
image = image.convert("L").resize((hash_size + 1, hash_size), Image.LANCZOS)
pixels = numpy.asarray(image)
# compute differences between columns
diff = pixels[:, 1:] > pixels[:, :-1]
return diff


def dhash_vertical(image, hash_size=8):
image = image.convert("L").resize((hash_size, hash_size + 1), Image.ANTIALIAS)
image = image.convert("L").resize((hash_size, hash_size + 1), Image.LANCZOS)
pixels = numpy.asarray(image)
# compute differences between rows
diff = pixels[1:, :] > pixels[:-1, :]
Expand All @@ -101,7 +101,7 @@ def whash(image, hash_size=8, image_scale=None, mode="haar", remove_max_haar_ll=
assert level <= ll_max_level, "hash_size in a wrong range"
dwt_level = ll_max_level - level

image = image.convert("L").resize((image_scale, image_scale), Image.ANTIALIAS)
image = image.convert("L").resize((image_scale, image_scale), Image.LANCZOS)
pixels = numpy.asarray(image) / 255.0

# Remove low level frequency LL(max_ll) if @remove_max_haar_ll using haar filter
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy
scipy
pywavelets
pillow==9.5.0
pillow==10.1.0
hexhamming
nc-py-api==0.0.11
pi-heif>=0.9.0

0 comments on commit 5a80152

Please sign in to comment.