Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename scipy.fftpack to scipy.fft #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down