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

Home » Public Forums » archive » Re: how to find continuous regions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: how to find continuous regions [message #58625] Mon, 11 February 2008 09:46 Go to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Mark wrote:
> Hello.
>
> Does anyone know of any code that finds continuous regions? To be more
> exact:
>
> I have a 3D dataset, say 64x64x64. Within this array, many entries
> will be 1, some will be zero. Is there an easy way to identify all the
> groups of array elements equal to 1 which lie adjacent to each other?
>
> For a 1D dataset this is what I'm looking for:
>
> arr=[0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1,1,1,1,1, 0, 0, 0, 0]
> first second third
> So, there are three continuous regions. (I don't care about isolated
> 1's).
> I'd like to have an array (arr2) returned where I'd have something
> like:
>
> arr =[0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1,1,1,1,1, 0, 0, 0, 0]
> arr2=[0, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3,3, 3,3,3, 0, 0, 0, 0]
>
> As I said, I need such a thing for a 3D array....
>
> I expect I'm looking at recursive routines which I've always had
> trouble getting my mind around. I'd rather not re-invent the wheel if
> I can avoid it.
>
> Thanks!
>
> Mark

Hi Mark,
have a look at LABEL_REGION
Note that, to get correct result, you would have to increase the size of
each dimension by 1, as the outer limit is not considered in the algorithm.

data = indgen(10,10)
==> data2 = intarr(12,12)
data2[1:10,1:10] = data

result = lab_region(data2)

Jean
Re: how to find continuous regions [message #58626 is a reply to message #58625] Mon, 11 February 2008 09:49 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Feb 11, 10:16 am, Mark <astrobo...@gmail.com> wrote:
> Hello.
>
> Does anyone know of any code that finds continuous regions? To be more
> exact:
>
> I have a 3D dataset, say 64x64x64. Within this array, many entries
> will be 1, some will be zero. Is there an easy way to identify all the
> groups of array elements equal to 1 which lie adjacent to each other?
>
> For a 1D dataset this is what I'm looking for:
>
> arr=[0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1,1,1,1,1, 0, 0, 0, 0]
>           first             second             third
> So, there are three continuous regions. (I don't care about isolated
> 1's).
> I'd like to have an array (arr2) returned where I'd have something
> like:
>
> arr  =[0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1,1,1,1,1, 0, 0, 0, 0]
> arr2=[0, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3,3, 3,3,3, 0, 0, 0, 0]
>
> As I said, I need such a thing for a 3D array....
>
> I expect I'm looking at recursive routines which I've always had
> trouble getting my mind around. I'd rather not re-invent the wheel if
> I can avoid it.

Check out LABEL_REGION.

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how to find continuous regions
Next Topic: Re: A whine about default device settings

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

Current Time: Wed Oct 08 20:01:12 PDT 2025

Total time taken to generate the page: 0.00507 seconds