MATLAB Answers

Translated by

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

0

How can I rotate the lines on an image

Kel Alaike さんによって質問されました 2019 年 3 月 12 日
最新アクティビティ Kel Alaike さんによって コメントされました 2019 年 3 月 15 日
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 件のコメント

Adam Danz
2019 年 3 月 12 日
It's unclear (to me) what you're asking.
Kel Alaike 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?
Adam Danz
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
回答者: Rik
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
r_pad=50;%distance between parallel lines
I=phantom(250);%random image
r_outer=r_inner+r_pad;
theta=0:30:360;
[x1,y1]=pol2cart(deg2rad(theta),r_inner);
[x2,y2]=pol2cart(deg2rad(theta),r_outer);
figure(1),clf(1)
imshow(I)
hold on
plot(x1+center(1),y1+center(2))
plot(x2+center(1),y2+center(2))
hold off

  2 件のコメント

Rik
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 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
Parallel-beam-geometry.png
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
[x1,y1]=pol2cart(deg2rad(theta),L1)
[x2,y2]=pol2cart(deg2rad(theta),L2)
[x3,y3]=pol2cart(deg2rad(theta),L3)
[x4,y4]=pol2cart(deg2rad(theta),L4)
[x5,y5]=pol2cart(deg2rad(theta),L5)
[x6,y6]=pol2cart(deg2rad(theta),L6)
figure(1),clf(1)
imshow(I)
hold on
plot(x1+center(1),y1+center(2))
plot(x2+center(1),y2+center(2))
plot(x3+center(1),y3+center(2))
plot(x4+center(1),y4+center(2))
plot(x5+center(1),y5+center(2))
plot(x6+center(1),y6+center(2))
hold off

サインイン to comment.



Translated by