Main Content

Segment Image Using Find Circles in Image Segmenter

This example shows how to use theFind Circlesoption in the Image Segmenter app to segment an image. The Find Circles option is an automatic segmentation technique that you can use to segment an image into foreground and background elements. The Find Circles option does not require initialization.

Load Image into the Image Segmenter App

Read an image into the workspace.

coins = imread('coins.png');

从MATLAB®OugorStrip,打开Image Segmenterapp. On theAppstab, in theImage Processing and Computer Vision部分中,点击Image Segmenter.

On the app toolstrip, clickLoad Image, 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 app using theimageSegmentercommand, specifying the image:

imageSegmenter(coins);

Use Find Circles to Segment the Image

On theImage Segmenterapp toolstrip, expand the Create Mask section and selectFind Circles.

TheImage Segmenterapp opens a new tab for the Find Circles segmentation option.

In the Find Circles tab, first clickRulerand measure the diameters of some representative circles in the image to determine the range of sizes. To find circles, you must specify the lower and upper bounds on the diameters. Set the values in theMin. DiameterandMax。直径fields to values that you think include all the objects, 50 and 150.

On the Find Circles tab, clickFind Circles. TheImage Segmenterapp fills the circles it finds. However, find circles does not find two of the circles. Examining the image more closely, you discover that the diameter of these coins are slightly smaller than the specified minimum diameter.

Change the minimum value to accommodate the sizes of the objects that were not segmented and run the find circles segmentation operation again. This time,Find Circlessegments all the objects in the image.

Save the Mask Image to the Workspace

When you are satisfied with the segmentation, clickCreate Maskon the Find Circles tab toolstrip and create the mask image. TheImage Segmenterapp closes the Find Circles tab and returns to the Segmentation tab. The color of the segmented circles changes to yellow. To view the mask image, clickShow Binary.

When you are done segmenting the image, save the mask image by using theExportoption. You can also obtain the code used for the segmentation.

See Also

|

Related Topics