MATLAB: How to slid filter window of 3*3 over the pixels of image.

filterimage processing

can anyone plz tell me how to slid a filter window of 3*3 over the pixels of an image one by one.Suppose i have and image with pixels
A= 44 25 22 55 21 11 10 23 ; 35 43 2 23 45 66 86 97 ; 12 22 19 12 76 58 56 23 ; 21 23 43 12 65 75 55 75 ;
I want to slide a filter mask/window of 3*3 over these pixels of image .let the mask be
Mask= 1 1 1 ; 1 1 1 ; 1 1 1 ; plz tell me the coding how to slid this mask over pixels one by one. I have also attached PDF version if anyone know how to do the coading then plz help.

Best Answer

use imfilter() it gives you more option than conv2.
For the border pixels instead of using zeros (as in conv2 case) you can define symmetric, replicate, or even circular boundary condition which gives you better results.
As image Analyst said, Another reason that imfilter is suggested in your case is that conv flips the mask. in your case it doesn't matter because you are using symmetric kernel. if you don't want to flip your kernel you should use cross correlation.
Check here and the graph to see how these two, i.e. convolution and cross-correlation, will produce different output.
Related Question