[SciPy-User] Matlab imfilter/fspecial equivalent
Brickle Macho
bricklemacho at gmail.com
Wed May 15 22:19:35 EDT 2013
I am porting some Matlab code to python. When I run the ported version
the output differs. It appears the difference may be due to how I have
translated Matlab's imfilter() and/or fspecial(). Below are my
translation, are there any Scipy/Matlab gurus that can let me know if
there are correct or if I have made some errors, or could suggest better
translations.
Matlab: imfilter(saliencyMap, fspecial('gaussian', [10, 10], 2.5))
Scipy: ndimage.gaussian_filter(saliencyMap, sigma=2.5)
Also the following. At the rsik of highlighting my lack of
understanding of the temrinology, Is uniform_filter the same as 'average'?
Matlab: imfilter(myLogAmplitude, fspecial('average', 3), 'replicate');
Scipy: scipy.ndimage.uniform_filter(mylogAmplitude, size=3, mode="nearest")
Thanks,
Michael.
--
If curious here are the 8 lines of matlab code I am trying to port:
%% Read image from file
inImg = im2double(rgb2gray(imread('yourImage.jpg')));
inImg = imresize(inImg, 64/size(inImg, 2));
%% Spectral Residual
myFFT = fft2(inImg);
myLogAmplitude = log(abs(myFFT));
myPhase = angle(myFFT);
mySpectralResidual = myLogAmplitude - imfilter(myLogAmplitude,
fspecial('average', 3), 'replicate');
saliencyMap = abs(ifft2(exp(mySpectralResidual + i*myPhase))).^2;
%% After Effect
saliencyMap = mat2gray(imfilter(saliencyMap, fspecial('gaussian', [10,
10], 2.5)));
imshow(saliencyMap);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130516/bc6815e6/attachment.html>
More information about the SciPy-User
mailing list