Re: not-quite meidan filter [message #72734 is a reply to message #72733] |
Thu, 30 September 2010 14:06   |
JJ
Messages: 36 Registered: January 2007
|
Member |
|
|
>
> 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.
I think I see what you're suggesting, but unless I'm missing
something, it seems that I would still have to loop over all the
pixels in my image - which is exactly what I don't want to do. It's
good to know the name "mode" though.
I have worked up a solution which will work as long as I have a
limited number of possible values - my test case is only 53 distinct
values, which is OK. I create a 3D array with a slice for each
distinct value, where value of each slice is the coverage (0 or 1) for
that particular value. I then convol each slice with a simple box
kernel filled with 1's, which gives me number of instances of that
value in the box. Then I do a max (dim = 3) on the cube and get the
"max_subscripts", which I can then easily convert to the disticnt
value that I want.
This method is reasonably fast (especially compared to how long a loop
would take), but seems a little clunky and might cause trouble with a
lot more values. Come to think of it though, I don't need the whole
cube - I could just process one value at a time and just keep the
maximum so far.
Any better solutions appreciated.
Thanks.
-Jonathan
|
|
|