Main Content

Refine Segmentation Using Morphology in Image Segmenter

This example shows how to use the capabilities of theImage Segmenterapp to polish the appearance of the mask image you created with the app. The Image Segmenter app includes several morphological operations that you can use to fix small imperfections in the mask image.

This example creates a mask image using hand-drawn ROIs and active contours (seeSegment Image Using Active Contours in Image Segmenter).

裂殖体加载图像的图像

Open theImage Segmenterapp and load an image to be segmented. TheImage Segmentercan open any file that can be read byimread.

For this example, first read an image into the workspace. This example uses an MRI image of a knee. The goal is to create a mask image that segments the bone from the soft tissue in the image.

I = dicomread('knee1'); knee = mat2gray(I);

From the MATLAB® toolstrip, open theImage Segmenterapp. On theAppstab, in theImage Processing and Computer Visionsection,clickImage Segmenter.

On the app toolstrip, clickLoad, and then selectLoad image from Workspace. In the Import from Workspace dialog box, select the image you read into the workspace. TheImage Segmenterapp displays the image you selected.

You can also open the image in theImage Segmenterapp using theimageSegmentercommand, as follows:

imageSegmenter(knee);

After you load an image, you can optionally load an existing binary mask. For example, you might have previously created a mask by drawing ROIs. To load an existing mask, clickLoad Mask. The segmentation mask image must be a logical image of the same size as the image you are segmenting.

Create the Mask Image

Create a rough segmentation of the image using ROI drawing tools. Use active contours to finish the segmentation. For more details on this process, seeSegment Image Using Active Contours in Image Segmenter.

After finishing the segmentation, clickShow Binaryon the Segmentation tab to view the mask image. Upon close examination, you can see several small holes in the mask image.

The Image Segmenter includes morphological tools to refine the binary mask. Expand the Refine Mask section of the app toolstrip and clickFill Holes.

This removes the holes in the binary mask.

To save the binary mask, clickExportand selectExport Images.

See Also

Related Topics