How to find the center to contour angle in matlab

4 ビュー (過去 30 日間)
Atreyee Mondal
Atreyee Mondal 2019 年 11 月 7 日
コメント済み: darova 2019 年 11 月 8 日
Hi, I am completely new to matlab.
Please guide me how can I find center to contour angle (in degree) for each contour pixel?
Suppose I have an input image like bell-12.gif. Now, I know the centeroid of it. Say suppose[110,99]. I also know the boundary pixel array of bell-12.gif. Now I want to calculate the angle between centroid to each boundary pixel and store it into an array Angle. How can I find the Angle array?
I tried the following code by fixing one angle:
for i=1:lob-1
x = [cents1(1) cents1(2)]; % common point
y = [boundary(1,1),boundary(1,2)];
a = [cents1(1) cents1(2)]; % common point
b = [boundary(i,1) boundary(i,2)];
CCDANG(i)=(atan((y(2)-x(2))/(y(1)-x(1))) - atan((b(2)-a(2))/(b(1)-a(1)))) * 180/pi;
This gives me negative value for angle. I am not sure what exactly is the way to solve it.
  4 件のコメント
darova
darova 2019 年 11 月 7 日
Where is the angle?
Atreyee Mondal
Atreyee Mondal 2019 年 11 月 7 日
kindly consider this diagram .

サインインしてコメントする。

回答 (1 件)

darova
darova 2019 年 11 月 7 日
  • Use edge to detect contour
  • find (x,y) coordinates (remember x - columns, y - rows)
  • coordinates need to be sorted (hint: divide them into 2 groups - x < x0 and x >= x0 then sort by y)
  • use interparc to interpolate data if needed
  • calculate angles
  2 件のコメント
Atreyee Mondal
Atreyee Mondal 2019 年 11 月 8 日
Thank you. I tried to find the angle by fixing a boundary point but is gives negative angular value . Here I am attaching my code:
for i=1:lob-1
x = [cents1(1) cents1(2)]; % common point
y = [boundary(1,1),boundary(1,2)];
a = [cents1(1) cents1(2)]; % common point
b = [boundary(i,1) boundary(i,2)];
CCDANG(i)=(atan((y(2)-x(2))/(y(1)-x(1))) - atan((b(2)-a(2))/(b(1)-a(1)))) * 180/pi;
darova
darova 2019 年 11 月 8 日
I thought you want angle between tangents
123.png
Can't you just change the sign? Is the value correct? Only sign is wrong?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by