Re: collecting points with "cursor" procedure for several classes [message #43503] |
Mon, 18 April 2005 09:08 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Francois L. writes:
> Does someone has an idea on how to collect samples for several classes with
> the CURSOR procedure ?
> The problem is using a loop of the type while...
>
> For example, if I have 3 targets of interest and I want to collect several
> points for each target, I can think about the following pseudo-code:
> number_of_targets = 3
> tvscl, image
> for i=0, number_of_targets-1 do begin
> while (not finish cliking) do begin
> cursor, x,y, device
> xyouts, x, y, '+', /device
> endwhile
> endfor
>
> I am interested in keeping only pixels coordinates of samples.
> I know how to do it with xroi procedure but this one allows only to collect
> polygons.
>
> If the image is displayed, for one class, I would like to click on several
> samples and stop by clicking the right button of the mouse.
> This right-click would be the stop condition of the while loop.
> But how to code this ?
You would do it like this:
number_of_targets = 3
tvscl, image
targets = 0
!Mouse = 0
while (!Mouse NE 4) AND (targets LE number_of_targets) do begin
cursor, x,y, /device, /down
xyouts, x, y, '+', /device
targets = targets + 1
endwhile
But you *really* don't want to do this with the CURSOR command. :-)
Learn to write a widget program. You will have *infinitely* more
flexibility.
http://www.dfanning.com/widget_tips/line_on_image.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|