How to store Image properties: "MEAN AREA" and "AREA VARIANCE" of an Image with many closed section.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Carl
am 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 Kommentare
Image Analyst
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Classification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!