How to find the centroids and the angle between each of them?

Hi i found the centroids of the each white regions using regionprops. How can i find the distance and angle between each centroids and mark the points which are almost in straight line?

 Accepted Answer

Once you know the centroids as x-y coordinates, it is easy to find their distances and angles. Suppose A = [x1,y1], B = [x2,y2], and C = [x3.y3] are three centroid positions.
For example, the distance between A and B is:
distAB = sqrt((x2-x1)^2+(y2-y1)^2);
and the interior angle in triangle ABC at centroid B is:
angB = atan2(abs((x1-x2)*(y3-y2)-(x3-x2)*(y1-y2)),...
(x1-x2)*(x3-x2)+(y1-y2)*(y3-y2));

1 Comment

Sir can you guide me how I fuse/ combine two images . one image is 2d having dimensions 512x271 and other image is 3d having dimensions 512x271x512. I want to combine them to make one image . the output image have size 512x271x512

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!