This example shows how to calculate the properties of regions in binary images by using the Image Region Analyzer app. This example finds the largest region, measure by area, in the image.
Read a binary image into the MATLAB workspace.
BW = imread('text.png');
Open the Image Region Analyzer app from the MATLAB toolstrip. On the Apps tab, in the Image Processing and Computer Vision section, click Image Region Analyzer .
On the app toolstrip, click Load Image, and then select Load Image from Workspace to load the image from the workspace into the app. In the Import From Workspace dialog box, select the image you read into the workspace, and then click OK.
You can also open the app from the command line by using the imageRegionAnalyzer
function, specifying the image you want to analyze: imageRegionAnalyzer(BW);
.
The Image Region Analyzer app displays the image you selected and a table where each row is a region identified in the image and each column is a property of that region, such as the area, perimeter, and orientation. (The Image Region Analyzer app uses the regionprops
function to identify regions in the image and calculate properties of these regions.)
To explore the image, move the cursor over the image to access the pan and zoom controls.
The app calculates more properties than it initially includes in the table. To view additional properties in the table, click Choose Properties and select the properties you want to view. The app updates the table automatically, adding a new column to the table for each property.
To explore properties of the image, sort the information in the table. Initially, the app lists the properties in the order it finds them, starting in the upper-left corner of the image. To change the sorting order, in the Properties section of the app toolstrip, click Sort Table and select the property on which you want to sort. For example, to find the largest region in the image, sort on the Area
property. The Image Region Analyzer app sorts the table by size.
To view the region in the image with the largest area, click the item in the table. The app highlights the corresponding region in the image.
bwareafilt
| bwpropfilt
| Image Region Analyzer | regionprops