Skip to content

Commit

Permalink
Rename scipy.fftpack to scipy.fft
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Rotzbua committed Oct 24, 2023
1 parent 5e9ef5d commit bccedd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions imagehash/__init__.py
Expand Up @@ -269,11 +269,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
Expand All @@ -289,11 +289,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
Expand Down

0 comments on commit bccedd0

Please sign in to comment.