필터 지우기
필터 지우기

How can I measure an angle between center and pixel?

조회 수: 6 (최근 30일)
Dominika Krason
Dominika Krason 2021년 8월 28일
답변: Image Analyst 2021년 8월 28일
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