Change Color of Segmented object based on Solidity
Show older comments
I have used regionprops to calculate the Convexhull of each shape in the image shown and then drawn the region in red around it. I want to color each blob differently according to the solidity value and then display the colormap on the figure itself on the side. Essentially, the lower the value, the darker I want it to be.
I have thought about implementing it manually through if statements but then how would I display the colormap on the side?
Much appreciated!
HOW IT LOOKS CURRENTLY:

HOW I WANT IT TO LOOK:

stats = regionprops(mask,{...
'Centroid',...
'MajorAxisLength',...
'MinorAxisLength',...
'Orientation', ...
'Circularity', ...
'ConvexHull', ...
'Solidity', ...
'Eccentricity', ...
'BoundingBox', 'Area' })
figure , imshow(img)
hold on
for k = 1 : size(stats)
tempHull = stats(k).ConvexHull;
tmpSize = size(tempHull);
x = tempHull(:, 1);
y = tempHull(:,2);
tempSolid = round(stats(k).Solidity, 2);
fill(x, y, fillColor);
plot(x, y, 'LineWidth', 1, 'Color', 'r');
text(stats(k).Centroid(1), stats(k).Centroid(2), num2str(tempSolid), 'FontSize', 12);
end
hold off
title("Solidity", 'FontSize', 18);
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
