MATLAB Answers

How to store Image properties: "MEAN AREA" and "AREA VARIANCE" of an Image with many closed section.

6 views (last 30 days)
Alessandro Bellini
Alessandro Bellini on 21 Jul 2017
Answered: Image Analyst on 24 Jul 2017
As briefly described in the title, I want to create a vector that can store all the values of areas of the single closed section component contained in a binarized image. Of those values, I want to compute the mean value but more important the variance. (I know that for the first issue, I could easily divide the the total number of pixels equal to 1 contained into the image by the number of centroids contained into the image, but I will lose the variance parameter).

  0 Comments

Sign in to comment.

Answers (2)

Carl
Carl on 24 Jul 2017
Hi Alessandro, you can use the bwconncomp function to do this. See the example code below. The bwconncomp function will identify the connected components in your binarized image. You can then easily find the mean and variance of you component sizes.
CC = bwconncomp(BW);
[sizes, ~] = cellfun(@size, CC.PixelIdxList);
meanArea = mean(sizes);
varArea = var(sizes);
Let me know if this works for what you are trying to do.

  0 Comments

Sign in to comment.


Image Analyst
Image Analyst on 24 Jul 2017
If binaryImage is your binary image, you can do
[labeledImage, numRegions] = bwlabel(binaryImage);
props = regionprops(labeledImage, grayImage, 'Area', 'PixelList');
% Extract areas of each blob from structure array into regular double array.
allAreas = [props.Area];
% Get variance of the areas
areaVariance = var(allAreas);
% Get variances of gray levels in each blob.
for k = 1 : numRegions
grayLevelVariances(k) = var(props(k).PixelList);
end
I wasn't sure which variance you meant so I gave you both the variance of the areas, and an array with the gray level variance of each blob.

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by