How can I measure an angle between center and pixel?

11 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2021-8-28
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.

更多回答(0 个)

类别

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

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by