compute centroid of a matrix
69 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Elysi Cochin
el 9 de Jun. de 2014
Respondida: David Lieberman
el 10 de Ag. de 2017
how to compute centroid of a matrix? is it possible?
0 comentarios
Respuesta aceptada
Matt J
el 9 de Jun. de 2014
Editada: Matt J
el 9 de Jun. de 2014
If you have the Image Processing Toolbox,
regionprops(true(size(matrix)), matrix, 'WeightedCentroid');
Otherwise,
matrix=matrix/sum(matrix(:));
[m,n]=size(matrix);
[I,J]=ndgrid(1:m,1:n);
centroid=[dot(I(:),matrix(:)), dot(J(:),matrix(:))]
0 comentarios
Más respuestas (1)
David Lieberman
el 10 de Ag. de 2017
x = sum(sum(matrix).*(1:size(matrix,2)))/sum(sum(matrix))
y is computed similarly
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!