フィルターのクリア

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

5 ビュー (過去 30 日間)
SUKUMAR NAGINENI
SUKUMAR NAGINENI 2019 年 9 月 19 日
コメント済み: Image Analyst 2019 年 9 月 21 日
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

回答 (1 件)

Image Analyst
Image Analyst 2019 年 9 月 19 日
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 件のコメント
Arijit Chattopadhyay
Arijit Chattopadhyay 2019 年 9 月 20 日
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 2019 年 9 月 21 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by