K-means clustering ignoring zero values
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an image with a large number of zeros. I am trying to use the kmeans clustering but I would like to ignore those zero values. Does someone know how to do it? Tks
2 commentaires
Image Analyst
le 30 Oct 2012
That doesn't make sense. How are you doing kmeans on the image? Where did you upload your image to so we can see what you're talking about? Are you trying to group non-zero pixels according to spatial location? If so, have you tried using morphology like imclose() and imreconstruct()?
Réponses (1)
Tom Lane
le 1 Nov 2012
In that demo clustering is performed on the variable ab, then the result are reshaped and put into the variable pixel_labels.
I don't have the Image Processing Toolbox handy at the moment. But I would create a variable idx that is the row numbers of ab that are not all zero. Then I would create an output pixel_labels as zeros of the proper shape. Then I would store the result of clustering ab(idx,:) into pixel_labels(idx).
Try it, then tell me if I'm wrong.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!