The VOXEL_PROJ function generates visualizations of volumetric data by computing 2-D 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 rendering can be quite time consuming. The time required to render a volume is proportional to the viewing areas 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.

Note: It is necessary to use SCALE3 to initialize a display before calling VOXEL_PROJ as shown in the Examples section.

Syntax


Result = VOXEL_PROJ( V [, RGBO] [, BACKGROUND=array] [, CUTTING_PLANE=array] [, /INTERPOLATE] [, /MAXIMUM_INTENSITY] [, STEP=[Sx, Sy, Sz]] [, XSIZE=pixels] [, YSIZE=pixels] [, ZBUFFER=int_array] [, ZPIXELS=byte_array] )

Return Value


Returns the specified voxel projection results.

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:

  • A (256, 4) byte array for TrueColor rendering. This array represents 256 sets of red, green, blue, and opacity (RGBO) components for each voxel value, scaled into the range of bytes (0 to 255). The R, G, and B components should already be scaled by the opacity. For example, if a voxel value of 100 contains a material that is red, and 35% opaque, the RGBO values should be, respectively: [89, 0, 0, 89] because 255 * 0.35 = 89. If more than one material is present, the RGBO arrays contain the sum of the individual RGBO arrays. The content and shape of the RGBO curves is highly dependent upon the volume data and experimentation is often required to obtain the best display.
  • A (256, 2) byte array for volumes with only one material or monochrome rendering. This array represents 256 sets of pixel values and their corresponding opacities for each voxel value.
  • If this argument is omitted, the average projection method, or maximum intensity method (if the MAXIMUM_INTENSITY keyword is set) is used.

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 second 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 second example, below, for details.

Examples


The following examples use a volume data set depicting a human head. Execute the following statements to load the data and set appropriate parameters before executing the examples below:

; Read some volume data
file = FILEPATH('head.dat', SUBDIRECTORY = ['examples', 'data'])
V = READ_BINARY(file, DATA_DIMS = [80, 100, 57])
Vx=80 & Vy=100 & Vz=57
; Get device parameters
DEVICE, GET_DECOMPOSED=old_decomposed
old_device=!D.name
resolution=[!D.x_size, !D.y_size]
; Set up the axis scaling and default rotation:
SCALE3, XRANGE=[0, Vx-1], YRANGE=[0, Vy-1], ZRANGE=[0, Vz-1]

Example 1

In the following example, assume that variable V contains a volume of data, with dimensions Vx by Vy by Vz. (These variables are created by the code above.) 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 190-232, which we want to render with white color, and an opacity of 50:

; Use a color table
DEVICE, DECOMPOSED=0
; Create the opacity vector:
rgbo = BYTARR(256,4)
; Red and opacity for muscle:
rgbo[50:70, [0,3]] = 20
; White and opacity for bone:
rgbo[190:232, *] = 50
; Compute projected image:
img = VOXEL_PROJ(V, rgbo)
; Convert from 24-bit to 8-bit image and display:
img = COLOR_QUAN(img, 3, R, G, B)
; Load quantized color tables:
TVLCT, R, G, B
; Display the image
TV, img
; Restore device settings
DEVICE, DECOMPOSED=old_decomposed

Example 2

This example demonstrates combining a volume with the contents of the Z-buffer.

Note: You must execute Example 1 before executing this example.

; Use a color table
DEVICE, DECOMPOSED=0
; Set plotting to Z-buffer and set resolution
SET_PLOT, 'Z'
DEVICE, SET_RESOLUTION=resolution
; Draw a polygon at z equal to half the depth:
POLYFILL, [0, Vx-1, Vx-1, 0], [0, 0, Vy-1, Vy-1], Vz/2., /T3D
; Read pixel values from the Z-buffer:
zpix = TVRD()
; Read depth values from the Z-buffer:
zbuff = TVRD(CHANNEL=1)
; Restore plotting to original device:
SET_PLOT, old_device
; Compute the voxel projection and use the ZPIXELS and ZBUFFER
; keywords to combine the volume with the previously-read contents
; of the Z-buffer:
img = VOXEL_PROJ(V, rgbo, ZPIXELS=zpix, ZBUFFER=zbuff)
; Convert from 24-bit to 8-bit image.
img = COLOR_QUAN(img, 3, R, G, B)
; Load the quantized color tables:
TVLCT, R, G, B
; Display the image
TV, img
; Restore device settings
DEVICE, DECOMPOSED=old_decomposed

Example 3

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

Note: You must execute Example 1 before executing this example.

; Use a color table
DEVICE, DECOMPOSED=0
; Create an empty 256 x 2 array:
rgbo2 = BYTARR(256,2)
; Intensity and opacity for muscle:
rgbo2[50:70, *] = 20
; Compute and display the projected image:
img = VOXEL_PROJ(V, rgbo2)
; Create color table array for red:
RGB = (FINDGEN(256)/255.) # [255., 0., 0]
; Load colors:
TVLCT, RGB[*,0], RGB[*,1], RGB[*,2]
; Display the image
TV, img
; Restore device settings
DEVICE, DECOMPOSED=old_decomposed

Version History


Pre-4.0

Introduced

Resources and References


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.

See Also


POLYSHADE Procedure, PROJECT_VOL Procedure, RECON3, SHADE_VOLUME Procedure