Axes上に表示した画像を傾けたい

2 views (last 30 days)
koji fukumoto
koji fukumoto on 5 Dec 2019
Answered: Akira Agata on 6 Dec 2019
お世話になります。
Axes上に、imread関数で読み込んだpng画像をimage関数を用いて表示しています。
この画像を任意の角度傾ける方法が分かりません。
11.png
リファレンスを見る限り、imrotateを使うと出来そうな気がしますが、Toolboxを使わずに実装したいです。
rotate関数では思ったように傾けることができませんでした(軸に沿って回転してしまう)。

Accepted Answer

Akira Agata
Akira Agata on 6 Dec 2019
axesオブジェクトで、図の真上方向を示す CameraUpVector プロパティを回転させるのはいかがでしょうか?
ちなみに、2次元表示での CameraUpVector プロパティのデフォルト値は [0 1 0] ですが、imshowで画像を表示した場合はデフォルト値が [0 -1 0] になっていますのでご注意ください。
% Load image
I = imread('peppers.png');
% Show the image
figure
imshow(I)
% Set rotation angle
rotDeg = 20; % [deg]
rotRad = deg2rad(rotDeg); % [rad]
% Change CameraUpVector
ax = gca;
ax.CameraUpVector = [-1*sin(rotRad), -1*cos(rotRad), 0];
rotPepper.png

More Answers (0)

Categories

Find more on 幾何学的変換とイメージ レジストレーション in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!