MATLAB: How to prevent conv2d from changing image size

conv2convolutiondigital image processingimage processingMATLAB

I have an image of size 330×363 uint8. I am convoluting it with 11×11 filter using conv2. The resulting image gets padded with zeros from top (6 pixels), bottom (4 pixels), left (6 pixels), right (4 pixels). Is there a way to prevent this padding from happening? Is it a good practice to crop the resulting image after the convolution?

Best Answer

conv2(A, B, 'same') or conv2(A, B, 'valid')