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

3 views (last 30 days)
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)"

Answers (1)

KSSV
KSSV on 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|) ;

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!