[SciPy-User] Matlab imfilter/fspecial equivalent
Michael Borck
michael at yanchepmartialarts.com.au
Fri May 17 13:38:41 EDT 2013
An update. On further testing, the problem appeared to be caused by
converting the RGB image to grayscale, not imresize(). I was getting
different image values using a rgb2grayscale convertor form skimage.
If I use ndimage.imread(, flatten=True) then I get the same values in
the image array/matrix. Since I was using skimage to do the
conversion, I posted a query on the skimage mail list, and got back the
following response:
They're just different color conversion factors. Based on
http://www.mathworks.com/help/images/ref/rgb2gray.html, Matlab uses:
0.2989 R + 0.5870 G + 0.1140 B
Based on the docstring for `color.rgb2gray`:
0.2125 R + 0.7154 G + 0.0721 B
So I think this will explain why the output is similar in structure but
different in detail. I will write a convertor using the Matlab's
conversion factors to convince myself that the output is the same as in
the paper.
I will post the final ported version later.
Michael.
--
On 17/05/13 8:23 AM, Brickle Macho wrote:
> I am getting closer. Here are some observations:
>
> * If I don't imresize() the original image, then visually I can't tell
> the difference in the output image from Matlab or Scipy.
> * Empirically the results using different kernels are the same. That
> is the difference between two images is essentially zero. That is
> doesn't seem to matter if I use the imported the "fspecial()" kernel
> from matlab; generate my own kernel using a fgaussion(), or use
> scipy.ndimage.gaussian_filter().
>
> So look like the problem is with ndimage.resize().
>
> Michael.
> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130517/8c240a26/attachment.html>
More information about the SciPy-User
mailing list