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

3 visualizaciones (últimos 30 días)
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)"

Respuestas (1)

KSSV
KSSV el 26 de Nov. de 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|) ;

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by