how to slid filter window of 3*3 over the pixels of image.
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Geoff Hayes
2014년 10월 10일
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
Image Analyst
2014년 10월 10일
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.
카테고리
도움말 센터 및 File Exchange에서 Image Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!