What is the difference between conv2 and imfilter?
Afficher commentaires plus anciens
Hello ,
i am trying to convolute an image (512x512) with a filter (3x3) .For this process i am using both covv2() and imfilter() . These functions are supposed to do the same but after the convolution in the first case(conv2) i am getting a new image 516x516 and in the second case (imfilter) i am getting a new image 514x514 .Why is this happening?
Réponse acceptée
Plus de réponses (1)
Bjorn Gustavsson
le 14 Oct 2020
The first question is very simple to answer, conv2 has as its default behaviour:
'full' - (default) returns the full 2-D convolution,
That is with sizes of your image of szIm1, and szIm2 and size of the filter szK1 and szK2 the result of conv2 shold be:
[szIm1 + 2*(szK1-1), szIm2 + 2*(szK2-1)] i.e. [512 + 2*(3-1), 512 + 2*(3-1)]. Typically I call conv2 with the 'same' shape-argument, which returns a result with the same size as the input-array.
Regarding imfilter your result is very confusing, the default shape-argument is 'same' which should return an image with the same size as the input-image, of 'full' which to the best of my understanding in your case should return an array with the size of 516x516, why it doesn't is difficult to speculate about. Have a look at the help and documentation of both functions.
HTH
Catégories
En savoir plus sur Image Filtering dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!