|
Getting Started with IDL: Volume Visualization |
|
Visualizing volume data at the IDL command line is as easy as reading in data and then calling the correct command to visualize. The following sections will guide you through the process of reading and visualizing volume data via the command line.
The following steps illustrate the use of BINARY_TEMPLATE and READ_BINARY to read in a dataset:
MYTEMPLATE=BINARY_TEMPLATE(FILEPATH('head.dat',$
SUBDIR=['examples', 'data']))
The binary template dialog box appears.
At the "Number of Dimensions" pull-down menu, be sure to specify that we are dealing with a three-dimensional data set. These data are contained in an 80 by 100 by 57 array, so we will enter these values in the three boxes marked "size".
Finally, let the binary template dialog know that we are dealing with Byte type data by specifying "Byte (Unsigned 8-bits) at the "Type" pull-down menu.
Once you have entered the above data, the binary template dialog appears once again showing the specifications you have made.
Now we will use the READ_BINARY procedure to read the data defined by template we have just created.
HEAD_BINARY=READ_BINARY(FILEPATH('head.dat',
$ SUBDIR=['examples','data']),TEMPLATE=MYTEMPLATE)
When creating "3-D" plots at the IDL command line (for example, surfaces, shaded surfaces, and volume visualizations), a three-dimensional transformation needs to be set up. The 3-D transformation applies the requested translation, rotation, and scaling to a 3-D plot before displaying it.
Three-dimensional transformations are especially important when using the POLYSHADE routine. Unless the transformation is set up such that the entire volume is visible, the volume will not be rendered correctly. Once a 3-D transformation has been established, most IDL plotting routines can be made to use it by including the T3D keyword.
There are a number of ways to set up a transformation matrix in IDL.
One way is that a transformation matrix can be entered explicitly into the system variable !P.T. This method is rather difficult, because you have to figure out the transformation yourself. More information about the transformation matrix can be found in Coordinate Conversions.
Another method, is the SURFACE and SHADE_SURF commands, which automatically create a 3-D transformation based on the datasets being visualized.
SLICE=(HEAD_BINARY.B)[*,*,25]
A number of different IDL procedures that simplify the creation of 3-D transformations can be used. Keyword arguments to some of these procedures allow you to set viewing angles and data ranges. The procedures then create the appropriate transformation matrix for you and store it in !P.T. These procedures include T3D, SCALE3, SCALE3D, and SURFR.
Two IDL commands, SHADE_VOLUME and POLYSHADE, are used together to visualize an iso-surface. SHADE_VOLUME generates a list of polygons that define a 3-D surface given a volume dataset and a contour (or density) level. The function POLYSHADE can then be used to create a shaded-surface representation of the iso-surface from those polygons.
Like many other IDL commands, POLYSHADE accepts the T3D keyword that makes POLYSHADE use a user-defined 3D transformation. Before you can use POLYSHADE to render the final image, you need to set up an appropriate three-dimensional transformation. The XRANGE, YRANGE, and ZRANGE keywords accept 2-element vectors, representing the minimum and maximum axis values, as arguments. POLYSHADE returns an image based upon the list of vertices, V, and list of polygons, P. The T3D keyword tells POLYSHADE to use the previously-defined 3D transformation. The TV procedure displays the shaded-surface image.
Enter the following lines:
SHADE_VOLUME,HEAD_BINARY.B,70,V,P,/LOW
SCALE3,XRANGE=[0,80],YRANGE=[0,100],ZRANGE=[0,57]
IDL Online Help (March 06, 2007)