Set image aspect ratio using imshow

조회 수: 21 (최근 30일)
Gerard Capes
Gerard Capes 2017년 8월 18일
댓글: Adam 2017년 8월 18일
I am trying to load an image (screenshot of a graph), and plot my data on top. I have achieved this, but the aspect ratio of the displayed image/graph doesn't look to be adjustable. Can it be done?
% Load cleaned up screen shot.
load image.mat
% Observe aspect ratio.
imshow(I)
% Flip matrix so that y axis origin is at the bottom instead of the top.
I = flipud(I);
% Scale image to allow plotting on top - this works, but changes the aspect ratio.
RI = imref2d(size(I));
RI.XWorldLimits = [1970 2020];
RI.YWorldLimits = [320 410];
figure;
imshow(I,RI);
set(gca,'YDir','normal');

채택된 답변

Adam
Adam 2017년 8월 18일
  댓글 수: 2
Gerard Capes
Gerard Capes 2017년 8월 18일
Great, thanks! Easy when you know where to look! I do wonder why it changed the aspect ratio in the first place?
Adam
Adam 2017년 8월 18일
I'm not aware of any overload of imshow that takes an imref2d as 2nd argument. Is this an overload from a toolbox?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by