How to compute centroidal distances

2 次查看(过去 30 天)
I wanted to compute centroidal distances, by calculating the distance is between the geometric centroid of the segmented object and the brightness centroid of the same.
% Is geometric centroid same as
s = regionprops(BW,'centroid');
what is brightness centroid

采纳的回答

Matt J
Matt J 2018-1-3
编辑:Matt J 2018-1-6
I assume you mean regionprops(BW, I ,'WeightedCentroid') ? You need an intensity image I, to invoke that option.

更多回答(1 个)

Image Analyst
Image Analyst 2018-1-6
You can use regionprops() and sqrt(), like this untested code:
props = regionprops(binaryImage, grayImage, 'Centroid', 'WeightedCentroid');
% Extract centroids into x and y from structure.
centroids = [props.Centroid];
xCentroids = centroids(1:2:end);
yCentroids = centroids(2:2:end);
weightedCentroids = [props.WeightedCentroid];
xWeightedCentroids = weightedCentroids(1:2:end);
yWeightedCentroids = weightedCentroids(2:2:end);
% Compute distances between the centroids and the weighted centroids.
distances = sqrt((xCentroids - xWeightedCentroids) .^2 + (yCentroids - yWeightedCentroids) .^ 2);

类别

Help CenterFile Exchange 中查找有关 Feature Detection and Extraction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by