Re: Grouping adjacent detected pixels? [message #4996] |
Mon, 28 August 1995 00:00 |
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
|
|
|
Re: Grouping adjacent detected pixels? [message #4997 is a reply to message #4996] |
Mon, 28 August 1995 00:00  |
chase
Messages: 62 Registered: May 1993
|
Member |
|
|
>>>> > "Mitchell" == Mitchell R Grunes <grunes@news.nrl.navy.mil> writes:
In article <grunes.160.809624931@news.nrl.navy.mil> grunes@news.nrl.navy.mil (Mitchell R Grunes) writes:
Mitchell> Subject: Grouping adjacent detected pixels?
Mitchell> I have an image of "detected" points--
Mitchell> True for pixels meeting some detection criteria (such as brightness).
Mitchell> False otherwise.
Mitchell> I wish, using WAVE or IDL, to:
Mitchell> 1. Group together adjacent detected pixels.
Mitchell> If I want to get fancy, I might try to group together detected
Mitchell> pixels which are within a specific distance of touching.
If you only want to groups as adjacent pixels, try the LABEL_REGION
command that comes with IDL. If you want a distance larger than 1 for
"adjancent" pixels you can combine DILATE (or convolution with a more
general kernel) with label_region and AND the result with your
original image.
Chris
--
===============================
Bldg 24-E188
The Applied Physics Laboratory
The Johns Hopkins University
Laurel, MD 20723-6099
(301)953-6000 x8529
chris.chase@jhuapl.edu
|
|
|