Colormap for Connected Components in an image

2 ビュー (過去 30 日間)
CuriousThinker
CuriousThinker 2016 年 2 月 27 日
コメント済み: CuriousThinker 2016 年 3 月 13 日
Hello all,
Is there a way I can assign individually different colors to the connected components obtained using bwareafilt() function, labeled in an image? I have tried using colormap() function. But it doesn't work.
Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2016 年 2 月 27 日
Yes. See this snippet from my Image Segmentation Tutorial:
% 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)
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', 20);
  4 件のコメント
CuriousThinker
CuriousThinker 2016 年 3 月 7 日
Thank you once again, Image Analyst. The method you advised me works. Great. But while it colors the selected labels with different colors, it just colors a corner of them instead of coloring them in full, or at least a good part of them. Could you please advice me which direction to take to improve their performance? Thanks.
Image Analyst
Image Analyst 2016 年 3 月 7 日
I don't see how it could color just a corner of the squares since the square is a solid color throughout. You'll have to share your code for me to fix it.

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

その他の回答 (1 件)

CuriousThinker
CuriousThinker 2016 年 3 月 13 日
編集済み: CuriousThinker 2016 年 3 月 13 日
Thank you, Image Analyst for your kind reply. Could you please advice me how to share the code privately?
  2 件のコメント
Image Analyst
Image Analyst 2016 年 3 月 13 日
No.
CuriousThinker
CuriousThinker 2016 年 3 月 13 日
Sorry, Sir. I just meant if there is a way I can upload, still not shown publicly in the discussion.Thank you very much for the help. If there is no way, please tell me. I will upload my code here.

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

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by