VOXEL_PROJ

The VOXEL_PROJ function generates visualizations of volumetric data by computing 2D projections of a colored, semi-transparent volume. Parallel rays from any given direction are cast through the volume, onto the viewing plane. User-selected colors and opacities can be assigned to arbitrary data ranges, simulating the appearance of the materials contained within the volume.

The VOXEL_PROJ function can be combined with the Z-buffer to render volume data over objects. Cutting planes can also be specified to view selected portions of the volume. Other options include: selectable resolution to allow quick "preview" renderings, and average and maximum projections.

VOXEL_PROJ renders volumes using an algorithm similar to the one described by Drebin, Carpenter, and Hanrahan, in "Volume Rendering", Computer Graphics , Volume 22, Number 4, August 1988, pp. 125-134, but without the surface extraction and enhancement step.

Voxel rendering can be quite time consuming. The time required to render a volume is proportional to the viewing area's size, in pixels, times the thickness of the volume cube in the viewing direction, divided by the product of the user-specified X, Y, and Z steps.

Calling Sequence

Result = VOXEL_PROJ( V [, RGBO] )

Arguments

V

A three-dimensional array containing the volume to be rendered. This array is converted to byte type if necessary.

RGBO

This optional parameter is used to specify the look-up tables that indicate the color and opacity of each voxel value. This argument can be one of the following types:

Keywords

BACKGROUND

A one- or three-element array containing the background color indices. The default is (0,0,0), yielding a black background with most color tables.

CUTTING_PLANE

A floating-point array specifying the coefficients of additional cutting planes. The array has dimensions of (4, N), where N is the number of additional cutting planes from 1 to 6. Cutting planes are constraints in the form of:

C[0] * X + C[1] * Y + C[2] * Z + D > 0

The X, Y, and Z coordinates are specified in voxel coordinates. For example, to specify a cutting plane that excludes all voxels with an X value greater than 10:

CUTTING_PLANE = [-1.0, 0, 0, 10.], for the constraint: -X + 10 > 0.

INTERPOLATE

Set this keyword to use tri-linear interpolation to determine the data value for each step on a ray. Otherwise, the nearest-neighbor method is used. Setting this keyword improves the quality of images produced, especially when the volume has low resolution in relation to the size of the viewing plane, at the cost of more computing time.

MAXIMUM_INTENSITY

Set this keyword to make the value of each pixel in the viewing plane the maximum data value along the corresponding ray. The RGBO argument is ignored if present.

STEP

Set this keyword to a three-element vector, [ Sx , Sy , Sz ], that controls the resolution of the resulting projection. The first two elements contain the step size in the X and Y view plane, in pixels. The third element is the sampling step size in the Z direction, given in voxels. Sx and Sy must be integers equal to or greater than one, while Sz can contain a fractional part. If Sx or Sy are greater than one, the values of intermediate pixels in the output image are linearly interpolated. Higher step sizes require less time because fewer rays are cast, at the expense of lower resolution in the output image.

XSIZE

The width, in pixels, of the output image. If this keyword is omitted, the output image is as wide as the currently-selected output device.

YSIZE

The height, in pixels, of the output image. If this keyword is omitted, the output image is as tall as the currently selected output device.

ZBUFFER

An integer array, with the same width and height as the output image, that contains the depth portion of the Z-buffer. Include this parameter to combine the previously-read contents of a Z-buffer with a voxel rendering. See the third example, below, for details.

ZPIXELS

A byte array, with the same width and height as the output image, that contains the image portion of the Z-buffer. Include this parameter to combine the contents of a Z-buffer with a voxel rendering. See the third example, below, for details.

Examples

In the following example, assume that variable V contains a volume of data, with dimensions Vx by Vy by Vz . The volume contains two materials, muscle tissue represented by a voxel range of 50 to 70, that we want to render with red color, and an opacity of 20; and bone tissue represented by a voxel range of 220-255, that we want to render with white color, and an opacity of 50:

rgbo = BYTARR(256,4) ; Create the opacity vector.

rgbo[50:70, [0,3]] = 20 ; Red and opacity for muscle.

rgbo[220:255, *] = 50 ; White and opacity for bone.

Although it is common to use trapezoidal or Gaussian functions when forming the RGBO arrays, this example uses rectangular functions for simplicity.

SCALE3, XRANGE=[0, Vx-1], YRANGE=[0, Vy-1], ZRANGE=[0, Vz-1]
; Set up the axis scaling and default rotation.

C = VOXEL_PROJ(V, rgbo) ; Compute projected image.

TV, COLOR_QUAN(C, 3, R, G, B) ; Convert from 24-bit to 8-bit image and display.

TVLCT, R, G, B ; Load quantized color tables.

This example required approximately 27 seconds on a typical workstation to compute the view in a 640- by 512-pixel viewing window. Adding the keyword STEP=[2,2,1] in the call to VOXEL_PROJ decreased the computing time to about 8 seconds, at the expense of slightly poorer resolution.

 

When viewing a volume with only one constituent, the RGBO array should contain only an intensity/opacity value pair. To illustrate, if in the above example, only muscle was of interest we create the RGBO argument as follows:

rgbo = BYTARR(256,2) ; Create an empty 256 x 2 array.

rgbo[50:70, *] = 20 ; Intensity and opacity for muscle

SCALE3, XRANGE=[0, Vx-1], YRANGE=[0, Vy-1], ZRANGE=[0, Vz-1]

TV, VOXEL_PROJ(V, rgbo) ; Compute and display the projected image.

C = (FINDGEN(256)/255.) # [255., 0., 0] ; Create color table array for red.

TVLCT, C[*,0], C[*,1], C[*,2] ; Load colors.

The following example demonstrates combining a volume with the contents of the Z-buffer:

SET_PLOT, 'Z' ; Set plotting to Z-buffer.

DEVICE, /Z_BUFFER ; Turn on Z buffering.

SCALE3, XRANGE=[0, Vx-1], YRANGE=[0, Vy-1], ZRANGE=[0, Vz-1]
; Set scaling.

POLYFILL, [0, Vx-1, Vx-1, 0], [0, 0, Vy-1, Vy-1], Vz/2., /T3D
; Draw a polygon at z equal to half the depth

zpix = TVRD() ; Read pixel values from the Z-buffer.

zbuff = TVRD(/WORDS,/CHAN) ; Read depth values from the Z-buffer.

SET_PLOT, 'X' ; Back to display window

C = VOXEL_PROJ(V, rgbo, ZPIX=zpix, ZBUFF=zbuff)
; Compute the voxel projection and use the ZPIXELS and ZBUFFER keywords to combine the volume with the previously-read contents of the Z-buffer.

TV, COLOR_QUAN(C, 3, R, G, B) ; Convert from 24-bit to 8-bit image and display.

TVLCT, R, G, B ; Load the quantized color tables.

See Also

POLYSHADE , PROJECT_VOL , RECON3 , SHADE_VOLUME