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

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

채택된 답변

Akira Agata
Akira Agata 2019년 12월 6일
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

추가 답변 (0개)

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!