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

조회 수: 1 (최근 30일)
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 2019년 11월 26일
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|) ;

Community Treasure Hunt

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

Start Hunting!

Translated by