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

Home » Public Forums » archive » Re: cursor command
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: cursor command [message #83840 is a reply to message #83775] Fri, 05 April 2013 14:08 Go to previous message
gpeterso is currently offline  gpeterso
Messages: 22
Registered: February 2013
Junior Member
On Wednesday, April 3, 2013 6:48:07 AM UTC-7, rr...@stsci.edu wrote:
> On Tuesday, April 2, 2013 10:11:01 PM UTC-4, gpet...@ucsc.edu wrote:
>
>> http://www.idlcoyote.com/ip_tips/image_profile.html
>
>>
>
>>
>
>>
>
>> This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map.
>
>
>
> Ok. So now I think I know what's wrong. You want to draw a contour plot, then select a line, then have it plot the profile along that line. Got it. Well, I suppose a line is given by either two points: (x1,y1) and (x2,y2) or by a slope-intercept pair (m,b). Of course it's easy to convert between the two, but since you'e asked about cursor, I suppose we should use the two xy pairs.
>
>
>
> Here's the pseudocode.
>
> 1. plot the contour.
>
> 2. click once to get one point.
>
> 3. click a second time to get the other point.
>
> 4. draw the profile
>
> 5. Goto 2 or quit.
>
>
>
> Here's some IDL code
>
> ;step 0 read the image
>
> img=dist(200)
>
> sz=size(img,/dim) ;the size of the image
>
>
>
> ;step 1. draw the contour
>
> window,1,retain=2,xsize=400,ysize=400
>
> contour,img
>
>
>
> npoints=100 ;number of the line plot
>
>
>
> ;start a while loop so we can "goto" step 2
>
>
>
>
>
> ;save the current state of the mouse button. this is generally
>
> ;a good habit anytime you modify or test the system variables
>
> mousebutton=!mouse.button & !mouse.button=0
>
> print,'right click to quit'
>
> while !mouse.button ne 4 do begin
>
> ;double chcek that the window is set to the main one.
>
> wset,1
>
>
>
> print,'please click on one point.'
>
> cursor,x1,y1,3,/data
>
> if x1 lt 0 || y1 lt 0 || x1 gt sz(0) || y1 gt sz(1) then begin
>
> print,'first point is off the image.'
>
> goto,skip
>
> endif
>
>
>
> print,'please click on a second point.'
>
> cursor,x2,y2,3,/data
>
> if x2 lt 0 || y2 lt 0 || x2 gt sz(0) || y2 gt sz(1) then begin
>
> print,'second point is off the image.'
>
> goto,skip
>
> endif
>
>
>
>
>
>
>
> ;okay at this point, we have the two x,y pairs
>
> ;over plot the line
>
> oplot,[x1,x2],[y1,y2],line=1
>
>
>
> ;now extract the contour (via Fanning's webpage)
>
> xloc=x1+(x2-x1)*findgen(npoints)/(npoints-1)
>
> yloc=y1+(y2-y1)*findgen(npoints)/(npoints-1)
>
> line=interpolate(img,xloc,yloc)
>
>
>
> ;now create a second window for the plot
>
> window,3,retain=2,xsize=400,ysize=400
>
> plot,line
>
>
>
> ;set the window back to the first (in case you want to do it again)
>
> wset,1
>
>
>
> skip:
>
> endwhile
>
>
>
> ;if here, menas you quit. so lets uset the mousestate
>
> !mouse.button=mousebutton

Thank you russell! works great!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: map_do_segments: map file: plow not found
Next Topic: How to parse the output of restore, filename, /ver

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

Current Time: Wed Oct 08 18:15:25 PDT 2025

Total time taken to generate the page: 0.00426 seconds