How to use kmeans for an image

조회 수: 1 (최근 30일)
Mathew Cherian Carathedathu
Mathew Cherian Carathedathu 2011년 12월 19일
Hi..
I need to apply kmeans clustering for a grayscale image (the clustering should be based on the value of the pixels and not the distance). I tried to apply the inbuilt function to do that but the documentation says I will get only a n-by-1 vector as the output. How do I then get the cluster values for each of the pixels?
Thank you,
Mathew

채택된 답변

Image Analyst
Image Analyst 2011년 12월 19일
Here's an example that you should be able to modify from color to grayscale rather easily: http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 19일
What do you mean by "the cluster values" ? kmeans() returns the cluster number for each point (each row is considered a point) as the first output. That kmeans() cannot return the cluster probabilities, but the four-output version will return the distance from each point to each centroid.

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by