Hello,
Im a new user of matlab. Im making a project for card detection, and I need average centroid of all objects in a binary image. I am using a function for this calculation and i get the error that Index exceeds matrix dimensions.
Here is the function
function [averageDist, averageCentroid] = averageCentroidDistance(centroids) averageCentroid = mean(centroids); x = averageCentroid(1); y = averageCentroid(2); hold on totalDist = 0; for i = 1:size(centroids, 1) X = [y, x; centroids(i,:)]; d = pdist(X,'euclidean'); totalDist = totalDist + d; end averageDist = totalDist / size(centroids, 1);end
In the error it says that y exceeds the matrix dimensions.
Best Answer