フィルターのクリア

compute centroid of a matrix

69 ビュー (過去 30 日間)
Elysi Cochin
Elysi Cochin 2014 年 6 月 9 日
回答済み: David Lieberman 2017 年 8 月 10 日
how to compute centroid of a matrix? is it possible?

採用された回答

Matt J
Matt J 2014 年 6 月 9 日
編集済み: Matt J 2014 年 6 月 9 日
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(:))]

その他の回答 (1 件)

David Lieberman
David Lieberman 2017 年 8 月 10 日
x = sum(sum(matrix).*(1:size(matrix,2)))/sum(sum(matrix))
y is computed similarly

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by