Re: Blanking all 5x5 windows with less than X 'on' pixels in them [message #74540 is a reply to message #74539] |
Fri, 21 January 2011 02:52   |
Axel Martínez
Messages: 22 Registered: June 2010
|
Junior Member |
|
|
On Jan 21, 11:41 am, Axel M <axe...@gmail.com> wrote:
> On Jan 21, 10:02 am, Robin Wilson <ro...@rtwilson.com> wrote:
>
>
>
>> Hi Chris,
>
>> That's great. Yes, your description is correct - that's exactly what I
>> want to do.
>
>> Cheers,
>
>> Robin
>
>>> Hi Robin,
>>> i have such a vectorised function. Please give more details. Do you
>>> want to clean all pixels including the center pixel in a moving
>>> window, if the center pixel is below a threshold?
>
>>> Cheers
>
>>> CR
>
> Hi Robin,
>
> You described the problem in two different ways:
> (1) clean the pixel neighborhood if the center pixel is below a
> threshold
> (2) clean the pixel if the number of neighbors on is below a threshold
>
> I understand that you actually mean case (2). You can try that (I did
> not test the code):
> kernel_size = 9
> threshold = 3.0 / (kernel_size*kernel_size) ;3 pixels on out of a 9x9
> neighborhood
> Image[WHERE(SMOOTH(image, [kernel_size,kernel_size], /EDGE_TRUNCATE)
> LT threshold)] = 0
A correction: if image is not a float array, please change it like
that:
Image[WHERE(SMOOTH(FLOAT(image), [kernel_size,kernel_size], /
EDGE_TRUNCATE) LT threshold)] = 0
If you want the code to be robust, you should also check that WHERE is
not -1.
|
|
|