Borrar filtros
Borrar filtros

how 2x2 median filter works

10 visualizaciones (últimos 30 días)
sumeet
sumeet el 29 de Ag. de 2017
Comentada: Image Analyst el 30 de Sept. de 2017
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.

Respuestas (2)

KSSV
KSSV el 29 de Ag. de 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 comentarios
Image Analyst
Image Analyst el 2 de Sept. de 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.
sumeet
sumeet el 30 de Sept. de 2017
The problem is how is window decided for a particular pixel ? The documentation taught that medfilt2 will take 4 values , find their average , discard the fraction and give whole number as output . Is that right ? Then , let the window have values called top left , top right , bottom left and bottom right . 1 maps to 0 would mean that avg of 4 values < 1 . similiarly for 3,7,9 .
2 maps to 2 would mean that avg of 4 values >= 2 and <3 . similairly for 4.
5 maps to 5 would mean that avg of 4 values >= 5 and <6 . similairly for 8.
6 maps to 3 would mean that avg of 4 values >= 3 and <4 .
Now can you tell me four values considered for each case above ? I am unable to find neighbour choosing criterion such that above mapping happens .
Thanks a lot.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 30 de Sept. de 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 comentarios
sumeet
sumeet el 30 de Sept. de 2017
that explains 1->0 .
now for 2 the window must be
0 0
1 2
the average is 3 . 3/4 is 0.75 so output should be 0.
how do we get 2 there ?
Image Analyst
Image Analyst el 30 de Sept. de 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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by