Effacer les filtres
Effacer les filtres

function kmeans is not able to process uint8 what should i do?

1 vue (au cours des 30 derniers jours)
Poonam
Poonam le 2 Mar 2015
Commenté : David Young le 2 Mar 2015
I am using kmeans function and getting following error
??? Error using ==> plus Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> kmeans>distfun at 704 D(:,i) = D(:,i) + (X(:,j) - C(i,j)).^2;
Error in ==> kmeans at 313 D = distfun(X, C, distance, 0);
What should i do know

Réponses (1)

David Young
David Young le 2 Mar 2015
Convert your date to double before passing it to kmeans. For example, if Xi is your uint8 data array,
Xd = double(Xi);
idx = kmeans(Xd, k);
If you have very large arrays and so run out of memory, consider using single instead of double.
  2 commentaires
Poonam
Poonam le 2 Mar 2015
done as you said but now getting ??? Error using ==> minus Number of array dimensions must match for binary array op.
Error in ==> kmeans>onlineUpdate at 557 Del(:,i) = (m(i) ./ (m(i) + sgn)) .* sum((X - C(repmat(i,n,1),:)).^2, 2);
Error in ==> kmeans at 324 converged = onlineUpdate();
David Young
David Young le 2 Mar 2015
Sorry, there isn't enough information to solve this new problem. I suggest you post a new question, showing the code that calls kmeans.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by