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

8 visualizaciones (últimos 30 días)
SUKUMAR NAGINENI
SUKUMAR NAGINENI el 19 de Sept. de 2019
Comentada: Image Analyst el 21 de Sept. de 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

Respuestas (1)

Image Analyst
Image Analyst el 19 de Sept. de 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 comentarios
Arijit Chattopadhyay
Arijit Chattopadhyay el 20 de Sept. de 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 el 21 de Sept. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by