blue = [0 0.4470 0.7410];
%%
name = 'ten-objects';
suffix = '.tif';
Img = imread(['images\', name, suffix]);
[rows, cols] = size(Img);
label = bwconncomp(Img); %bwlabel
region_stats_table = regionprops("table", label, ["BoundingBox" "Circularity" ...
"Eccentricity" "Area" "Extent" "Solidity" "Perimeter"])
region_stats = region_stats_table.Variables;
% boundaries_stats = diameter(label);
BW = Img;
figure; imshow(Img,'InitialMagnification',200)
hold on
for i = 1 : label.NumObjects
text(region_stats(i,2) + region_stats(i,4)/2, ...
region_stats(i,3) + region_stats(i,5)/2, [num2str(i)], ...
'Color', blue, 'FontSize',14, 'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle','Interpreter','latex')
end
%%
figure
region_stats = region_stats_table.Variables;
xvalues = {"Area" "Eccentricity" "Circularity" ...
"Solidity" "Extent" "Perimeter" };
yvalues = {'D' 'A' 'Square' 'Rectangle' 'E' 'B' 'Triangle' 'F' 'C' 'Circle'};
h = heatmap(xvalues,yvalues,region_stats(:,[1,6:end]),Interpreter="latex");
h.ColorScaling = 'scaledcolumns';