A = [5 2 3 8 7 1 2 2 3][labeledA, numRegions] = bwlabel(A < 4)% Get the size of the regions.
props = regionprops(labeledA, 'Area')elementCounts = [props.Area]
In the command window:
A = 5 2 3 8 7 1 2 2 3labeledA = 0 1 1 0 0 2 2 2 2numRegions = 2props = 2×1 struct array with fields: AreaelementCounts = 2 4
And I get sth like this:
elementCounts = 2 4value = 2 3 1 2 2 3
Best Answer