The Image Segmenter Workflow

This example shows how to use an iterative approach to image segmentation, trying several different methods until you achieve the results you want.

For information about opening the app and loading an image, see Open Image Segmenter App and Load Image. This example uses an image from an MRI of a knee. Use the following code to read the image into the workspace and load it into the Image Segmenter.

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

Segment Using Threshold Technique in Image Segmenter

As a first attempt at the segmentation of the knee image, try thresholding.

Click Threshold in the Create Mask toolstrip group. The app displays the Threshold tab. You can choose between several thresholding methods: Global, Adaptive, and Manual. It is often useful to try each option and see which one works best with your image. Experiment with the optional parameters available with each option. For example, with the Manual option you can use a slider to specify the threshold value. The knee image does not have well-defined pixel intensity differences between foreground and background. Thresholding does not seem like the best choice to segment this image.

Click Cancel to return to the main segmentation app window without accepting the result and try one of the other segmentation options. If you had wanted to keep the thresholded mask image, click Create Mask.

Segment By Drawing Regions in Image Segmenter

Another technique that you can try is to draw the regions that you want to include in the mask image. The Image Segmenter provides tools you can use to draw rectangles, ellipses, polygons, or freehand shapes.

Expand the Add to Mask group and click the Draw ROIs option. Select the type of ROI you want to draw and the cursor changes to the cross hairs shape when you move it over the image. Press the mouse button, and draw a shape over the image that outlines the object you want to segment. With the Assisted Freehand ROI option, which is preselected, you can draw a freehand shape that automatically follows edges in the underlying image to help you draw a more accurate ROI. As you draw, click the mouse to create waypoints for accurate drawing. To adjust the borders of the ROI, double-click on the ROI edge to add an additional waypoint. Move the waypoint to adjust the border of the ROI.

Click Apply to save the regions your have drawn. To save this mask image, click Export.

Use Active Contours to Refine Segmentation in Image Segmenter

This part of the example shows how to refine a binary mask created using the Image Segmenter. The Image Segmenter app provides several tools that you can use to fill holes, finish a rough approximation using Active Contours, and other operations. This example shows how to load an existing binary mask image. Active contours (snakes) is an automatic, iterative method where you mark locations in the image and active contours grows (or shrinks) the regions identified in the image. To use active contours, you must have a rough segmentation already. The accuracy of this initial seed mask can impact the final result after active contours. You can use the Include Texture Features option with Active Contours.

Draw seed shapes in the regions you want to segment. You can use the freehand regions drawn using the freehand tool (see Segment By Drawing Regions in Image Segmenter). To use an existing binary mask, first load the original image that you segmented. After loading the original image, click Load Mask and specify the segmented image result from the example Segment By Drawing Regions in Image Segmenter.

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

Click the Active Contours option. The Image Segmenter opens the Active Contours tab.

Click Evolve to use active contours to grow the regions to fill the objects to their borders. Initially, use the default active contours method (Region-based) and the default number of iterations (100). The Image Segmenter displays the progress of the processing in the lower right corner. Looking at the results, you can see that this approach worked for two of the three objects but the segmentation bled into the background for one of the objects. The object boundary isn’t as well-defined in this area.

Repeat the active contours segmentation, this time changing the number of iterations. To redo the operation, change the number of iterations in the iterations box, specifying 35, and click Evolve again. When you are satisfied with the segmentation, click Apply. The color of the regions changes from blue to yellow, indicating that the changes have been applied. To see how to remove the small imperfection in the one of the regions, see Use Morphology to Refine Mask in Image Segmenter.

Use Morphology to Refine Mask in Image Segmenter

The segmentation mask image you created in the segmentation step (The Image Segmenter Workflow) might have slight imperfections that you'd like to fix. The Image Segmenter includes morphological tools, such as dilation and erosion, on the Morphology tab, and options like Fill Holes and Clear Borders on the Segmentation tab. You can use these tools to improve your mask image.

Upon close examination, one of the mask regions (created in The Image Segmenter Workflow) contains a small hole.

Click Fill Holes and the Image Segmenter fills the hole in the region.

See Also


Related Topics