필터 지우기
필터 지우기

K-means Clustering for Color Grouping

조회 수: 2 (최근 30일)
Chandra Shekhar
Chandra Shekhar 2013년 1월 9일
I need to cluster different colors using k-means clustering algorithm.
when i use function like this with k=4 for 5 colors image.
[cluster_idx cluster_centre]=kmeans(inputImg,k,'distance','sqEuclidean','Replicates',3);
It will end up with empty cluster at iteration 1 and no partition. If i run multiple times,then at one time it will partition the colors .
then if i change above function like this [cluster_idx cluster_centre]=kmeans(inputImg,k); and then also end up with same result.
Why it showing like this even though image is having 5 colors..? How to debug this problem..? Does any one know please help me out.
Thank You.

채택된 답변

Image Analyst
Image Analyst 2013년 1월 9일
Have you seen the Mathworks demo: http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html. I don't have the stats toolbox so I can't help you debug it anymore.
  댓글 수: 2
Chandra Shekhar
Chandra Shekhar 2013년 1월 10일
I used same demo code, but still i am getting error.
In my program, i used color reduction image as a input to the 'kmeans'function.In that the image is having 5 colors and i need to group those colors by choosing k=4 or 5;
In demo program the direct input image is used as input to the kmeans function.
Does any one know please help me..
Thank You.
Image Analyst
Image Analyst 2013년 1월 10일
I can't help you because I don't have the stats toolbox. Perhaps you can call the Mathworks and ask why their demo returns 4 clusters (or 4 plus an empty 5th) when you're specifying 5 clusters.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by