The regionprops function measures properties such as area, centroid, and bounding box, for each object (connected component) in an image. regionprops supports both contiguous regions and discontiguous regions.
regionprops finds unique objects in binary images using 8-connected neighborhoods for 2-D images and maximal connectivity for higher dimension images. For more information, see Pixel Connectivity. To find objects using other types of connectivity, use bwconncomp to create the connected components, and then pass the result to regionprops using the CC argument instead.
stats = regionprops(regions,I,properties) also measures pixel value properties for each labeled region in the grayscale image I. The first input argument, regions, must be a valid value for the BW, CC, or L argument.
regionprops sorts the objects in the binary image from left to right based on the top-left extremum of each component. When multiple objects have the same horizontal position, the function then sorts those objects from top to bottom, and again along any higher dimensions. regionprops returns the measured properties, stats, in the same order as the sorted objects.
A numeric array of any dimension. Pixels labeled 0 are the background. Pixels labeled 1 make up one object; pixels labeled 2 make up a second object; and so on. regionprops treats negative-valued pixels as background and rounds down input pixels that are not integers. You can get a numeric label image from labeling functions such as watershed or labelmatrix.
Position and size of the smallest box containing the region, returned as a 1-by-(2*Q) vector, where Q is the image dimensionality. The first Q elements are the coordinates of the minimum corner of the box. The second Q elements are the size of the box along each dimension. For example, a 2-D bounding box with value [5.5 8.5 11 14] indicates that the (x,y) coordinate of the top-left corner of the box is (5.5, 8.5), the horizontal width of the box is 11 pixels, and the vertical height of the box is 14 pixels.
Center of mass of the region, returned as a 1-by-Q vector, where Q is the image dimensionality. The first element of Centroid is the horizontal coordinate (or x-coordinate) of the center of mass. The second element is the vertical coordinate (or y-coordinate). All other elements of Centroid are in order of dimension.
Extrema points in the region, returned as an 8-by-2 matrix. Each row of the matrix contains the x- and y-coordinates of one of the points. The format of the vector is [top-left top-right right-top right-bottom bottom-right bottom-left left-bottom left-top]. For some shapes, multiple extrema points can have identical coordinates.
This figure illustrates the extrema of two different regions. In the region on the left, each extrema point is distinct. For the region on the right, certain extrema points (such as top-left and left-top) are identical.
Angle between the x-axis and the major axis of the ellipse that has the same second-moments as the region, returned as a scalar. The value is in degrees, ranging from -90 degrees to 90 degrees. This figure illustrates the axes and orientation of the ellipse. The left side of the figure shows an image region and its corresponding ellipse. The right side shows the same ellipse with the solid blue lines representing the axes. The red dots are the foci. The orientation is the angle between the horizontal dotted line and the major axis.
Distance around the boundary of the region returned as a scalar. regionprops computes the perimeter by calculating the distance between each adjoining pair of pixels around the border of the region. If the image contains discontiguous regions, regionprops returns unexpected results. This figure illustrates the pixels included in the perimeter calculation for this object.
Measurement values, returned as an array of structures or a table. The number of structures in the array or the number of rows in the table is equal to the number of objects in BW, CC.NumObjects, or max(L(:)). The fields of each structure or the variables in each row denote the properties calculated for each region, as specified by properties. If the input image is a categorical label image L, then stats includes an additional field or variable with the property "LabelName".
1 1 0 1 1 0 2 21 1 0 1 1 0 2 2Elements of L equal to 1 belong to the first region, which is discontiguous and contains two connected components. Elements of L equal to 2 belong to the second region, which is a single connected component.
Starting in R2022a, when a table output format is specified, the regionprops function stores the Image, ConvexImage, and FilledImage property values as cell arrays, regardless of the size of the image objects. In previous releases, if the size of the bounding box of an object was 1-by-1 or 1-by-n, these properties were stored in the output table as a numeric scalar or row vector.
To update your code, access the value of the Image, ConvexImage, and FilledImage properties by using dot notation with curly braces, . For example, use the below code to access the Image property for the first object in the input image BW. In previous releases, curly braces were not required to access values stored as a numeric scalar or row vector.
regionprops now measures the circularity and Feret properties of regions in a binary image. To measure the circularity, minimum Feret properties, or maximum Feret properties, include "Circularity", "MinFeretProperties", or "MaxFeretProperties", respectively, when specifying the properties argument.
Origin is the data analysis and graphing software of choice for over a million scientists and engineers in commercial industries, academia, and government laboratories worldwide. Origin offers an easy-to-use interface for beginners, combined with the ability to perform advanced customization as you become more familiar with the application.
Take your data analysis to the next level with OriginPro. In addition to all of Origin's features, OriginPro offers advanced analysis tools and Apps for Peak Fitting, Surface Fitting, Statistics and Signal Processing. Features specific to OriginPro are marked with the PRO icon in this page. Visit the Origin v.s. OriginPro page to view a comparison table.
With over 100 built-in and extended graph types and point-and-click customization of all elements, Origin makes it easy to create and customize publication-quality graphs. You can add additional axes and panels, add, remove plots, etc. to suit your needs. Batch plot new graphs with similar data structure, or save the customized graph as graph template or save customized elements as graph themes for future use.
This is a box plot with mean points connected. The user can also connect median points, data points or other percentiles, using controls on the Connect Lines tab of the Plot Details dialog.
A 3D OpenGL Surface Plot with multiple surfaces stacked in one graph layer. The graph has been customized by assigning a unique plot style and a custom Z offset to each surface. Some surfaces are also rendered as flat.
When merging individual graphs, check Treat Each Source Graph as a Unit to maintain the proper relationship of layers in individual graphs. In this example, each inset graph remains with its parent layer. An add labels option is also available to facilitate adding labels to each unit in the merged graph.
A multi-panel graph combining several layers of contour and line plots arranged flexibly. Note the inset layer on the bottom right panel. The top panel displays stacked lines by y offset allowing for easy comparison of multiple data plots.
In this graph, one dataset is plotted as a scatter graph + error bars. Because the data is dense, every other point is skipped using the Skip Points settings in Plot Details.The other two datasets are plotted as grouped line plots for easy customization. Their corresponding error bars are drawn as transparent bands. Vertical and Horizontal drop lines are drawn from a point to the axes, with the x and y values labeled.
Origin supports offsetting plots in the X and Y directions with no change in data values. Offset options include auto, cumulative, incremental, constant, and individual. In this graph we stacked curves with a pattern such as 0 -100 so each data pair stayed together. The color and style were customized to use repeated patterns. For such graphs, you can also drag a single curve to reposition it for comparison with another curve. The Legend is arranged in two columns and placed beside each plot pair.
A color mapped bubble chart. This is essentially a scatter plot with modifiers for symbol size and color, set using other data columns. Notice the bubble legend on the top left of the graph. This unique feature in Origin allows for various configurations for this legend. The powerful Color Chooser dialog is displayed on the right side. This dialog has several options including the ability to load a list of pre-defined colors.
This graph displays the relative quantities of size fractions of unconsolidated sedimentary materials with depth below the ground surface. Hatch (Fill) pattern selection has been enhanced for Origin 2017, including the addition of entirely new "Geology" fill patterns.
The graph is an example of a sunburst chart. A sunburst has multiple levels (represented by different rings), across which you can see how a category is split into contributing sub-categories. The color-indexing of the rings is done by values from the same "Browser" column in the worksheet.
A Double-Y plot allowing for easy comparison of two datasets. Note that the Y axes ticks and labels have the same color as the data plot they represent. Other features include scientific notation for labels in the right Y axis, special tick labels at user-specified axis positions, and an axis break in the X axis. Origin supports multiple special ticks and axes breaks.
b37509886e