How to get a color image with labeling from a binary image?

17 vues (au cours des 30 derniers jours)
SUKUMAR NAGINENI
SUKUMAR NAGINENI le 19 Sep 2019
Commenté : Image Analyst le 21 Sep 2019
Dear sir,
We have a dilated image (binary image), we need to convert it into a color image with the labelling. Anyone can help me to get this color image with labelling? if you a have any idea, please let me know about it.
Dailated color image output labeling
Thanks

Réponses (1)

Image Analyst
Image Analyst le 19 Sep 2019
Here is a snippet from my Image Segmentation Tutorial:
% Identify individual blobs by seeing which pixels are connected to each other.
% Each group of connected pixels will be given a label, a number, to identify it and distinguish it from the other blobs.
% Do connected components labeling with either bwlabel() or bwconncomp().
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.
subplot(3, 3, 4);
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
% coloredLabels is an RGB image. We could have applied a colormap instead (but only with R2014b and later)
subplot(3, 3, 5);
imshow(coloredLabels);
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
caption = sprintf('Pseudo colored labels, from label2rgb().\nBlobs are numbered from top to bottom, then from left to right.');
title(caption, 'FontSize', captionFontSize);
Adapt as needed.
  2 commentaires
Arijit Chattopadhyay
Arijit Chattopadhyay le 20 Sep 2019
Dear Sir,
In Simulink,in matlab function block when we use this code,it shows an error as: "In code generation, LABEL2RGB does not support colormap functions for MAP".
Image Analyst
Image Analyst le 21 Sep 2019
It works in MATLAB. I don't have Simulink so it it works differently there, then I don't know - you'll just have to look at the documentation as to how to specify a colormap for the different/unique blobs.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Red dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by