This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

volshow

Display volume

Syntax

vol = volshow(V)
vol = volshow(V,Name,Value)

Description

vol = volshow(V) displays the 3-D grayscale volume V and returns a volshow object, vol. Use vol to modify the display settings after the volume is displayed. You can also rotate and zoom the display interactively by using the mouse.

example

vol = volshow(V,Name,Value) adjusts the initial display settings using name-value pairs.

Examples

collapse all

Load a volume into the workspace and view it using volshow.

load('spiralVol.mat');
h = volshow(spiralVol);

Create an array of camera positions around the unit circle.

vec = linspace(0,2*pi(),120)';
myPosition = [cos(vec) sin(vec) ones(size(vec))];

Update the display at each camera position.

framerate = 24;
for idx = 1:120
    h.CameraPosition = myPosition(idx,:);
    pause(1/framerate)
end

Load MRI data and remove the singleton dimension.

load mri
V = squeeze(D);

Generate a color map and transparency (alpha) map suited for MRI images.

intensity = [0 20 40 120 220 1024];
alpha = [0 0 0.15 0.3 0.38 0.5];
color = ([0 0 0; 43 0 0; 103 37 20; 199 155 97; 216 213 201; 255 255 255]) ./ 255;
queryPoints = linspace(min(intensity),max(intensity),256);
alphamap = interp1(intensity,alpha,queryPoints)';
colormap = interp1(intensity,color,queryPoints);

View the volume with the custom color map and transparency map. Click and drag the mouse to rotate the volume. Use the scroll wheel to zoom in and out of the volume.

vol = volshow(V,'Colormap',colormap,'Alphamap',alphamap);

This example uses 3-D volumetric human chest CT scan data. To run this example, you must download the sample data using the Add-Ons Explorer. Select Get Add-ons from the Add-ons drop-down menu from the MATLAB® desktop. The support file is in the MathWorks Features section. You must have write privileges for the installation folder.

Load the data into the MATLAB workspace.

load chestVolume

Generate a color map and transparency (alpha) map suited for CT images.

intensity = [-3024,-16.45,641.38,3071];
alpha = [0, 0, 0.72, 0.72];
color = ([0 0 0; 186 65 77; 231 208 141; 255 255 255]) ./ 255;
queryPoints = linspace(min(intensity),max(intensity),256);
alphamap = interp1(intensity,alpha,queryPoints)';
colormap = interp1(intensity,color,queryPoints);

View the volume with the custom color map and transparency map. Click and drag the mouse to rotate the volume. Use the scroll wheel to zoom in and out of the volume.

vol = volshow(V1,'Colormap',colormap,'Alphamap',alphamap);

Programatically change the camera position to see a different view of the volume.

vol.CameraPosition = [-1.0533 -0.0093, 0.1593];

Input Arguments

collapse all

3-D grayscale image, specified as an m-by-n-by-p numeric array.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: vol = volshow(V,'Colormap',cmap,'Alphamap',amap);

Parent container in which to plot, specified as a handle to a figure or panel object. If you do not specify a parent, then volshow uses the handle to the current figure, gcf. If a figure does not exist, then volshow creates a new figure.

Colormap of the volume content, specified as a 256-by-3 numeric array, with values in the range [0 1]. The default colormap is gray(256).

Data Types: double

Transparency map for the volume content, specified as a 256-by-1 numeric vector with values in the range [0 1]. The default value of Alphamap is linspace(0,1,256)'.

Data Types: double

Background color, specified as a MATLAB® ColorSpec.

Data Types: single | double

Camera viewpoint, specified as a 3-element numeric vector of the form [x y z]. Changing the CameraPosition property changes the point from which you view the volume. The camera is oriented along the view axis, which is a straight line that connects the camera position and the camera target. This property updates when you interactively rotate the volume.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Vector defining upwards direction, specified as a 3-element numeric vector of the form [x y z]. This property updates when you interactively rotate the volume.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Point used as camera target, specified as a 3-element numeric vector of the form [x y z]. The camera is oriented along the view axis, which is a straight line that connects the camera position and the camera target.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Rendering style, specified as one of the following values.

ValueDescription
'Isosurface'

View an isosurface of the volume specified by the value in Isovalue.

'MaximumIntensityProjection'

View the voxel with the highest intensity value for each ray projected through the data.

'VolumeRendering'

View the volume based on the specified color and transparency for each voxel.

If volume V is a numeric data type, then the default rendering style is 'VolumeRendering'. If V is logical, then the default rendering style is 'Isosurface'.

Isosurface color, specified as a MATLAB ColorSpec. This property specifies the volume color when Renderer is set to 'Isosurface'.

Isovalue, specified as a numeric scalar in the range [0 1]. The isovalue specifies which surface of the volume to draw when Renderer is set to 'Isosurface'.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Display is interactive, specified as true or false. When true (default), you can zoom using the mouse scroll wheel, and rotate by clicking and dragging on the volume. Rotation and zoom is performed about the value specified by CameraTarget. When false, you cannot interact with the volume.

Scale factors used to rescale the volume in the x, y, and z directions, specified as a 1-by-3 vector of positive numbers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Tips

  • The volshow function creates a panel object in the specified parent figure. Panels are containers that group UI components together. The volumetric data is displayed in the panel.

Introduced in R2018b