How can I measure an angle between center and pixel?

12 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 28 Ago 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.

Più risposte (0)

Categorie

Scopri di più su Images in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by