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

Home » Public Forums » archive » tracing contours, how?
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
tracing contours, how? [message #10730] Thu, 22 January 1998 00:00 Go to next message
becker is currently offline  becker
Messages: 1
Registered: January 1998
Junior Member
Hi,

I am trying to trace a special contour line in a 2D field, t, to
get the coordinates in data units. I tried

CONTOUR, t, PATH_XY=xy, PATH_INFO=info, levels=contourlevels
k = 0
FOR i=0, (N_ELEMENTS(info) - 1 ) DO BEGIN
FOR j=0, info(i).n-1 DO BEGIN
IF((info(i).value EQ tracecontourvalue)THEN BEGIN
print, info(i).value, xy(0, k+j), xy(1, k+j)
ENDIF
ENDFOR
k = j
ENDFOR

and was hoping that this would trace the polygons and give me all points
in normalized units if the contourvalue is tracecontourlevel. I got the
right contour, but the points it printed didn't really make sense. Why?
Did anybody solve this problem with IDL? Your help is greatly appreciated.
Thanks in advance

Thorsten

Thorsten W. Becker________________________becker@fas.harvard.edu
Re: tracing contours, how? [message #10798 is a reply to message #10730] Fri, 23 January 1998 00:00 Go to previous message
Armand J. L. Jongen is currently offline  Armand J. L. Jongen
Messages: 9
Registered: April 1997
Junior Member
Thorsten Becker wrote:
>
> Hi,
>
> I am trying to trace a special contour line in a 2D field, t, to
> get the coordinates in data units. I tried
>
> CONTOUR, t, PATH_XY=xy, PATH_INFO=info, levels=contourlevels
> k = 0
> FOR i=0, (N_ELEMENTS(info) - 1 ) DO BEGIN
> FOR j=0, info(i).n-1 DO BEGIN
> IF((info(i).value EQ tracecontourvalue)THEN BEGIN
> print, info(i).value, xy(0, k+j), xy(1, k+j)
> ENDIF
> ENDFOR
> k = j
> ENDFOR
>
> and was hoping that this would trace the polygons and give me all points
> in normalized units if the contourvalue is tracecontourlevel. I got the
> right contour, but the points it printed didn't really make sense. Why?
> Did anybody solve this problem with IDL? Your help is greatly appreciated.

I think that for just getting the coordinates for one polygon at a
certain level the suggestion from David works best. So just do:

CONTOUR, t, PATH_XY=xy, /Path_Data_Coords, $
levels=tracecontourvalue

Both probably you have some troubles that there are more polygons at the
same level generated and you want to seperate them. The way I did this
for selscting the longest polygon is:

; Here I set the desired thresholdvalue

Levels=[ThresHoldVal]

Contour, ImageData, /Follow, $
Levels=Levels, /Closed, $
Path_XY=xy, Path_Info=pathinfo, /Path_Data_Coords

; Check if there are results and then

If N_Elements(pathinfo) GT 0 Then Begin

; choose a selection-criterion
; I look for the longest polygon

Dum = Max(pathinfo.N,IMax)

; Look at the manual pages for Contour. The returned Path_XY is NOT
; in device_coords but also needs a offset

S = [INDGEN(pathinfo(IMax).N), 0]

; Here the area xy(*, pathinfo(IMax).Offset+S) contains the polygon
coords in
; /device for the selected polygon.

PlotS, xy(*, pathinfo(IMax).Offset+S), /Device

Endif

I hope this helps. Remember to look at the manual page for Contour to
see how Path_XY and Path_Info are returned.

Cheers,

--
************************************************************ ************
Armand J.L. Jongen Academic Medical Centre
Laser Centre
Phone +31-20-5667418 \\||||// Meibergdreef 9
Fax +31-20-6975594 | ~ ~ | 1105 AZ Amsterdam
E-mail a.j.jongen@amc.uva.nl [| o o |] The Netherlands
*****************************o00o***(__)***o00o************* ************
Re: tracing contours, how? [message #10829 is a reply to message #10730] Thu, 22 January 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Thorsten Becker (becker@fas.harvard.edu) writes:

> I am trying to trace a special contour line in a 2D field, t, to
> get the coordinates in data units. I tried
>
> CONTOUR, t, PATH_XY=xy, PATH_INFO=info, levels=contourlevels
> k = 0
> FOR i=0, (N_ELEMENTS(info) - 1 ) DO BEGIN
> FOR j=0, info(i).n-1 DO BEGIN
> IF((info(i).value EQ tracecontourvalue)THEN BEGIN
> print, info(i).value, xy(0, k+j), xy(1, k+j)
> ENDIF
> ENDFOR
> k = j
> ENDFOR
>
> and was hoping that this would trace the polygons and give me all points
> in normalized units if the contourvalue is tracecontourlevel. I got the
> right contour, but the points it printed didn't really make sense. Why?
> Did anybody solve this problem with IDL?

Perhaps I don't understand this question, but why won't
this work:

CONTOUR, t, PATH_XY=xy, /Path_Data_Coords, $
levels=tracecontourvalue

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Programming Position in Baltimore
Next Topic: I want to know more about IDL

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

Current Time: Wed Oct 08 18:13:59 PDT 2025

Total time taken to generate the page: 0.00705 seconds