Effacer les filtres
Effacer les filtres

value changes when running each time

2 vues (au cours des 30 derniers jours)
kash
kash le 5 Mar 2013
x=imread('im9.bmp');
HSV = rgb2hsv(x);
H = HSV(:,:,1); H = H(:);
S = HSV(:,:,2); S = S(:);
V = HSV(:,:,3); V = V(:);
idx = kmeans([H S V], 3,'distance','sqEuclidean');
tabulate(idx)
the percentage for each idx gets changed every time i run the program,whay i am getting like this,kindly assist
  3 commentaires
kash
kash le 22 Mar 2013
I used
idx = kmeans(reshape(HSV, [], 3), 3,'distance','sqEuclidean');
even then i get same error each cluster changes and different color is applied each time
Walter Roberson
Walter Roberson le 22 Mar 2013
kmeans still uses random initialization when you use reshape(), unless you provide the starting centroids like I showed below.

Connectez-vous pour commenter.

Réponses (1)

Youssef  Khmou
Youssef Khmou le 5 Mar 2013
Modifié(e) : Youssef Khmou le 5 Mar 2013
hi kash,
i quote , from Wikipedia : " Commonly used initialization methods are Forgy and Random Partition" so each time you run the code : Random partition is the cause of that small change , so here is what you can do :
you run the code 10 times , each time you store that variable, it is then a R.V calculate its mean and STD , and conclude .
  9 commentaires
Teja Muppirala
Teja Muppirala le 22 Mar 2013
Are you sure you have typed everything correctly?
x = imread('peppers.png');
HSV = rgb2hsv(x);
C=HSV(102:104,102:104);
idx = kmeans(reshape(HSV, [], 3),3,'distance','sqEuclidean','Start',C);
tabulate(idx)
For me, no matter how many times I run this, I always get the same result:
Value Count Percent
1 74013 37.64%
2 99481 50.60%
3 23114 11.76%
kash
kash le 22 Mar 2013
sorry the mistake i made was placed C inside single quotes,thanks

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by