how 2x2 median filter works
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
KSSV
il 29 Ago 2017
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 Commenti
Image Analyst
il 2 Set 2017
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
il 30 Set 2017
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 Commenti
Image Analyst
il 30 Set 2017
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
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!