please, how do we give each region a color after the segmentation ?

5 views (last 30 days)

Answers (2)

Guillaume
Guillaume on 17 Nov 2018
label2rgb is one way to do it.

Image Analyst
Image Analyst on 17 Nov 2018
Try this:
labeledImage = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
% labeledImage is an integer-valued image where all pixels in the blobs have values of 1, or 2, or 3, or ... etc.
imshow(labeledImage, []); % Show the gray scale image.
title('Labeled Image, from bwlabel()', 'FontSize', captionFontSize);
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
where "binaryImage" is your segmented image, or possibly you've already labeled it and labeledImage is your segmented image.

Categories

Find more on Image Processing Toolbox 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!