regionpropsMeasure properties of image regions Show
SyntaxDescriptionexample
Note To return measurements of a 3-D volumetric image, consider using For all syntaxes, you can omit the
example
Examplescollapse all Calculate Centroids and Superimpose Locations on ImageRead a binary image into workspace. Calculate centroids for connected components in the image using s = regionprops(BW,'centroid'); Store the x- and y-coordinates of the centroids into a two-column matrix. centroids = cat(1,s.Centroid); Display the binary image with the centroid locations superimposed. imshow(BW) hold on plot(centroids(:,1),centroids(:,2),'b*') hold off Estimate Center and Radii of Circular Objects and Plot CirclesEstimate the center and radii of circular objects in an image and use this information to plot circles on the image. In this example, Read an image into workspace. a = imread('circlesBrightDark.png'); Turn the input image into a binary image. bw = a < 100;
imshow(bw)
title('Image with Circles') Calculate properties of regions in the image and return the data in a table. stats = regionprops('table',bw,'Centroid',... 'MajorAxisLength','MinorAxisLength') stats=4×3 table
Centroid MajorAxisLength MinorAxisLength
________________ _______________ _______________
256.5 256.5 834.46 834.46
300 120 81.759 81.759
330.47 369.83 111.78 110.36
450 240 101.72 101.72
Get centers and radii of the circles. centers = stats.Centroid; diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2); radii = diameters/2; Plot the circles. hold on viscircles(centers,radii); hold off Input Argumentscollapse all BW — Binary image logical arrayBinary image, specified as a logical array of any dimension. Data Types: CC — Connected components structureConnected
components, specified as a structure returned by Data Types: L — Label image numeric array | categorical arrayLabel image, specified as one of the following.
Data Types: properties — Type of measurement "basic" (default) | comma-separated list of string scalars or character vectors | array of string scalars | cell array of character vectors | "all"Type of measurement, specified as a comma-separated list of
string scalars or character vectors, an array of string scalars, a cell array of character vectors, or as
The following tables list all the properties that provide shape measurements. The properties listed in the Pixel Value Measurements table are valid only when you specify a grayscale image. Shape Measurements
The pixel value measurement properties in the following table are valid only when you specify a grayscale image, Pixel Value Measurements
Data Types: I — Image to be measured grayscale imageImage to be measured, specified as a grayscale image. The size of the image must match the size of the binary image
Data Types: output — Return type "struct" (default) | "table"Return type, specified as either of the following values.
Data Types: Output Argumentscollapse all stats — Measurement values struct array (default) | tableMeasurement 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 More Aboutcollapse all Contiguous Regions and Discontiguous RegionsContiguous regions are also called
objects, connected components, or blobs. A label image 1 1 0 2 2 0 3 3 1 1 0 2 2 0 3 3 Elements of Discontiguous regions are regions that can contain multiple connected components. A label image containing discontiguous regions might look like this: 1 1 0 1 1 0 2 2 1 1 0 1 1 0 2 2 Elements of Tips
Extended CapabilitiesC/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.Usage notes and limitations:
GPU Code Generation Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.Usage notes and limitations:
Thread-Based Environment Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment. GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.Usage notes and limitations:
For more information, see Image Processing on a GPU. Version HistoryIntroduced before R2006a expand all R2022b: Support for thread-based environments
R2022a: regionprops stores the Image, ConvexImage, and FilledImage properties as cell arrays in the output table for all inputsStarting
in R2022a, when a table output format is specified, the To update your code, access the value of the stats = regionprops("table",BW,"Image"); imdata = stats.Image{1}; What will take you from one corner to another corner of a selection?If you have a single-column range selected, a single Ctrl+Period will get you to the top. If you have a rectangular range selected, pressing Ctrl+Period will move in a clockwise sequence to the next corner.
What is the Wrap text button in Excel?The Excel wrap text feature can help you fully display longer text in a cell without it overflowing to other cells. "Wrapping text" means displaying the cell contents on multiple lines, rather than one long line.
What is a range in Excel?Range represents a set of one or more contiguous cells such as a cell, a row, a column, or a block of cells.
What are the letters at the top of a spreadsheet called?These letters and numbers are called row and column headings.
|