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

Home » Public Forums » archive » Re: array index, data coordinates, rotate direction, ...
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: array index, data coordinates, rotate direction, ... [message #45264] Wed, 24 August 2005 19:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael A. Miller writes:

> I deal with medical images and display with direct graphics using
> tv. These image are stored in arrays that are N x M pixels, and
> each pixel is A mm x B mm in size. I'm trying to figure out how
> to set up the display so that "cursor, /data" returns positions
> in mm on this image. I do this with plot:
>
> A = 0.5
> B = 0.5
> N = 256
> M = 336
>
> image = REPLICATE(1, N) # FINDGEN(M)
>
> window, xsize=N, ysize=M, /free
> TV, bytscl(image)
>
> xs = A*indgen(N)
> ys = B*indgen(M)
> plot, A*indgen(N), B*indgen(M), $
> /noerase, $
> /nodata, $
> xstyle=5, $
> ystyle=5, $
> position=[0,0,1,1], $
> xrange=[min(xs),max(xs)], $
> yrange=[min(ys),max(ys)]
>
>
> cursor, x, y, /device
> print, x, y
>
> cursor, x, y, /normal
> print, x, y
>
> cursor, x, y, /data
> print, x, y
>
> But now I want to rotate my image and display it:
>
> window, xsize=M, ysize=N, /free
> TV, bytscl(rotate(image,1))
>
> It would be simple enough to use the same scheme with plot,
> swaping the axes, but it gets cumbersome if I want to make
> something flexible that works with any value of the direction
> parameter for rotate. So my question is, does anyone have a
> handy way to convert an array index in a rotated array back to
> the pre-rotated index, for all values of the direction parameter.
> I suppose it really boils down to "has anyone done this for me
> already?" :-)
>
> My second question is, is there a handy way to mix rotate
> directions with calls to plot and cursor (or anything else that
> will set up the data coordinates) that will allow me to get the
> position and coordinates back for any point in an array while
> automagically taking the rotate direction parameter into account?

In our medical imaging system we also use direct graphics
calls (TV, etc.), but our images are packaged as objects.
Each data object can have its own coordinate system. This
is not set up by drawing a PLOT command, as you are doing,
but the idea is similar. Before the image is displayed,
the coordinate system is "drawn", meaning the correct data
coordinate space is created in the window that displays the
image. Thus, cursor locations (we use draw widget events)
are automatically reported in the "data" coordinate system.
(We convert from device coordinates to data coordinates
with Convert_Coord.)

To rotate an image in our system would require a call to
a ROTATE method. The code would automatically get the range
values from the associated coordinate object and switch
the range values:

PRO CatImage::Rotate
*self._data = Rotate(*self._data, 1)
self._coords -> GetProperty, XRange=xr, YRange=yr
self._coords -> SetProperty XRange=yr, YRange=xr
self -> Draw
END

Now you would be good to go. Any interaction with the image
in the display window is automatically using the updated
coordinate system.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Help needed on calling an IDL procedure from the Linux command line
Next Topic: Re: Mac Program Support

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

Current Time: Wed Oct 08 17:26:14 PDT 2025

Total time taken to generate the page: 0.00544 seconds