Calculate Properties of Image Regions Using Image Region Analyzer
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, measured by area, in the image.
Read a binary image into the 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:
The Image Region Analyzer app displays the binary image and a table with region properties. In the table, 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.
To access the image exploration controls such as pan and zoom, move the cursor over the image.
The app initially displays a subset of the available properties. To add or remove properties from the table, click Choose Properties and select the properties you want to view. The app updates the table automatically.
Initially, the app lists the regions in the order it finds them, starting in the upper-left corner of the image. To change the sorting order, click the sort icon next to a property name in the table. The app sorts the regions in increasing order. Click again to sort the regions in decreasing order.
For example, to sort the regions in the image from largest area to smallest area, click on the sort icon for the
Area property twice.
To view the region in the image with the largest area, click the first row in the table. The app highlights the corresponding region in the image.