In the documentation:
CC = bwconncomp (BW) returns the connected CC components found in BW. The BW binary image can have any dimension. CC - structure with four fields ...
The final field in CC is PixelIdxList , which is:
[a] array of 1-by-NumObjects cells, where the k-th element in the cell array is a vector containing linear pixel indices in the k-th object.
You can find the area of โโeach label by looking at the length of the corresponding record in the array of cells. Sort of:
areas_in_pixels = cellfun(@length, CC.PixelIdxList);
A PixelIdxList is an array of cells, each of which contains linear indexes of pixels present in this connected component. The line of code above defines the length of each cell in an array of cells - that is, the number of pixels in each connected component.
I used cellfun to make the code short and efficient. Another way to write the same thing:
areas_in_pixels = nan(1, length(CC.PixelIdxList); for i = 1:length(CC.PixelIdxList) areas_in_pixels(i) = length(CC.PixelIdxList{i}); end
For each connected component, you can find the size of this component in pixels by accessing the element in the injection_ areas:
areas_in_pixels(34) %
source share