Image Segmentation Using K means

1 visualización (últimos 30 días)
Octa
Octa el 29 de Jun. de 2013
Comentada: Walter Roberson el 31 de Dic. de 2018
When I execute the following command in Matlab 2012a
centroid=kmeans(imread('image.jpg'),4);
I get the following error
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in kmeans>distfun (line 659)
*D(:,i) = D(:,i) + (X(:,j) - C(i,j)).^2;*
*Error in kmeans (line 273)*
*D = distfun(X, C, distance, 0, rep, reps);*
I need to segment this image into 4 cluster. This image is a CT Brain tumour Image. Size of this image is 233 x 216. Please give me a solution to cluster this image file.

Respuestas (3)

Walter Roberson
Walter Roberson el 29 de Jun. de 2013
YourImage = imread('Image.jpg');
centroid = kmeans(double(YourImage), 4);
Note: if your .jpg is color rather than greyscale, you will probably need to convert it to greyscale before clustering.
  5 comentarios
syed salma banu s
syed salma banu s el 31 de Dic. de 2018
sir i need to cluster the image based on intensity of pixels e.g. i want 3 gray level classes
Walter Roberson
Walter Roberson el 31 de Dic. de 2018
convert the image to grayscale and kmeans requesting 3 clusters .

Iniciar sesión para comentar.


moahaimen talib
moahaimen talib el 10 de Abr. de 2017
hi i need to use kmean for segmenting and clustering a binary image please help

Gebra maryam Alehegn
Gebra maryam Alehegn el 1 de Mayo de 2017
How to correctly culsture image using k menas?

Community Treasure Hunt

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

Start Hunting!

Translated by