compute centroid of a matrix
69 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Elysi Cochin
am 9 Jun. 2014
Beantwortet: David Lieberman
am 10 Aug. 2017
how to compute centroid of a matrix? is it possible?
0 Kommentare
Akzeptierte Antwort
Matt J
am 9 Jun. 2014
Bearbeitet: Matt J
am 9 Jun. 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 Kommentare
Weitere Antworten (1)
David Lieberman
am 10 Aug. 2017
x = sum(sum(matrix).*(1:size(matrix,2)))/sum(sum(matrix))
y is computed similarly
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!