How to rotate a line using Matlab?

52 ビュー (過去 30 日間)
Makrim
Makrim 2015 年 5 月 16 日
編集済み: Habtamu Tesfaw 2021 年 3 月 12 日
Suppose I have an image I and a line h1. Using Matlab, I can draw the line (or segment) like this (in red) :
h1 = plot( [l1 l1],[20 100], 'r');
Now I want to rotate the image I with an angle of 45°. So I used imrotate like this:
IR = imrotate(I,45);
Now, I want to rotate the line, how to do that using Matlab ?
PS: I found the function rotate. I am trying this, but it is not working !
rotate(h1,[1 1],45);

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 16 日
imrotate() rotates an entire image, not a line you created with line() or plot(). You need to take your points and multiply by the rotation matrix - you know, the sin and cos thing you learned in your linear algebra class in college. Then call line() or plot() again with the rotated coordinates.
  1 件のコメント
Makrim
Makrim 2015 年 5 月 16 日
it worked for the two points of the line ... thank you

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

その他の回答 (1 件)

Habtamu Tesfaw
Habtamu Tesfaw 2021 年 3 月 12 日
編集済み: Habtamu Tesfaw 2021 年 3 月 12 日
here is a simple package that can do the job '
https://www.mathworks.com/matlabcentral/fileexchange/88748-lrotate?s_tid=srchtitle

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by