Re: Translating IDL Co ordinates [message #12237] |
Mon, 27 July 1998 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Peter Hunter wrote:
>
> Please Help.
> Using IDL's Extract Slice function, I can extract a 2d slice from a 3d
> dataset.
>
> On this 2d slice I want to select a point( in 2d co ordinates) and then
> translate this
> co ordinate back into 3d co ordinates, in the 3d dataset.
>
> Can anyone help me with this ?
>
> Peter Hunter
Peter -
First, you may want to download my RESLICE.PRO function, which
accounts for anisotropic voxels and allows you to produce a realistic
slice from your 3D dataset. You can get this via anonymous ftp from:
bial8.ucsd.edu pub/software/idl/share/idl_share.tar.gz
There are a lot of other routines thay may be useful, but in any
event you can extract RESLICE.PRO from this. Check the README file
for a short description of the routines available. Also extract
RESLICE.DOC for the documentation.
As for your task of converting from screen coordinates to volume
coordinates, I will email you a file called SCRN_UTILS.PRO that
contains the following routines that may be useful:
; FUNCTIONS AND PROCEDURES
;
; function get_voxel_dir_scale
; function compute_disp_image_dim
; function get_img_draw_limit
; function check_3d_pt
; function screen_to_3d_pt
; function three_d_to_screen
; function get_display_image
These routines were written by someone else and now are maintained
by me; the code is a bit strange but it works! Here is a snippet of
code from one of my programs that use several of these routines.
The user has picked a point from a Coronal brain slice within a 3D
volume; this point (x,y,z) is then converted from screen coors to
volume coors (in mm), and these are then converted back to screen
coors but in the Axial and Sagittal plane (we have computed orthogonal
images and now want to show the point in these other planes).
============================================================ ======
; Now compute orthogonal views and display. Use SCREEN_TO_3D_PT(),
; THREE_D_TO_SCREEN() and GET_DISPLAY_IMAGE() from SCRN_UTILS.PRO
written
; by Jim Sewell. Also use DRAW_POINT_COLOR() from his DRAW_UTILS.PRO .
;
; Note that !ORDER has to be set to 0 before display of image returned
; from GET_DISPLAY_IMAGE(), as his routine maintains correct
orientation
; independent of the setting of !ORDER.
views = ['Y-Z', 'Z-X'] ; Sagittal, Axial views
scale = 512.0 / d.dim ; Scale factor for window relative to
image
depth = 0.00 ; Depth in slice
; Get coordinates in 3D coordinates, with units of mm.
; Use structure for appropriate volume.
coords_struct = screen_to_3d_pt(winx, winy, depth, 'X-Y', $
winz, scale, volume_info, 0)
; Now get new coordinates of this point from different view
screen_struct = three_d_to_screen(coords_struct.x_coord, $
coords_struct.y_coord, coords_struct.z_coord, $
views(i), scale, volume_info, 0)
============================================================ ======
I will also mail you a routine that creates a volume information
structure that is required by these routines. Hopefully these
will at least be useful in getting you started. Let me know if
you have any questions.
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|