Routines (alphabetical) > Routines: P > PROJECT_VOL Procedure

# PROJECT_VOL Procedure

The PROJECT_VOL function returns a two-dimensional image that is the projection of a 3-D volume of data onto a plane (similar to an X-ray). The returned image is a translucent rendering of the volume (the highest data values within the volume show up as the brightest regions in the returned image). Depth queuing and opacity may be used to affect the image. The volume is projected using a 4x4 matrix, so any type of projection may be used including perspective. Typically the system viewing matrix (!P.T) is used as the 4x4 matrix.

Note: The VOXEL_PROJ procedure performs many of the same functions as this routine, and is faster.

This routine is written in the IDL language. Its source code can be found in the file `project_vol.pro` in the `lib` subdirectory of the IDL distribution.

## Examples

Use the T3D routine to set up a viewing projection and render a volume of data using PROJECT_VOL.

; First, create some data:
vol = RANDOMU(S, 40, 40, 40)
FOR I=0, 10 DO vol = SMOOTH(vol, 3)
vol = BYTSCL(vol(3:37, 3:37, 3:37))
opaque = RANDOMU(S, 40, 40, 40)
FOR I=0, 10 DO opaque = SMOOTH(opaque, 3)
opaque = BYTSCL(opaque(3:37, 3:37, 3:37), TOP=25B)
; Set up the view:
xmin = 0 & ymin = 0 & zmin = 0
xmax = 34 & ymax = 34 & zmax = 34
!X.S = [-xmin, 1.0] / (xmax - xmin)
!Y.S = [-ymin, 1.0] / (ymax - ymin)
!Z.S = [-zmin, 1.0] / (zmax - zmin)
T3D, /RESET
T3D, TRANSLATE=[-0.5, -0.5, -0.5]
T3D, SCALE=[0.7, 0.7, 0.7]
T3D, ROTATE=[30, -30, 60]
T3D, TRANSLATE=[0.5, 0.5, 0.5]
WINDOW, 0, XSIZE=512, YSIZE=512
; Generate and display the image:
img = PROJECT_VOL(vol, 64, 64, 64, DEPTH_Q=0.7, $
OPAQUE=opaque, TRANS=(!P.T))
TVSCL, img

## Syntax

Result = PROJECT_VOL( Vol, X_Sample, Y_Sample, Z_Sample [, /AVG_INTENSITY] [, /CUBIC] [, DEPTH_Q=value] [, OPAQUE=3D_array] [, TRANS=array] [, XSIZE=longword integer] [, YSIZE=longword integer] [, /Z_BUFFER] )

## Return Value

Returns a projection of the volumetric data.

## Arguments

### Vol

A 3-D array of any type except string or structure containing the three-dimensional volume of data to project.

### X_Sample

A long integer specifying the number of rays to project along the X dimension of the image. The returned image will have the dimensions X_sample by Y_sample.

### Y_Sample

A long integer specifying the number of rays to project along the Y dimension of the image. To preserve the correct aspect ratio of the data, Y_sample should equal X_sample.

### Z_Sample

A long integer specifying the number of samples to take along each ray. Higher values for X_sample, Y_sample, and Z_sample increase the image resolution as well as execution time.

## Keywords

### AVG_INTENSITY

If this keyword is set, the average intensity method of projection is used. The default is a maximum intensity projection. This keyword is ignored if the Z_BUFFER keyword is set.

### CUBIC

If this keyword is set, the cubic method of interpolation is used. The default is bilinear interpolation.

### DEPTH_Q

Set this keyword to indicate that the image should be created using depth queuing. The depth queuing should be a single floating-point value between 0.0 and 1.0. This value specifies the brightness of the farthest regions of the volume relative to the closest regions of the volume. A value of 0.0 will cause the back side of the volume to be completely blacked out, while a value of 1.0 indicates that the back side will show up just as bright as the front side. The default is 1.0 (indicating no depth queuing).

### OPAQUE

A 3-D array of any type except string or structure, with the same size and dimensions as Vol. This array specifies the opacity of each cell in the volume. OPAQUE values of 0 allow all light to pass through. OPAQUE values are cumulative. For example, if a ray emanates from a data value of 50, and then passes through 10 opaque cells (each with a data value of 0 and an opacity value of 5) then that ray would be completely blocked out (the cell with the data value of 50 would be invisible on the returned image). The default is no opacity.

### TRANS

A 4x4 floating-point array to use as the transformation matrix when projecting the volume. The default is to use the system viewing matrix (!P.T).

### XSIZE

The x size of the returned image to return. CONGRID is used to resize the final image to be XSIZE by YSIZE. The default is the x size of the current window (or the x size of the Z-buffer). If no current window exists, then the default is X_sample.

### YSIZE

The y size of the returned image. CONGRID is used to resize the final image to be XSIZE by YSIZE. The default is the y size of the current window (or the y size of the Z-buffer). If no current window exists, then the default is Y_sample.

### Z_BUFFER

If this keyword is set, the projection is combined with the contents of the Z-buffer. The default is to not use the Z-buffer contents.

## Version History

Pre-4.0 | Introduced

## See Also

POLYSHADE Procedure, VOXEL_PROJ