Sort clusters using K-means by intensity
Mostrar comentarios más antiguos
Hello everyone. I am using K-means to segment some grayscale images. Unfortunately, the values of the generated clusters are not repeatable, i.e. every time I run the code the clusters have a different value. For example, if I use k=2 sometimes the darker areas of the original image have a cluster value of 1 and sometimes 2 (before normalisation). How to sort/order the generated clusters to have a value corresponding to the actual grayscale intensities, i.e. darkest = 1, less dark = 2,... brightest = k ? Thanks. Here is the code:
% Clustering.
clustered = reshape(kmeans(inputimage(:), k), size(inputimage));
% Normalise intensities from 0 to 1.
clustered = clustered - min(clustered(:));
clustered = clustered / max(clustered(:));
1 comentario
Xen
el 29 de Mayo de 2015
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre k-Means and k-Medoids Clustering en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!