MATLAB Answers

How can I get the angle between centroid of a binary object and a point on it's boundary?

조회 수: 2(최근 30일)
Casio Uploader
Casio Uploader 26 Nov 2019
Answered: KSSV 26 Nov 2019
How to calculate angle between centroid of a binary object and a point on it's boundary?
For example as in attached figure I want the angle between 'a' and centrioid is near to "0 degree" and for 'b' it will be near to "45 degree (maybe 42 or 40)"

답변 수 (1)

KSSV
KSSV 26 Nov 2019
Get the centorid of the image by using mean. So I assume you know all the points A,B,C,D and O. You have (x,y) in hand. If you want angle w.r.t x-axes..simply find slope and get tan inverse of it.
th = atan((y2-y1)/(x2-x1)) ;
If you want angle between two lines...say OA and OB, ude dot product.
cos(th) = oa.ob/(|oa|*|ob|) ;

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by