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

3 次查看(过去 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|) ;

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by