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

Home » Public Forums » archive » Re: Grouping adjacent detected pixels?
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: Grouping adjacent detected pixels? [message #4996] Mon, 28 August 1995 00:00 Go to previous message
Thomas A McGlynn is currently offline  Thomas A McGlynn
Messages: 3
Registered: August 1995
Junior Member
grunes@news.nrl.navy.mil (Mitchell R Grunes) wrote:
> Subject: Grouping adjacent detected pixels?
>
> I have an image of "detected" points--
> True for pixels meeting some detection criteria (such as brightness).
> False otherwise.
>
> I wish, using WAVE or IDL, to:
>
> 1. Group together adjacent detected pixels.
> If I want to get fancy, I might try to group together detected
> pixels which are within a specific distance of touching.
>
> 2. Get a something like a structure back, each element of which
> describes one such group. Each element would be an array
> of the coordinates of the pixels in the adjacent group.
>
> Can anyone think of an EFFICIENT way to do this that does not involve
> a massively slow loop which loops once for each detected pixel?
>
> (There are many, many detected points, and IDL/WAVE are rather slow
> at loops.)
>
> Thanks in advance for your response.


Suppose you have a one dimensional array x of dimension n
where x ne 0 for detected pixels.

Then you can find the starting offset of each group of pixels with

w= where(x(0:n-2) eq 0 and x(1:n-1) ne 0) )

You'll need to handle the first pixel specially and add 1 or 2 to the
offsets

e.g.,
IDL> a=[0,0,0,1,1,1,0,1,0,0,0,1,1,0,0,1,0,1,0]
IDL> help,a
A INT = Array(19)
IDL> w=where(a(0:17) eq 0 and a(1:18) ne 0)
IDL> print,w
2 6 10 14 16


To handle multidimensional stuff you'll need to do something more
sophisticated, but you can do similar things to get rid of at
least the innermost loop.

Hope this helps,
Tom McGlynn
mcglynn@grossc.gsfc.nasa.gov
[Message index]
 
Read Message
Read Message
Previous Topic: test
Next Topic: Grouping adjacent detected pixels?

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

Current Time: Fri Oct 10 18:19:53 PDT 2025

Total time taken to generate the page: 1.60076 seconds