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 volumetric data

Description

Display volumetric data, creating a volshow object with properties that control the appearance of the display.

Creation

Syntax

volshow(V)
volshow(V,Name,Value)
h = volshow(___)

Description

example

volshow(V) displays 3-D grayscale volume V in a figure. You can rotate and zoom in and out on the display interactively using the mouse.

volshow(V,Name,Value) displays the volume, using one or more name-value pairs to set properties that control the visualization of the volume. For a list of name-value pairs, see Properties. Enclose each property in quotes. For example, 'BackgroundColor'.

h = volshow(___) returns a volshow object with properties that can be used to control visualization of the volume.

Input Arguments

expand all

Volumetric data, specified as a 3-D grayscale volume.

Properties

expand all

Transparency map for the volume content, specified as a 256-by-1 numeric array, with values in the range [0 1].

Color of the background, specified as a MATLAB® ColorSpec. The intensities must be in the range [0,1].

Location of camera, or the viewpoint, specified as a three-element vector of the form [x y z]. This vector defines the axes coordinates of the camera location, which is the point from which you view the axes. The camera is oriented along the view axis, which is a straight line that connects the camera position and the camera target. Changing the CameraPosition property changes the point from which you view the volume. For an illustration, see Camera Graphics Terminology (MATLAB). Interactively rotating the volume modifies the value of this property.

Vector defining upwards direction, specified as a three-element direction vector of the form [x y z]. By default, volshow defines the z-axis as the up direction ([0 0 1]). For an illustration, see Camera Graphics Terminology (MATLAB). Interactively rotating the volume modifies the value of this property.

Field of view, specified as a scalar angle greater than or equal to 0 and less than 180. The greater the angle, the larger the field of view. Also, the bigger the angle, objects appear smaller in the scene. For an illustration, see Camera Graphics Terminology (MATLAB).

Point used as camera target, specified as a three-element 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. For an illustration, see Camera Graphics Terminology (MATLAB).

Colormap of the volume content, specified as a 256-by-3 numeric array with values in the range [0 1].

Interactivity of the volume, 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 are performed about the value specified by CameraTarget. When false, you cannot interact with the volume.

Isosurface color, specified as a MATLAB ColorSpec, with values in the range [0 1]. This property specifies the volume color when the Renderer is set to 'Isosurface'.

Value that defines the surface of the volume drawn when Renderer is set to 'Isosurface', specified as a numeric array. Value must be in the range [0 1].

Parent of volshow object, specified as a handle to a uipanel or figure. If you do not specify a parent, the parent of the volshow object is gcf.

Rendering style, specified as one of the values in this table. When the volume is logical, the default Renderer is 'Isosurface', otherwise the default Renderer is 'VolumeRendering'.

ValueDescription
'VolumeRendering'View the volume based on the specified color and transparency for each voxel.
'MaximumIntensityProjection'View the voxel with the highest intensity value for each ray projected through the data.
'Isosurface'View an isosurface of the volume specified by the value in Isovalue.

Scale factors used to rescale volume, specified as a 1-by-3 positive numeric array. The values in the array correspond to the scale factor applied in the x, y, and z direction.

Object Functions

setVolumeSet new volume

Examples

collapse all

Load and view the volume.

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

Specify the name of the GIF file.

filename = 'animatedSpiral.gif';

Create an array of camera positions around the unit circle.

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

Loop through and create an image at each camera position.

for idx = 1:120
    % Update current view.
    h.CameraPosition = myPosition(idx,:);
    % Use getframe to capture image.
    I = getframe(gcf);
    [indI,cm] = rgb2ind(I.cdata,256);
    % Write frame to the GIF File.
    if idx == 1
        imwrite(indI, cm, filename, 'gif', 'Loopcount', inf, 'DelayTime', 0.05);
    else
        imwrite(indI, cm, filename, 'gif', 'WriteMode', 'append', 'DelayTime', 0.05);
    end
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);

Load data.

load mri
V = squeeze(D);

Generate a colormap and an alphamap that are ideal for visualizing 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 volume with custom Colormap and Alphamap

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

Introduced in R2019a