Controlling colour selections when using "labeloverlay"

조회 수: 11 (최근 30일)
Sam Yu
Sam Yu 2020년 7월 31일
답변: Rishik Ramena 2020년 8월 6일
Hi, I've applied kmeans clustering to a batch of images, and I am using "labeloverlay" to display the results. However, I am finding that the colours in each picture varies significantly (see attached outptuts). For better comparison effects, I am wondering if it is possible to manually assign colours to different clusters of each picture? For example, I want to keep the background cluster of each image to be green.
time = 0 min:time = 488 time = 488 min:

답변 (1개)

Rishik Ramena
Rishik Ramena 2020년 8월 6일
As per my understanding, you are trying to have a custom color scheme for the clusters(labels) generated using K-Means. You can use the Colormap paramenter for labeloverlay function. For further details and examples, refer to the Create Custom Colormap documentation. Here’s a snippet with a simple implementation.
A = imread('coins.png');
t = im2bw(A)+1;
B = labeloverlay(A,t,'Colormap',[1 0 0; 0 0.9 0]);
imshow(B)

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by