![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342151/image.png)
Controlling colour selections when using "labeloverlay"
7 ビュー (過去 30 日間)
古いコメントを表示
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 min: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/340081/image.jpeg)
![time = 488](https://www.mathworks.com/matlabcentral/answers/uploaded_files/340078/time%20=%20488.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/340081/image.jpeg)
0 件のコメント
回答 (1 件)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342151/image.png)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!