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 #20547 is a reply to message #20544] Fri, 07 July 2000 00:00 Go to previous messageGo to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
Shame on me!

I posted unfinished code. Please find the corrected version below.

Ben

----snip

;+
; NAME: LABEL_VECTOR
;
; PURPOSE: This function returns a labeled (blob-colored) vector
; where each unique region bears a unique region number.
; This function is analogous to the built in LABEL_REGION function for IDL.
;
; CALLING SEQUENCE:
; Result = LABEL_VECTOR(Vector, [BackGround])
;
; ARGUMENTS:
; Vector Set this value to a numeric vector (Byte,Integer, etc.)
; BackGround Set this argument equal to the background value
; of the vector... that is, the value that separates the blobs.
; If not provided, the default value of zero is used.
;
; KEYWORDS:
;
; MAXLABEL Set this keyword to a named variable to retrieve the
; maximum label value. (Saves a MAX(Result) later.)
;
; EXAMPLE:
; Generate a dummy vector... then plot it with the colorings
; superimposed.
; IDL> v = indgen(20)
; IDL> v = rebin(shift(v*5,5), 80,/sample)
; IDL> f = Label_Vector(V)
; IDL> plot, v
; IDL> TEK_COLOR
; IDL> plots, indgen(80), v, color=f, /data, psym = 6
;
; MODIFICATION HISTORY:
; Written 6JULY2000, Ben Tupper
; Bigelow Laboratoryu for Ocean Science
; tupper@seadas.bigelow.org
; pemaquidriver@tidewater.net
;
; 7JUL2000 oops!, Actually implement Background argument! BT
;-

;-------
; Label_Vector
;-------
FUNCTION Label_Vector, Vec, BackGround ,MaxLabel = MaxLabel

On_Error, 2

Sz = Size(Vec)
If Sz[0] NE 1 Then Begin
Message,'First argument must be a 1d vector'
Return, -1
EndIf

If N_Params() EQ 2 then Background = Background[0] Else Background = 0
LabeledVec = Fix(Vec NE BackGround)
N = Sz[3]
MaxLabel = 0

A = Where(Labeledvec GT 0, Count)

If Count GT 0 Then Begin

MaxLabel = 1

For i = A[0] , N - 1L Do Begin

If LabeledVec[i] GT 0 Then Begin

LabeledVec[i] = MaxLabel

EndIf Else Begin

If i NE N-1L Then $
If LabeledVec[i] NE LabeledVec[i+1L] Then $
MaxLabel = MaxLabel +1

EndElse

EndFor ; i loop

EndIf ; Count GT 0

Return, LabeledVec

END

----snip


--
Ben Tupper

Bigelow Laboratory for Ocean Science
tupper@seadas.bigelow.org

pemaquidriver@tidewater.net
[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 Oct 11 05:32:18 PDT 2025

Total time taken to generate the page: 3.52095 seconds