how to slid filter window of 3*3 over the pixels of image.
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Geoff Hayes
el 10 de Oct. de 2014
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];
Mask = [ 1 1 1
1 1 1
1 1 1];
C = conv2(A,Mask,'same');
where C would be
C =
147 171 170 168 221 239 293 216
181 224 223 275 367 429 430 295
156 220 199 297 432 582 591 392
78 140 131 227 298 385 342 209
The same shape parameter ensures that the output matrix is the same size as A. Note that if the window falls outside of the matrix A, then zeros are used in place (so A is zero-padded).
1 comentario
Image Analyst
el 10 de Oct. de 2014
imfilter() in the Image Processing Toolbox does the same thing and gives you the option of flipping the kernel or not. For this case (all 1's) it doesn't matter but if you ever change the mask Ravneet to something that's not symmetrical, and wonder why the numbers don't match up, then brush up on the definition of convolution, or flip your mask or use imfilter.
Categorías
Más información sobre Image Filtering en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!