Main Content

Getting Started with Image Segmenter App

图像分段器应用程序提供对段段图像的许多不同方式的访问。使用图像分段器可以是迭代过程,您可以尝试几个分段选项。某些分割技术可能与某些类型的图像更好地工作而不是其他技术。分割图像后,您可以保存二进制掩码。您还可以检索用于创建掩码的图像分段器的代码。

Open Image Segmenter App and Load Data

打开应用程序并加载要分段的图像。图像分段器可以打开任何可以读取的文件imread

你可以打开图像分段器from the command line. Specify an image in the workspace or the name of a file.

我= imread('coins.png'); imageSegmenter(I)

或者,从中打开应用程序应用标签,下面图像处理和计算机视觉。Then, from the加载菜单,选择工作区变量的名称或包含图像的文件的名称。

加载图像后,您可以选择加载现有的二进制掩码。例如,您之前可能已经创建了一个RGB图像的掩码Color Thresholder应用程序,您希望改进分段。要加载现有面具,请单击加载Mask。分段掩模图像必须是与您分段的图像相同大小的逻辑图像。

创建和添加分段掩码的区域

要创建初始掩码,请使用任何工具Create MaskandAdd to Mask菜单。如果要在创建掩码后启动新分段,请单击新分割。You can perform multiple segmentations using the app. Each segmentation appears, with a thumbnail, in the Data Browser.

To add segmented regions to an existing mask, use tools in theAdd to Maskmenu. The app displays the steps you take while creating the segmentation in the History panel of the Data Browser.

Tool Description
临界点

一种自动技术,可以指定要隔离的强度值。如果要在图像中的对象具有相似的像素强度值,则该技术可以是有用的,并且这些值很容易与图像的其他区域(例如背景)区分开。有关更多信息,请参阅Segment Image Using Thresholding in Image Segmenter

Graph Cut

一种半自动技术,可以进行前景和背景。这种技术不需要仔细放置种子点,您可以交互地改进分割。有关更多信息,请参阅使用图形在图像分段器中切割的段图像

自动集群

An automatic technique where the app groups image features into a binary segmentation. This option is only available if you have Statistics and Machine Learning Toolbox™. For more information, see在图像分部器中使用自动群集的段图像

找到圈子

一种自动技术,可以指定要检测的圆形对象的最小和最大直径。有关更多信息,请参阅段图像在图像分段器中使用查找圈

Local Graph Cut (grabcut)

一种半自动技术,类似于图形切割方法,即段前景和背景。使用本地图形(GrabCut),首先定义包含要段的图像中的对象的ROI。图像分段器自动将对象分段为ROI中的对象。您可以通过在图像上绘制线来识别ROI内的前景和背景来完善分段。ROI之外的一切都被认为是背景。有关更多信息,请参阅Segment Image Using Local Graph Cut (Grabcut) in Image Segmenter

Flood Fill

An automatic technique where you specify starting points and the method segments areas with similar intensity values.

画乐队

A manual technique where you draw shapes that outline the region the objects you want to segment. Using the mouse, you can draw rectangles, ellipses, polygons, or freehand shapes. For more information, see通过使用图像分段器绘制区域段图像

使用时自动集群Graph Cut那andFlood Fill分割工具,你也可以包括纹理s an additional consideration in your segmentation. Texture filtering can help distinguish foreground from background. To turn the texture option on and off, clickInclude Texture Features。启用后,图像分段器uses Gabor filters to analyze the texture of the image as a preprocessing step in the segmentation. For more information about Gabor filters, seeTexture Segmentation Using Gabor Filters

Refine Segmented Mask

图像分段器provides access to several tools that you can use to refine the mask you created.

Tool Description
形态学

许多形态学技术,如扩张和侵蚀。例如,查看在图像分割器中使用形态进行细分

Active contours(also known as snakes)

An iterative method that grows or shrinks regions in an image. You identify the regions with seed points. For an example, viewSegment Image Using Active Contours in Image Segmenter

Clear borders

一种快速的方法,可以在图像边缘上移除小区域。

填充孔

A fast way to fill small holes in foreground regions. For an example, view在图像分割器中使用形态进行细分

逆变掩码

有时,如果颠覆前景和背景,则分段更容易评估。例如,查看在图像分部器中使用自动群集的段图像

出口分段结果

当您找到可接受的分段时,您可以导出到工作区最终分段掩码图像和原始图像的分段版本。要将掩码和分段导出到工作区,请单击Export并选择出口图像

You can also generate the code used to perform the segmentation (requires Statistics and Machine Learning Toolbox.) Use the code to apply the same segmentation algorithm to similar images. To get the code, clickExport并选择生成函数。该应用程序打开MATLAB®editor containing a function with the autogenerated code. To save the code, clickSave在Matlab编辑器中。

也可以看看