主要内容

使用音量细分器创建语义细分

此示例显示了如何使用Volume Segmenter应用程序。这Volume Segmenterapp offers many ways to explore a volume and segment objects in the volume. For example, you can view the volume slice-by-slice or as a 3-D representation. To segment an object, you can draw a region of interest (ROI) using ROI drawing tools or a paint brush tool. This example segments a stack of MRI images to label the brain and tumor regions. The example also labels the background.

Load Volumetric Data into the Workspace

将音量加载到工作区中。此示例使用一堆MRI脑图像,存储在垫子文件中vol_001.mat

加载(FullFile(toolboxDir)('图片'),'imdata',。。。“脑部标记”,'图片','vol_001.mat');

此命令加载一个240乘240-BY-155卷vol进入工作区。

whosvol
名称大小字节类属性vol 240x240x155 17856000 uint16

打开卷部分

Open theVolume Segmenter应用程序。点击Appstab on the MATLAB® toolstrip. In theImage Processing and Computer Visionsection, clickVolume Segmenter

Load the Volume into the Volume Segmenter

To load the volume in theVolume Segmenter应用,单击开放音量在里面app toolstrip. For this example, selectOpen from Workspace。在里面Import Volume dialog box, select the volume you loaded into the workspace,vol, 和click好的。(您还可以使用该应用程序指定卷体积分子command:体积分子(VOL)

Volume Segmenter应用显示该卷的3-D表示3-D Display窗格并显示数据集的单个切片窗格。

默认情况下,窗格显示数据的第一片。该应用显示图像顶部显示的切片的数量,例如1/155。在此数据集中,前几个切片不包含大脑的图像。

这app also automatically creates a label for the segmentation in the标签pane, using the default name标签1。您可以在标签窗格。但是,要创建二进制掩码,您只需使用一个标签。

To change the name of the label, double-click the label name. To change the color associated with the label, double-click the color square displayed in the标签窗格。您可以选择加载一组现有的labels into the app using the打开标签按钮。

Explore the Volume

To determine what you want to segment, explore the volume using the3-D Displaypane and the窗格。

在里面3-D Displaypane, you can rotate the volume to examine the data from every angle, using the mouse. You can also customize the display of the volume in the3-D DisplayApp Toolstrip中的选项卡。例如,如果您的元数据描述了体素的相对大小,则可以在空间引用的一部分3-D DisplayApp Toolstrip中的选项卡。为了改善数据的视图,您可以更改3-D显示屏中使用的背景颜色,修改显示屏的阈值和不透明度,并在显示屏中包括方向轴,如下图所示。有了大脑MRI数据,您可以在颞叶中看到要分割的肿瘤。

您还可以查看该卷的每个切片窗格。使用窗格底部的滑块从切片到切片。您可以在切片35到切片88上看到肿瘤。默认情况下,pane displays the volume oriented along the X-Y axis, but you can change this using buttons in the Orientation section of the toolstrip on the细分器标签。这窗格也是您使用绘图工具来定义面具的地方。

使用绘图工具将卷中的区域标记

一旦确定要细分的对象,就可以使用该工具tab in the app toolstrip to define the region. Select the drawing tool you want to use from the ROI tools:Freehand,协助Freehand, 和Polygon, 和aPaintBrush工具。

Start by labeling the brain. When one object is nested in another object, as the tumor appears over the brain on slices, label the larger region first. The first step is to create a label in the标签窗格。该应用程序默认提供一个标签,命名标签1。要将标签的名称更改为更具描述性的应用程序,请双击标签,然后输入新名称。要更改与标签关联的默认颜色,请双击标签标识符的彩色正方形,然后从“颜色对话框”中选择颜色。

在里面窗格,导航到对象首先出现的切片,并使用绘图工具标记对象。在下图中,此示例使用油漆工具来标记大脑,但是您可以使用任何绘图工具。

使用插值来加快对象创建的速度

您可以在卷中移动,逐个切片,并在对象出现的每个切片上绘制ROI。然而Volume SegmenterApp提供了几种自动插值工具,可以帮助您跨切片分割对象。

To use interpolation, you must first manually define the region on two slices. You have already defined the region on the first slice where the object appears, slice 35. Use the same process to define the region on the last slice where it appears, slice 88. The app places two bars on the slider, using the color associated with the label, to indicate the slices with ROIs.

在两个切片上定义的ROI,请单击Auto Interpolate。该应用程序会自动定义所有中间幻灯片上的ROI。该应用程序使用蓝色条来指示所有带有ROI的切片,现在看起来像是从切片35到切片88的实心条。

另外,在两片上定义ROI后,您可以单击手动插值。使用此选项,该应用程序打开了手动插值对话框。您选择要插值的两个区域,第二区和第二区。要选择第一个区域,请使用对话框底部的滑块用ROI,切片35导航到第一个切片,然后单击显示的ROI内部。要选择第二个区域,请单击区域二,导航至幻灯片88,然后单击显示的ROI内部。选择两个区域后,单击Run在所有中间切片上插入ROI。

完善插值标签

使用插值后,检查单个切片以查看插值是否创造了令人满意的ROI。请注意,切片71上的ROI不会填充要分割的整个对象。您可以使用PaintBrush工具。Alternatively, you can use one of the tools in the自动化标签。例如,您可以使用主动轮廓要在不填充肿瘤的全尺寸的切片上种植ROI。

执行自定义处理

您还可以添加自己的算法以在ROI上运行。在自动化tab, click添加算法。Choose whether you want your processing function to operate on each 2-D slice (Slice-based) or on the entire 3-D volume (Volume-based).

对于此示例,在基于切片的情况下,选择新的option and click功能模板创建一个在每个2D切片上运行的新功能。该应用程序在MATLAB编辑器中打开模板。将模板中的示例代码替换为要使用的代码。您的功能必须接受两个参数:每个片段作为单独的图像和掩码。您的功能还必须返回蒙版图像。

编辑模板完成后,保存文件。这Volume Segmenterapp automatically creates a button in the自动化tab toolstrip for your function. To test your function on one slice, clickRun。默认情况下,该应用仅将功能应用于当前切片。

After testing your function on a single slice, you can run it on all of the slices or a subset of the slices. You can run it from the current slice to the end (the highest numbered slice) or from the current slice back to the beginning (slice 1). You can also specify a range of slices by specifying the starting slice and the ending slice.

当您选择一个定向选项之一时,该应用会更新显示屏中的切片数字。您可以使用此显示来查看处理的进度。

创建其他标签

在每个切片上标记大脑后,将其在切片上出现的肿瘤标记,重复上述过程。

First, define a new label in the标签窗格。单击加号标签pane to create a new label.

在里面窗格,导航到首次出现对象的切片,然后使用绘图工具开始标记每个切片上的对象。在下图中,此示例使用油漆工具标记肿瘤。如前所述,您可以在每个切片上绘制对象,也可以使用插值工具自动绘制多个切片。插值后,您可以使用绘图工具,例如Eraser,修改每个切片上的自动分割。

Save the Segmentation

完成体积中的大脑和肿瘤标记时,保存分割。点击保存标签细分器标签并从几个选项中选择。您可以将标记的MRI数据保存为垫子文件或工作空间中的变量。对于此示例,选择一个工作区变量。定义多个标签时Volume SegmenterAPP在工作区中创建一个与输入卷相同的大小。保存细分后,您可以选择打开Autosave,这会定期自动保存分割。

Make the Background a Separately Labeled Region

After labeling the brain and the tumor, and saving the segmentation to the workspace as a categorical volume, you might notice that the background voxels all have the value<未定义>。要标记背景体素,以便它们也具有可识别的分类,请遵循与先前描述的相似的过程:

  1. Define a new label in the标签pane, give the label a descriptive name, and select the color you want for the background.

  2. 标记每个切片的背景。导航到切片,选择Fill Region标签,然后在后台单击任何地方。在每个切片上重复此过程。

当您添加背景时,它可能会掩盖其他标签3-D Display窗格。查看其他标记区域3-D Displaypane, disable the visibility of the background label. Click显示标签在里面3-D Displaytab, click定制, 和deselect the visibility of the background label.

查看标记的卷

要查看面具,请使用Labelvolshow功能:Labelvolshow(brain_labels);

See Also

相关话题