From f8bd5b64f102ca03317635e878c8291ee4dd8d93 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 24 Oct 2023 19:33:50 +0200 Subject: [PATCH] Rename `scipy.fftpack` to `scipy.fft` This submodule is considered legacy and will no longer receive updates. This could also mean it will be removed in future SciPy versions. New code should use scipy.fft. https://docs.scipy.org/doc/scipy/reference/fftpack.html --- README.rst | 2 +- imagehash/__init__.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 243f836..7345dd0 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ black & gray fractions (without position information). Installation ============ -Based on PIL/Pillow Image, numpy and scipy.fftpack (for pHash) +Based on PIL/Pillow Image, numpy and scipy.fft (for pHash) Easy installation through `pypi`_:: pip install imagehash diff --git a/imagehash/__init__.py b/imagehash/__init__.py index 47e5e7d..a3dd361 100644 --- a/imagehash/__init__.py +++ b/imagehash/__init__.py @@ -270,11 +270,11 @@ def phash(image, hash_size=8, highfreq_factor=4): if hash_size < 2: raise ValueError('Hash size must be greater than or equal to 2') - import scipy.fftpack + import scipy.fft img_size = hash_size * highfreq_factor image = image.convert('L').resize((img_size, img_size), ANTIALIAS) pixels = numpy.asarray(image) - dct = scipy.fftpack.dct(scipy.fftpack.dct(pixels, axis=0), axis=1) + dct = scipy.fft.dct(scipy.fft.dct(pixels, axis=0), axis=1) dctlowfreq = dct[:hash_size, :hash_size] med = numpy.median(dctlowfreq) diff = dctlowfreq > med @@ -290,11 +290,11 @@ def phash_simple(image, hash_size=8, highfreq_factor=4): @image must be a PIL instance. """ - import scipy.fftpack + import scipy.fft img_size = hash_size * highfreq_factor image = image.convert('L').resize((img_size, img_size), ANTIALIAS) pixels = numpy.asarray(image) - dct = scipy.fftpack.dct(pixels) + dct = scipy.fft.dct(pixels) dctlowfreq = dct[:hash_size, 1:hash_size + 1] avg = dctlowfreq.mean() diff = dctlowfreq > avg