How to store Image properties: "MEAN AREA" and "AREA VARIANCE" of an Image with many closed section.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Carl
2017-7-24
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 个评论
Image Analyst
2017-7-24
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!