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 CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by