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

Home » Public Forums » archive » Re: Watersheds and Label_Region for 1d
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: Watersheds and Label_Region for 1d [message #20545 is a reply to message #20544] Fri, 07 July 2000 00:00 Go to previous messageGo to previous message
rshill is currently offline  rshill
Messages: 2
Registered: May 2000
Junior Member
My apologies to anyone who is seeing this message twice.

On Thu, 6 Jul 2000, Ben Tupper wrote:
> In order to do this I need to mimic the LABEL_REGION function on a
> vector. I can think of a number of
> ways of doing this... but they seem computationally expensive (lots of
> WHERE's and connectedness checking.)

One cheap trick is to replicate the vector three times and do the
label_region on the resulting 2-D array:

vec = [0,0,0,2,2,2,0,1,5,1,2,1,0,0,0,3,99,3,3]
arr = [0,vec,0] # [1,1,1] ; Avoid edge effects.
lab2d = label_region(arr)
lab1d = (lab2d[*,1])[1:n_elements(vec)]

Another thing you can do if you just want the endpoints of the runs is
this:

nv = n_elements(vec)
flag = [0, vec NE 0, 0] ; Avoid endpoint effects.
diff = flag[1:nv+1] - flag[0:nv]
run_start = where(diff EQ 1)
run_end = where(diff EQ -1) - 1

Footnote: Be careful with the type of the flag array, which
later determines the type of the diff array. Comparisons may depend
on variable type, because of signed vs. unsigned. In other words,
-1b (byte) is not equal to -1 (integer) because -1b is actually 255.

---Bob H.



Sent via Deja.com http://www.deja.com/
Before you buy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Object definition
Next Topic: Re: Animating in Color

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

Current Time: Sat Nov 29 01:27:59 PST 2025

Total time taken to generate the page: 0.07754 seconds