volshow
Display volume
Description
A volshow
object displays volume and enables you to modify the
appearance of the display.
Creation
Description
volshow(
displays 3-D grayscale volume
V
)V
in a figure. You can rotate and zoom in and out on the display
interactively using the mouse.
volshow(
displays the 3-D grayscale volume V
,config
)V
. config
is a
struct exported from the Volume Viewer app. The
config
struct controls visualization of the volume, containing
values for volshow
object properties.
volshow(
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
name in quotes.V
,Name,Value
)
Example: volshow(V,'BackgroundColor','w')
displays 3-D grayscale
volume V
in a figure with a white background color.
returns a
vs
= volshow(___)volshow
object with properties that can be used to control
visualization of the volume.
Input Arguments
V
— 3-D grayscale volume
numeric array
3-D grayscale volume, specified as a numeric array.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| logical
config
— Rendering information exported by Volume Viewer
struct
Rendering information exported by Volume Viewer, specified as a
struct
.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| logical
Properties
Alphamap
— Transparency map for volume content
256-by-1 numeric vector
Transparency map for the volume content, specified as a 256-by-1 numeric array, with
values in the range [0, 1]. The default transparency map is the vector
linspace(0,1,256)'
.
BackgroundColor
— Background color
[0.3 0.75 0.93]
(default) | RGB triplet | color name | short color name
Background color, specified as an RGB triplet, a color name, or a short color name.
You can specify any color using an RGB triplet. An RGB triplet is a 3-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1].
You can specify some common colors by name as a string scalar or character vector. This table lists the named color options and the equivalent RGB triplets.
Color Name | Short Name | RGB Triplet | Appearance |
---|---|---|---|
'red' | 'r' | [1 0 0] |
|
'green' | 'g' | [0 1 0] |
|
'blue' | 'b' | [0 0 1] |
|
'cyan'
| 'c' | [0 1 1] |
|
'magenta' | 'm' | [1 0 1] |
|
'yellow' | 'y' | [1 1 0] |
|
'black' | 'k' | [0 0 0] |
|
'white' | 'w' | [1 1 1] |
|
Here are the RGB triplets for the default colors that MATLAB® uses in many types of plots.
RGB Triplet | Appearance |
---|---|
[0 0.4470 0.7410] |
|
[0.8500 0.3250 0.0980] |
|
[0.9290 0.6940 0.1250] |
|
[0.4940 0.1840 0.5560] |
|
[0.4660 0.6740 0.1880] |
|
[0.3010 0.7450 0.9330] |
|
[0.6350 0.0780 0.1840] |
|
Example: 'BackgroundColor','r'
Example: 'BackgroundColor','green'
Example: 'BackgroundColor',[0 0.4470 0.7410]
CameraPosition
— Location of camera
[4 4 2.5]
(default) | 3-element vector
Location of camera, or the viewpoint, specified as a 3-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. Interactively rotating the volume modifies the
value of this property.
CameraTarget
— Point used as camera target
[0 0 0]
(default) | 3-element vector
Point used as camera target, specified as a 3-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.
CameraUpVector
— Vector defining upwards direction
[0 0 1]
(default) | 3-element vector
Vector defining upwards direction, specified as a 3-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.
Interactively rotating the volume modifies the value of this property.
CameraViewAngle
— Field of view
15
(default) | numeric scalar
Field of view, specified as a scalar angle in the range [0, 180). The larger the angle, the larger the field of view. Also, as the angle increases, objects appear smaller in the scene. For an illustration, see Camera Graphics Terminology.
Colormap
— Colormap of volume content
gray(256)
(default) | 256-by-3 numeric array
Colormap of the volume content, specified as a 256-by-3 numeric array with values in the range [0, 1].
InteractionsEnabled
— Interactivity of volume
true
(default) | false
Interactivity of the volume, specified as true
or
false
. When true
, 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 the CameraTarget
property.
When false
, you cannot interact with the volume.
IsosurfaceColor
— Isosurface color
RGB triplet | color name | short color name
Isosurface color, specified as an RGB triplet, a color name, or a short color name.
This property specifies the volume color when the Renderer
property
is set to 'Isosurface'
.
You can specify any color using an RGB triplet. An RGB triplet is a 3-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1].
You can specify some common colors by name as a string scalar or character vector. This table lists the named color options and the equivalent RGB triplets.
Color Name | Short Name | RGB Triplet | Appearance |
---|---|---|---|
'red' | 'r' | [1 0 0] |
|
'green' | 'g' | [0 1 0] |
|
'blue' | 'b' | [0 0 1] |
|
'cyan'
| 'c' | [0 1 1] |
|
'magenta' | 'm' | [1 0 1] |
|
'yellow' | 'y' | [1 1 0] |
|
'black' | 'k' | [0 0 0] |
|
'white' | 'w' | [1 1 1] |
|
Here are the RGB triplets for the default colors that MATLAB uses in many types of plots.
RGB Triplet | Appearance |
---|---|
[0 0.4470 0.7410] |
|
[0.8500 0.3250 0.0980] |
|
[0.9290 0.6940 0.1250] |
|
[0.4940 0.1840 0.5560] |
|
[0.4660 0.6740 0.1880] |
|
[0.3010 0.7450 0.9330] |
|
[0.6350 0.0780 0.1840] |
|
Example: 'IsosurfaceColor','r'
Example: 'IsosurfaceColor','green'
Example: 'IsosurfaceColor',[0 0.4470 0.7410]
Isovalue
— Value that defines volume surface
0.49
(default) | nonnegative number
Value that defines the volume surface drawn when the Renderer
property is set to 'Isosurface'
, specified as a nonnegative number in
the range [0, 1].
Lighting
— Include light source in rendering
true
(default) | false
Include light source in rendering, specified as a logical scalar.
Parent
— Parent of volshow
object
gcf
(default) | uipanel | figure
Parent of the volshow
object, specified as a handle to a
uipanel
or figure
. If you do not specify a
parent, then the parent of the volshow
object is
gcf
.
Renderer
— Rendering style
'VolumeRendering'
| 'MaximumIntensityProjection'
| 'Isosurface'
Rendering style, specified as one of the values in this table. When the volume is
logical
, the default rendering style is
'Isosurface'
, otherwise the default rendering style is
'VolumeRendering'
.
Value | Description |
---|---|
'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 . |
ScaleFactors
— Scale factors used to rescale volume
[1 1 1]
(default) | 1-by-3 positive numeric array
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
setVolume | Set new volume |
Examples
Create Animated GIF of Spiral Volume
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
Visualize Volume of MRI Data
Load MRI data and remove the singleton dimension.
load mri
V = squeeze(D);
Generate a colormap 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 colormap 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);
Visualize Volume of CT Data
This example uses 3-D volumetric human chest CT scan data. To run this example, you must download the sample data from MathWorks™ using the Add-On Explorer. See Install Sample Data Using Add-On Explorer.
Load the data into the workspace.
load chestVolume
Create a colormap and transparency 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 colormap 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);
Programatically change the camera position to see a different view of the volume.
vol.CameraPosition = [-1.0533 -0.0093, 0.1593];
Tips
The
volshow
function creates auipanel
object in the specified parent figure. Panels are containers that group UI components together.volshow
displays volumetric data in theuipanel
. In contrast,imshow
displays images in anAxes
. If you callimshow
to display an image in a figure in whichvolshow
has displayed a volume, thenimshow
does not overwrite the volume displayed byvolshow
. TheAxes
created byimshow
displays behind theuipanel
.
Version History
See Also
Volume
Viewer | labelvolshow
| isosurface
| slice
| obliqueslice
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)