Colormap for Connected Components in an image
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!