How to calculate the centroid of these bounding boxes which their 4 vertices are stored in cell array?

조회 수: 5 (최근 30일)
How to calculate the centroid of these bounding boxes which their 4 vertices are stored in cell array?
The attached file is xy coordinates of the 4 vertices of the boxes.
The coordinates are in the order:
(left-bottom), (right-bottom), (left-top), (right-top).where each coordinate is an (x, y) pair.. i.e([x1 , y1], [x2, y2], [x3 , y3 ], [x4 , y4 ])
There are 23 bounding box vertices stored in the file.
-Also, I need any angle represents the inclination of whole box with respect to the horizontal x-axis
The output should be 23 angle each represents one box

채택된 답변

Matt J
Matt J 2022년 5월 12일
centroids = cellfun(@(z) mean(cell2mat(z(:))) ,c ,'UniformOutput' ,false)
  댓글 수: 6
M
M 2022년 5월 12일
편집: M 2022년 5월 12일
@Matt J, The coordinates are in the order:
(left-bottom), (right-bottom), (left-top), (right-top).where each coordinate is an (x, y) pair..
I need any angle represents the inclination of whole box with respect to the x-axis
The output should be 23 angle each represents one box
Image Analyst
Image Analyst 2022년 5월 13일
I don't understand. Box sides are perfectly aligned and parallel with the x and y axes. So what do you mean by angle? Bounding boxes are not inclined to the axes. An angle can be defined by 3 points : the vertex point, and the 2 end points of rays. How are you defining your angle? A diagram would be helpful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by