how 2x2 median filter works
9 ビュー (過去 30 日間)
古いコメントを表示
hi I tried this
- a = [ 1 2 3 ; 4 5 6; 7 8 9]
- b = medfilt2(a);
Output is [0,2,0;2,5,3;0,5,0]
How were values of b calculated from a ?
I can't figure out the logic.
Thanks.
0 件のコメント
回答 (2 件)
KSSV
2017 年 8 月 29 日
When ever you use a function in MATLAB.....it should be a common practice to read the documentation part of it. Read the documentation: https://in.mathworks.com/help/images/ref/medfilt2.html. The doc mentions the reference for the function. You may refer that for further idea.
Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, pp. 469-476.
3 件のコメント
Image Analyst
2017 年 9 月 2 日
Because when the window is centered such that most of the window is "off the image", the off image pixels are considered 0. Since most of the pixels are 0, 0 is the median.
Image Analyst
2017 年 9 月 30 日
When the image is this:
a =
1 2 3
4 5 6
7 8 9
and you're using a 2x2 window, and the 2x2 window is in the upper left, it will see
0 0
0 1
The zeros are where the window is off the array. So the median of three zeros and a 1 is zero, so that's why you got a zero in the upper left element of your output.
2 件のコメント
Image Analyst
2017 年 9 月 30 日
Are you using a 2x2, like your subject line says, or a 3x3 like your code does?
a = [ 1 2 3 ; 4 5 6; 7 8 9]
am3x3 = medfilt2(a)
am2x2 = medfilt2(a, [2, 2])
a =
1 2 3
4 5 6
7 8 9
am3x3 =
0 2 0
2 5 3
0 5 0
am2x2 =
3 4 1.5
6 7 3
3.5 4 0
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!