Skip to content

Commit 544cdef

Browse files
committed
update usage of scipy.misc.imresize
1 parent f5301bb commit 544cdef

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

pybalu/feature_extraction/fourier.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
__all__ = ['fourier_features', 'FourierExtractor']
22

33
import numpy as np
4-
from scipy.misc import imresize
54
import itertools as it
5+
from PIL import Image
66

77
from pybalu.base import FeatureExtractor
88

@@ -89,15 +89,13 @@ def fourier_features(image, region=None, *, vresize=64, hresize=64, vfreq=2, hfr
8989
if show:
9090
print('--- extracting Fourier features...')
9191

92-
img_resize = imresize(I, (vresize, hresize), interp='bicubic', mode='F')
92+
img_resize = _imresize(I, (vresize, hresize))
9393
img_fourier = np.fft.fft2(img_resize)
9494
img_abs = np.abs(img_fourier)
9595
img_angle = np.angle(img_fourier)
9696

97-
F = imresize(img_abs[:v_half, :h_half],
98-
(vfreq, hfreq), interp='bicubic', mode='F')
99-
A = imresize(img_angle[:v_half, :h_half],
100-
(vfreq, hfreq), interp='bicubic', mode='F')
97+
F = _imresize(img_abs[:v_half, :h_half], (vfreq, hfreq))
98+
A = _imresize(img_angle[:v_half, :h_half], (vfreq, hfreq))
10199

102100
features = np.hstack([F.ravel(), A.ravel()]).astype(float)
103101
if labels:
@@ -110,6 +108,11 @@ def fourier_features(image, region=None, *, vresize=64, hresize=64, vfreq=2, hfr
110108
return features
111109

112110

111+
def _imresize(arr, size):
112+
"""Used to keep compatibility with deprecated scipy function `imresize`"""
113+
return np.array(Image.fromarray(arr).resize(size))
114+
115+
113116
class FourierExtractor(FeatureExtractor):
114117
def __init__(self, *, vresize=64, hresize=64, vfreq=2, hfreq=2):
115118
self.vresize = vresize

pybalu/io/imread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def imread(filename, *, normalize=False, flatten=False):
1818
normalize: boolean, optional
1919
If set to true, the return value will be an array with float values between 0 and 1.
2020
If set to false, the reurn value will be an array with uint8 values between 0 and 255.
21-
default value is True.
21+
default value is False.
2222
flatten: boolean, optional
2323
If set to true, the return value is a 2 dimensional ndarray with the grayscale
2424
representation of the loaded image.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cython>=0.29.6
22
numpy>=1.16.1
33
scipy>=1.1.0
44
imageio>=2.5.0
5+
Pillow>=7.2.0
56
scikit-image>=0.14.2
67
scikit-learn>=0.20.2
78
tqdm>=4.29.1

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,19 @@ def getext(filename): return os.path.splitext(filename)[1]
356356
"numpy>=1.16.1",
357357
"scipy>=1.1.0",
358358
"imageio>=2.5.0",
359-
"scikit-image>=0.14.2",
360-
"scikit-learn>=0.20.2",
359+
"Pillow>=7.2.0",
360+
"scikit-image>=0.17.2",
361+
"scikit-learn>=0.22.2",
361362
"tqdm>=4.29.1"
362363
],
363364
setup_requires=[
364365
"cython>=0.29.6",
365366
"numpy>=1.16.1",
366367
"scipy>=1.1.0",
367368
"imageio>=2.5.0",
368-
"scikit-image>=0.14.2",
369-
"scikit-learn>=0.20.2",
369+
"Pillow>=7.2.0",
370+
"scikit-image>=0.17.2",
371+
"scikit-learn>=0.22.2",
370372
"tqdm>=4.29.1"
371373
],
372374
python_requires='!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4',

0 commit comments

Comments
 (0)