Previous Image Processing : Transforming Image Geometry Next

Planar Slicing of Volumetric Data

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:

Displaying a Series of Planar Slices

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.

  1. Select the file and read in the data, specifying known data dimensions:
  2. file = FILEPATH('head.dat', SUBDIRECTORY = ['examples', 
    'data'])  
    image = READ_BINARY(file, DATA_DIMS = [80, 100, 57])  
    

     

  3. Load a color table to more easily distinguish between data values and prepare the display device:
  4. LOADCT, 5  
    DEVICE, DECOMPOSED = 0, RETAIN = 2  
    

     

  5. Create the display window. When displaying all 57 slices of the array in a single window, the image size (80 by 100) and the number of slices (57) determine the window size. In this case, 10 columns and 6 rows will contain all 57 slices of the volumetric data.
  6. WINDOW, 0, XSIZE = 800, YSIZE = 600  
    

     

  7. Use the variable i in the following FOR statement to incrementally display each image in the array. The 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.
  8. FOR i = 0, 56,1 DO TVSCL, 255b - image [*,*,i], /ORDER, i  
    

     

  9. To extract a central slice from the y, z plane, which is perpendicular to the x, y plane of the MRI scans, specify 40 for the x-dimension value. Use REFORM to decrease the number of array dimensions so that TV can display the image:
  10. sliceImg = REFORM(image[40,*,*])  
    

     

    This results in a 100 by 57 array.

     

  11. Use CONGRID to compensate for the sampling rate of the scan slices:
  12. sliceImg = CONGRID(sliceImg, 100, 100)  
    

     

  13. Display the slice in the 47th window position:
  14. 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.

 

Figure 2-12: Planar Slices of a MRI Scan of a Human Head

Figure 2-12: Planar Slices of a MRI Scan of a Human Head


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.

Extracting a Slice of Volumetric Data

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.

  1. Select the file and read in the data, specifying known data dimensions:
  2. file = FILEPATH('head.dat', SUBDIRECTORY = ['examples', 
    'data'])  
    volume = READ_BINARY(file, DATA_DIMS =[80, 100, 57])  
    

     

  3. Prepare the display device and load the grayscale color table.
  4. DEVICE, DECOMPOSED = 0, RETAIN = 2  
    LOADCT, 0  
    

     

  5. Enter the following line to extract a sagittal planar slice from the MRI volume of the head.
  6. 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.

     

  7. Use CONGRID to resize the output array to an easily viewable size. This is also used to compensate for the sampling rate of the scan images.
  8. bigImg = CONGRID (sliceImg, 400, 650, /INTERP)  
    

     

  9. Prepare a display window based on the resized array and display the image.
  10. WINDOW, 0, XSIZE = 400, YSIZE = 650  
    TVSCL, bigImg  
    

The image created by this example should appear similar to the following figure.

 

Figure 2-13: Example of Extracting a Slice of Data From a Volume

Figure 2-13: Example of Extracting a Slice of Data From a Volume

Interactive Planar Slicing of Volumetric Data

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.

Displaying Volumetric Data Using SLICER3

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.

  1. Select the data file and read in the data using known dimensions:
  2. file = FILEPATH('head.dat', $  
       SUBDIRECTORY=['examples', 'data'])  
    volume = READ_BINARY(file, DATA_DIMS = [80, 100, 57])  
    

     

  3. To display all slices of the head.dat file as a volume in SLICER3, create a pointer called pdata which passes the data array information to the SLICER3 application.
  4. 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.

  1. Load the data into the SLICER3 application. The DATA_NAMES designates the data set in the application's Data list. This field will be greyed out if only one volumetric array has been loaded.
  2. 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.

Manipulating Volumetric Data Using SLICER3

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.

  1. In the SLICER3 application, select Surface from the Mode: list. Left-click in the Surface Threshold window containing the logarithmic histogram plot of the data and drag the green line to change the threshold value of the display. A value in the low to mid 40's works well for this image. Click Display to view the isosurface of the data.
  2.  

    Figure 2-14: An Isosurface of Volumetric Data

    Figure 2-14: An Isosurface of Volumetric Data

     


    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.

     

  3. Select Slice from the Mode list. Select the Expose, Orthogonal, and X options. Left-click in the image window and drag the mouse halfway along the X axis and then release the mouse button. The planar slice of volumetric data appears at the point where you release the mouse button.

 

Figure 2-15: Visualizing a Slice of Volumetric Data

Figure 2-15: Visualizing a Slice of Volumetric Data
  1. Change the colors used to display the slice by selecting Tools Colors Slice/Block. In the color table widget, select STD Gamma-II from the list and click Done to load the new color table.
  2.  

  3. Change the view of the display by selecting View from the Mode list. Here you can change the rotation and zoom factors of the displayed image. Use the slider bars to rotate the orientation cube. A preview of the cube's orientation appears in the small window above the controls. To create the orientation shown in the following figure, move the slider to a rotation of -18 for Z and -80 for X. Click Display to change the orientation of the image in the window.

The following figure displays the final image.

 

Figure 2-16: A Slice Overlaying an Isosurface

Figure 2-16: A Slice Overlaying an Isosurface

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)