Effacer les filtres
Effacer les filtres

How can I measure an angle between center and pixel?

6 vues (au cours des 30 derniers jours)
Dominika Krason
Dominika Krason le 28 Août 2021
Hi, im doing a little detection project but Ive stumbled upon some issues I cant quite figure out.
My program detects wanted circle and marks the center but 1. the Y-axis values increase from top to bottom and 2. I tried measuring an angle between the X-axis and the found center using 'atan2d' but I can't make it work like I need to.
In the image I drew in blue lines how the angle is detected right now and in red and green how I need it to be detected from the center point of the screen.
I'd be thankfull for any advice on the matter.

Réponse acceptée

Image Analyst
Image Analyst le 28 Août 2021
Find the centroid of the blob and the image, get delta y and delta x, and use arctand(). Something like
mask = bwareafilt(mask, 1); % Take largest blob only.
[rows, columns] = size(mask);
xci = columns/2; % Image centroid.
yci = rows/2;
props = regionprops(mask, 'Centroid');
xbi = props.Centroid(1); % Blob centroid.
ybi = props.Centroid(2);
angle = atan2d(ybi-yci, xbi-xci)
Adapt as needed.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by