Surface
Description
A Surface object displays a 3-D surface within a scene.
      Properties of the object control the appearance and behavior of the surface.
Creation
Description
s = images.ui.graphics.Surface(viewer) creates a
            Surface object and sets the Parent
          property as the specified 3-D viewer viewer. Use
            s to query and modify properties of the Surface
          object after you create the object.
s = images.ui.graphics.Surface(viewer,
          also sets properties of the object
          using one or more name-value arguments.Name=Value)
For example, images.ui.graphics.Surface(viewer,Alpha=0.5) creates a
            Surface object with a transparency of 0.5.
Properties
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.
Object is visible in the 3-D scene, specified as "on" or "off", or as a numeric or logical
        1 (true) or 0
        (false). A value of "on" is equivalent to
        true, and "off" is equivalent to
        false. The value is stored as an on/off logical value of type OnOffSwitchState.
Since R2025a
Picking state of the surface, specified as one of the strings in the table. Use this
            property to toggle whether the viewer displays point coordinates for the surface. This
            option is useful when a viewer contains multiple child objects, and you want to view or
            hide coordinates for certain volumes or surfaces. Toggle the visibility of the
            information display tool from the viewer context menu, or by using the
                DisplayInfo property of the Viewer
              object.
| Value | Description | 
|---|---|
"visible" | The viewer can pick the surface if it is visible in the scene, and cannot pick the surface if it is not visible. Control the
                        visibility of the surface by using the   | 
"on" | The viewer can pick the surface. | 
"off" | The viewer cannot pick the surface. | 
Transformation applied to the surface in the 3-D scene, specified as an affinetform3d, rigidtform3d,
              simtform3d,
            or transltform3d
            object. Use the  property to
            increase the size of the surface, rotate the surface, or perform other affine
            transformations. The default value is an Transformationaffinetform3d object that
            performs an identity transformation.
Transparency of the surface, specified as a numeric scalar in the range [0, 1].
            Fully opaque surfaces render most quickly, and specifying a value other than
              1.0 (the default) can increase rendering time.
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 | 
|---|---|---|---|
"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] | 
                                                   
  | 
This table lists the default color palettes for plots in the light and dark themes.
| Palette | Palette Colors | 
|---|---|
 Before R2025a: Most plots use these colors by default.  | 
 
  | 
  | 
 
  | 
You can get the RGB triplets for these palettes using the
                orderedcolors function (since R2023b). For example, get the RGB triplets for
        the "gem"
        palette.
RGB = orderedcolors("gem");Example: Color="r"
Example: Color="green"
Example: Color=[0 0.4470 0.7410]
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.
Display surface as wireframe mesh, specified as "on" or "off", or as a numeric or logical
        1 (true) or 0
        (false). A value of "on" is equivalent to
        true, and "off" is equivalent to
        false. The value is stored as an on/off logical value of type OnOffSwitchState.
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.
Examples
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 object.
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");
Create three 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 orange, yellow, and purple, respectively.
cmap = lines; surf1 = images.ui.graphics.Surface(viewer,Color=cmap(2,:),Data=mask1); surf2 = images.ui.graphics.Surface(viewer,Color=cmap(3,:),Data=mask2); surf3 = images.ui.graphics.Surface(viewer,Color=cmap(4,:),Data=mask3);

More About
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 Surface object
        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 | 
|---|---|---|---|
ClippingPlanesChanging | An object clipping plane is being interactively moved. This event does not execute if the clipping plane is programmatically moved.  | images.ui.graphics.events.ClippingPlanesChangedEventData | 
 
  | 
ClippingPlanesChanged | An object clipping plane stops being interactively moved. This event does not execute if the clipping plane is programmatically moved.  | images.ui.graphics.events.ClippingPlanesChangedEventData | 
 
  | 
Version History
Introduced in R2022bControl whether the parent viewer displays information about the surface point beneath
        the pointer by using the new Pickable property.
Surfaces now display fully opaque by default. To preserve the default appearance of
        previous releases, specify Alpha as 0.15. There is
        no requirement to update your code.
The function you use to create a new Surface object has been renamed
        from images.ui.graphics3d.Surface to
          images.ui.graphics.Surface. There are no plans to remove support for
        references to the old function name.
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
 - Canada (English)
 - United States (English)
 
유럽
- 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)