Getting Started with Image Segmenter App
The Image Segmenter app provides access to many different ways to segment an image. Performing segmentation using Image Segmenter can be an iterative process where you might try several of the segmentation options. Some segmentation techniques might work better with certain types of images than others. After segmenting an image, you can save the binary mask. You can also retrieve the code that Image Segmenter used to create the mask.
Open Image Segmenter App and Load Data
Open the app and load an image to be segmented. Image Segmenter can
open any file that can be read by
You can open the Image Segmenter from the command line. Specify an image in the workspace or the name of a file.
I = imread('coins.png'); imageSegmenter(I)
Alternatively, open the app from the Apps tab, under Image Processing and Computer Vision. Then, from the Load menu, choose the name of a workspace variable or the name of the file containing the image.
After you load an image, you can optionally load an existing binary mask. For example, you might have previously created a mask of an RGB image in the Color Thresholder app and you want to refine the segmentation. To load an existing mask, click Load Mask. The segmentation mask image must be a logical image of the same size as the image you are segmenting.
Create and Add Regions to Segmented Mask
To create an initial mask, use any of the tools in the Create Mask and Add to Mask menus. If you want to start a new segmentation after creating a mask, click New Segmentation. 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 the Add to Mask menu. The app displays the steps you take while creating the segmentation in the History panel of the Data Browser.
An automatic technique where you specify an intensity value that you want to isolate. This technique can be useful if the objects you want to segment in the image have similar pixel intensity values and these values are easily distinguished from other areas of the image, such as the background. For more information, see Segment Image Using Thresholding in Image Segmenter.
A semi-automatic technique that can segment foreground and background. This technique does not require careful placement of seed points and you can refine the segmentation interactively. For more information, see Segment Image Using Graph Cut in Image Segmenter.
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 Segment Image Using Auto Cluster in Image Segmenter.
An automatic technique where you specify the minimum and maximum diameter of the circular objects you want to detect. For more information, see Segment Image Using Find Circles in Image Segmenter
|Local Graph Cut (grabcut)|
A semi-automatic technique, similar to the Graph Cut method, that can segment foreground and background. With Local Graph Cut (grabcut), you first define an ROI that encompasses the object in the image that you want to segment. The Image Segmenter automatically segments the object in the ROI. You can refine the segmentation by drawing lines on the image to identify the foreground and the background within the ROI. Everything outside the ROI is considered background. For more information, see Segment Image Using Local Graph Cut (Grabcut) in Image Segmenter.
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 Segment Image by Drawing Regions Using Image Segmenter.
When using the Auto Cluster, Graph Cut, and Flood Fill segmentation tools, you can also include texture as an additional consideration in your segmentation. Texture filtering can help distinguish foreground from background. To turn the texture option on and off, click Include Texture Features. When enabled, Image Segmenter uses Gabor filters to analyze the texture of the image as a preprocessing step in the segmentation. For more information about Gabor filters, see Texture Segmentation Using Gabor Filters.
Refine Segmented Mask
Image Segmenter provides access to several tools that you can use to refine the mask you created.
Many morphological techniques, such as dilation and erosion. For an example, view Refine Segmentation Using Morphology in Image Segmenter.
|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, view Segment Image Using Active Contours in Image Segmenter.
A fast way to remove small regions on the edge of the image.
A fast way to fill small holes in foreground regions. For an example, view Refine Segmentation Using Morphology in Image Segmenter.
Sometimes the segmentation is easier to evaluate if you invert the foreground and background. For an example, view Segment Image Using Auto Cluster in Image Segmenter
Export Segmentation Results
When you find an acceptable segmentation, you can export to the workspace the final segmentation mask image and the segmented version of the original image. To export the mask and segmentation to the workspace, click Export and select Export Images.
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, click Export and select Generate Function. The app opens the MATLAB® editor containing a function with the autogenerated code. To save the code, click Save in the MATLAB editor.