How does the function imsegkmeans compute distance?

50 visualizaciones (últimos 30 días)
Tao Hu
Tao Hu el 8 de Nov. de 2024 a las 7:50
Editada: Tao Hu el 10 de Nov. de 2024 a las 22:23
I know imsegkmeans can do color-based clustering but I wonder how it is implemented. Specifically, how does it compte the distance between two pixels in the image? What distance does it use? I tried stepping into the code to see details but found it used an internal function:
images.internal.ocvkmeans(X,k,NumAttempts,MaxIterations,Threshold)
And I couldn't step into the "ocvkmeans" function. Can anyone tell me what distance it uses for distance?
Thanks!

Respuestas (1)

Sumukh
Sumukh el 8 de Nov. de 2024 a las 9:02
Kindly refer to the following MATLAB Answer where a staff member has answered that the “imgsegkmeans” and “kmeans” functions use similar algorithms under the hood:
The functionality of “imgsegkemeans” is to cluster the images based on the colour of each pixel of that image. As it uses k-means clustering to achieve this, you can refer to the following documentation where the algorithm for k-means clustering has been explained along with the way the distances are computed and used:
I hope this answers your query.
  6 comentarios
Walter Roberson
Walter Roberson el 10 de Nov. de 2024 a las 20:05
The code is very likely doing
Temp = reshape(TheImage, size(TheImage,1)*size(TheImage,2), []);
[IDX, Centers] = kmeans(Temp);
DGM
DGM el 10 de Nov. de 2024 a las 21:31
Editada: DGM el 10 de Nov. de 2024 a las 21:35
It reshapes the data, but it calls ocvkmeans()
[Label,NormCen] = images.internal.ocvkmeans(X,k,NumAttempts,MaxIterations,Threshold);
... which appears to be undocumented. IPT internals grabcut() and algkmeans() appear to be the only things that use it.

Iniciar sesión para comentar.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by