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 #20552 is a reply to message #20544] Thu, 06 July 2000 00:00 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
Hello,

I have made some progress. Well, I 've made some progress toward the
Label_Region function for vectors.

I tried a number of tricks including using the REVERSE_INDICES keyword for
HISTOGRAM.
In the end, I settled for the tried and true brute-force-and-ignorance
approach. It's not dainty but seems
to work with all of the mocked-up data I could think of.

;---------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
;-

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

LabeledVec = Fix(Vec GT 0)
N = N_elements(Vec)
MaxLabel = 0

If N_Params() EQ 2 then Background = Background[0] Else Background = 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: Wed Oct 08 19:28:01 PDT 2025

Total time taken to generate the page: 0.00406 seconds