comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: not-quite meidan filter
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: not-quite meidan filter [message #72736 is a reply to message #72735] Thu, 30 September 2010 13:29 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Sep 30, 3:38 pm, JJ <j...@cornell.edu> wrote:
> 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

So you're using a "mode" filter. Try max(histogram(pixels)). You
should be careful to choose your binsize appropriately if you have non-
integer data, however; or, alternatively you can use my statistical
mode which finds the mode of a continuous distribution by maximizing
the kernel density estimation. If you'd like the code for that, let
me know.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Color the points with different colors
Next Topic: Re: Help on Lon and lat.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 05:13:03 PDT 2025

Total time taken to generate the page: 1.59601 seconds