フィルターのクリア

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 Center および File ExchangeImages についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by