I\'m transferring Matlab\'s imresize code into python. I found the scipy\'s imresize, but I get a different results from Matlab.
How to get
To add one more option I found, while exploring the excellent answer by @rayryeng.
The scipy.misc.imresize uses PIL (and hence converts the image to scaled integers). But the page links to another function: scipy.ndimage.zoom
>>> from scipy import ndimage
>>> dtest = np.array(([1,2,3],[4,5,6],[7,8,9]), dtype='float')
>>> ndimage.zoom(dtest, 2/3)
array([[ 1., 3.],
[ 7., 9.]])
>>> ndimage.zoom(dtest, 2/3, prefilter=False)
array([[ 2.33333333, 3.66666667],
[ 6.33333333, 7.66666667]])
It does not give me the same result as matlab, but it comes close:
>> dtest = [1,2,3;4,5,6;7,8,9];
>> imresize(dtest, [2,2])
ans =
2.1296 3.5648
6.4352 7.8704
Depending on what you want to achieve, this could be useful. For me it has the advantage of not needing to include another package to the project, since scipy is already used.