Display surface in 3-D viewer
Surface object displays a 3-D surface within a scene.
Properties of the object control the appearance and behavior of the surface.
s = images.ui.graphics3d.Surface(viewer) creates a
Surface object and sets the
property as the specified 3-D viewer
s to query and modify properties of the
object after you create the object.
Data — Surface grayscale data
3-D logical array |
Surface grayscale data displayed in the viewer, specified as a 3-D logical array
with nonsingleton dimensions or as a
triangulation object containing 3-D points.
Visible — Object is visible
"on" (default) | on/off logical value
Object is visible in the 3-D scene, specified as
Transformation — Transformation applied to surface
affinetform3d object |
rigidtform3d object |
simtform3d object |
Transformation applied to the surface in the 3-D scene, specified as an
object. Use the
increase the size of the surface, rotate the surface, or perform other affine
transformations. The default value is an
affinetform3d object that
performs an identity transformation.
Alpha — Transparency of surface
0.15 (default) | number in range [0, 1]
Transparency of the surface, specified as a number in the range [0, 1].
Color — Color of surface
RGB triplet | color name | short color name | n-by-3 numeric matrix
Color of the surface, specified as one of these values.
RGB triplet, color name, or short color name — Use the same color for all the vertices on the surface.
n-by-3 numeric matrix representing n RGB triplets — Use a different color for each vertex on the surface. Each row of the matrix defines one color. The number of rows must equal the number of vertices.
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|
Here are the RGB triplets for the default colors that MATLAB® uses in many types of plots.
Color=[0 0.4470 0.7410]
ClippingPlanes — Clipping planes
 (default) | N-by-4 matrix
Clipping planes applied locally to the object, specified as an N-by-4 matrix where each row corresponds to the equation for a clipping plane. The maximum number of clipping planes N is six. Each clipping plane is specified as a 1-by-4 vector, in world coordinates, following the Hessian normal form where the first three values represent the normal vector of the plane and the fourth value is the signed distance from the origin to the plane.
Wireframe — Display surface as wireframe mesh
"off" (default) | on/off logical value
Display surface as wireframe mesh, specified as
When this value is
"on", the surface is rendered as a wireframe
mesh. When this value is
"off", the faces are rendered according to
the color and transparency of the object.
Display Labels as Colored Surfaces Within Volume
Load a 3-D image and corresponding label data.
datadir = fullfile(toolboxdir("images"),"imdata","BrainMRILabeled"); load(fullfile(datadir,"images","vol_001.mat")) load(fullfile(datadir,"labels","label_001.mat"))
The label data has three classes. Create binary masks for each class.
mask1 = (label == 1); mask2 = (label == 2); mask3 = (label == 3);
Display the scene using a
viewer = viewer3d;
Display the image data using a
Volume object. Render the image data using maximum intensity projection.
obj = volshow(vol,Parent=viewer, ... RenderingStyle="MaximumIntensityProjection");
Surface objects, one for each class. Display the surfaces using the
lines colormap. Skip the first color, which is a shade of blue that is similar to the color of the scene. The three surfaces appear red, yellow, and purple, respectively.
cmap = lines; surf1 = images.ui.graphics3d.Surface(viewer,Color=cmap(2,:),Data=mask1); surf2 = images.ui.graphics3d.Surface(viewer,Color=cmap(3,:),Data=mask2); surf3 = images.ui.graphics3d.Surface(viewer,Color=cmap(4,:),Data=mask3);
To receive notification from the
Surface object when certain events happen, set up
listeners for these events. You can specify a callback function
that executes when one of these events occurs. When the
notifies your application through the listener, it returns data specific to the event. Look
at the event class for the specific event to see what is returned.
|Event Name||Trigger||Event Data||Event Attributes|
An object clipping plane is being interactively moved. This event does not execute if the clipping plane is programmatically moved.
An object clipping plane stops being interactively moved. This event does not execute if the clipping plane is programmatically moved.
Introduced in R2022b