Controlling colour selections when using "labeloverlay"

9 views (last 30 days)
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:

Answers (1)

Rishik Ramena
Rishik Ramena on 6 Aug 2020
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)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!