I use this both function to find edges on a scale. You have a input image, you apply a mask (for ex. prewitt) to the input image, and get the resultant pic.
mypic = imread('examplepic.jpg')
hy = fspecial('prewitt')
yimfilter = imfilter(mypic,hy) % Using imfilter
yconv2 = conv2(mypic,hy) % Using conv2
Which is the theorical difference between these two? I know I got different outputs, but which is the difference?
Thanks
conv2 outputs the entire 2-D convolution, which means that yconv2 will be bigger than mypic. imfilter, on the other hand, by default trims the edges of the convolution so that yimfilter should be the same size as mypic. You can make imfilter leave the entire convolution like conv2 does, but that is not its default behavior.
There are other differences: imfilter's "replicate" option, imfilter can do convolution on arbitrary numbers of dimensions (not just 2), and so on, but I don't think you were asking about that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With