Image Processing : Transforming Image Geometry |
Volumetric displays are composed of a series of 2D slices of data which are layered to produce the volume. IDL provides routines that allow you to display a series of the 2D slices in a single image window, display single orthogonal or non-orthogonal slices of volumetric data, or interactively extract slices from a 3D volume. For more information, see the following sections:
The following example displays 57 Magnetic Resonance Imaging (MRI) slices of a human head within a single window as well as a single slice which is perpendicular to the MRI data.
Example Code See displayslices.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
file = FILEPATH('head.dat', SUBDIRECTORY = ['examples', 'data']) image = READ_BINARY(file, DATA_DIMS = [80, 100, 57])
LOADCT, 5 DEVICE, DECOMPOSED = 0, RETAIN = 2
WINDOW, 0, XSIZE = 800, YSIZE = 600
i
also functions to control the positioning which, by default, uses the upper left corner as the starting point. Use 255b -
array to display the images using the inverse of the selected color table and the ORDER
keyword to draw each image from the top down instead of the bottom up.FOR i = 0, 56,1 DO TVSCL, 255b - image [*,*,i], /ORDER, i
sliceImg = REFORM(image[40,*,*])
This results in a 100 by 57 array.
sliceImg = CONGRID(sliceImg, 100, 100)
TVSCL, 255b - sliceImg, 47
Since the image size is now 100 x 100 pixels, the 47th position in the 800 by 600 window is the final position.
Your output should be similar to the following figure.
|
Note This method of extracting slices of data is limited to orthogonal slices only. You can extract single orthogonal and non-orthogonal slices of volumetric data using EXTRACT_SLICE, described in the following section. See Extracting a Slice of Volumetric Data below for more information. |
The EXTRACT_SLICE function extracts a single two-dimensional planar slice of data from a three-dimensional volume. By setting arguments that specify the orientation of the slice and a point in its center using the following syntax, you can precisely control the orientation of the slicing plane.
Result = EXTRACT_SLICE( Vol, Xsize, Ysize, Xcenter, Ycenter, Zcenter, Xrot, Yrot, Zrot [, ANISOTROPY=[xspacing, yspacing, zspacing]] [, OUT_VAL=value] [, /RADIANS] [, /SAMPLE] [, VERTICES=variable] )
The following example demonstrates how to use EXTRACT_SLICE to extract the same singular slice as that shown in the previous example.
Example Code See extractslice.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
file = FILEPATH('head.dat', SUBDIRECTORY = ['examples', 'data']) volume = READ_BINARY(file, DATA_DIMS =[80, 100, 57])
DEVICE, DECOMPOSED = 0, RETAIN = 2 LOADCT, 0
sliceImg = EXTRACT_SLICE $ (volume, 110, 110, 40, 50, 28, 90.0, 90.0, 0.0, OUT_VAL=0)
Note The code within the previous parentheses specifies: the volume (Data), a size greater than the Xsize and Ysize of the volume ( 110,110 ), the Xcenter, Ycenter and Zcenter (40, 50, 28 ) denoting the x, y, and z index points through which the slice will pass, the degree of x, y, and z rotation of the slicing plane (90.0, 90.0, 0.0 ) and the OUT_VAL = 0 indicating that elements of the output array which fall outside the original values will be given the value of 0 or black. |
bigImg = CONGRID (sliceImg, 400, 650, /INTERP)
WINDOW, 0, XSIZE = 400, YSIZE = 650 TVSCL, bigImg
The image created by this example should appear similar to the following figure.
|
The series of two-dimensional images created by the magnetic resonance imaging scan, shown in the section, Displaying a Series of Planar Slices, can also be visualized as a three-dimensional volume using either of IDL's interactive volume visualization tools, SLICER3 or XVOLUME.
SLICER3 quickly creates visualizations of 3D data using IDL Direct Graphics. The XVOLUME procedure employs IDL Object Graphics to create highly interactive visualizations that take advantage of OpenGL hardware acceleration and multiple processors for volume rendering. Since Object Graphics are rendered in memory and not simply drawn, both the time and amount of virtual memory required to create a XVOLUME visualization exceed those needed to create a Direct Graphics, SLICER3 visualization.
Tip For more information and examples of displaying volumes and slicing volumetric data using XVOLUME, see XVOLUME. |
The Direct Graphics SLICER3 widget-based application allows you to view single or multiple slices of a volume or to create an isosurface of the three-dimensional data. Complete the following steps to load the head.dat
volume into the SLICER3 application.
Example Code See displayslicer3.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
file = FILEPATH('head.dat', $ SUBDIRECTORY=['examples', 'data']) volume = READ_BINARY(file, DATA_DIMS = [80, 100, 57])
head.dat
file as a volume in SLICER3, create a pointer called pdata
which passes the data
array information to the SLICER3 application.pData = PTR_NEW(volume)
Note You can load multiple arrays into the SLICER3 application by creating a pointer for each array. Each array must have the same dimensions. |
SLICER3, pData, DATA_NAMES ='head'
At first it is not apparent that your data has been passed to the SLICER3 application. See the following section, Manipulating Volumetric Data Using SLICER3 for details on how to use this interface.
Once you have loaded a three-dimensional array into the SLICER3 application, the interface offers numerous ways to visualize the data. The following steps cover creating an isosurface, viewing a slice of data within the volume and rotating the display.
Note To undo an action resulting in an unwanted image in the SLICER3 window, you can either choose Tools Delete and select the last item on the list to undo the last action or choose Tools Erase to erase the entire image. |
|
The following figure displays the final image.
To save the image currently in the display window, select File Save Save TIFF Image. For more information about using the SLICER3 interface to manipulate volumetric data, see SLICER3 in the IDL Reference Guide.
Note Enter the following line after closing the SLICER3 application to release memory used by the pointer: PTR_FREE, pData |
IDL Online Help (March 06, 2007)