not-quite meidan filter [message #72740] |
Thu, 30 September 2010 12:38 |
JJ
Messages: 36 Registered: January 2007
|
Member |
|
|
I would like to do something that is similar to, but not quite the
same as, a median filter to a 2D array. Instead of choosing the
median value in a box surrounding each pixel, I would like to chose
the value in that box that occurs most frequently.
For example, if I had
1 1 1 1 1
1 1 1 1 1
2 2 2 2 2
2 2 3 3 3
3 3 3 3 3
The median would be 2, but I would want the value 1 (it occurs 10
times, which is more than the 8 instances of the value 3 or the 7
instances of the value 2).
Can anyone think of a clever way to do this that would be fast in IDL
(ie, no looping through the pixels)? I need it to work for box sizes
up to around 21. Ties may be broken arbitrarily.
Is there already a name for this concept?
Thanks.
-Jonathan
|
|
|