Translated by このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

How can I rotate the lines on an image

Kel Alaike

Kel Alaike (view profile)

さんによって質問されました 2019 年 3 月 12 日

Kel Alaike (view profile)

さんによって コメントされました 2019 年 3 月 15 日
Rik

Rik (view profile)

さんの 回答が採用されました
Hey everyone I'm having trouble knowing how to rotate lines plotted on my image. I put in my code below.
Below when theta is changed the left axis changes value and the right axis changes value.
clc
%Horizontal lines @ 50 row spacing
a = [1 250];
b = [1 1]+R;
c = [50 50]+R;
d = [100 100]+R;
e = [150 150]+R;
f = [200 200]+R;
g = [250 250]+R;
%Rotation Matrix
theta = 0
R = [(+theta) (-theta)]
%Rotation of plots
Ha = [a;a];
Hb = [a;b];
Hc = [a;c];
Hd = [a;d];
He = [a;e];
Hf = [a;f];
Hg = [a;g];
%Rotation Matrix
P = phantom(250);
imshow(P)
hold on
plot(Hb',Ha'),plot(Hc',Ha'),plot(Hd',Ha'),plot(He',Ha'),plot(Hf',Ha'),plot(Hg',Ha')
plot(Ha',Hb'),plot(Ha',Hc'),plot(Ha',Hd'),plot(Ha',He'),plot(Ha',Hf'),plot(Ha',Hg')
hold off

3 件のコメント

2019 年 3 月 12 日
It's unclear (to me) what you're asking.
Kel Alaike

Kel Alaike (view profile)

2019 年 3 月 12 日
Sorry, so I have plotted parralel lines on my picture 50 pixels apart from eachother. What I need to do is rotate these parallel lines in increments of 10 degrees while keeping them the same width apart from eachother
How would I be able to get this done?

2019 年 3 月 12 日
So the rotated, parallel lines should be 50 pixels apart along the y or x axes or should they be 50 pixels apart orthogonally to their rotated orientation?

サインイン to comment.

1 件の回答

Rik (view profile)

2019 年 3 月 12 日
採用された回答

You can use code similar to that below. I changed the step size to 30 degrees to make it more clear what is happening.
clc
center=[120,120];%xy center of polygons
r_inner=20;%distance to center from inner polygon
I=phantom(250);%random image
theta=0:30:360;
figure(1),clf(1)
imshow(I)
hold on
plot(x1+center(1),y1+center(2))
plot(x2+center(1),y2+center(2))
hold off

Rik

Rik (view profile)

2019 年 3 月 14 日
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
Kel Alaike

Kel Alaike (view profile)

2019 年 3 月 15 日
Thanks for the response, I adapted what was suggested and have somewhat what I need, Is there any way to change these curved lines into straight lines across the image?
Like the image below, Thanks again for the patience centre=[125,1]
z=0 %distance to centre from line
Lspace=50 %distance between parallel lines
I=phantom(250) %random image
L1=z+(Lspace*0)
L2=z+(Lspace*1)
L3=z+(Lspace*2)
L4=z+(Lspace*3)
L5=z+(Lspace*4)
L6=z+(Lspace*5)
theta=0:30:360