필터 지우기
필터 지우기

Zooming narrow image should fill axes

조회 수: 13 (최근 30일)
Daniel Terry
Daniel Terry 2017년 11월 6일
편집: DGM 2022년 11월 6일
Hello,
When using imshow to display an narrow image in symmetric axes, zooming in maintains the same aspect ratio, resulting in a very narrow view of the image. The desired behavior is for the image to fill the entire axes at high zoom so more details are visible. Is there any way to alter the zoom behavior to achieve this effect?
Here is some example code that reproduces the problem:
figure; axes('Position',[0.1 0.1 0.8 0.8]);
RGB = imread('peppers.png');
strip = RGB(150:180,:,:);
imshow(strip);
Thank you for your help

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 7일
편집: Walter Roberson 2017년 11월 7일
Instead of using imshow(), use image() with "axis equal".
Some of prominent volunteers think highly of imshow(), but in my experience it has too many side effects for anything other than casual interactive viewing.
  댓글 수: 2
Daniel Terry
Daniel Terry 2017년 11월 7일
Thank you, this has resolved the issue. I wasn't aware of image() or the limitations of imshow().
DGM
DGM 2022년 11월 6일
편집: DGM 2022년 11월 6일
This. MIMT imshow2() was my workaround for the terrible viewport handling and cumbersome controls (and for the fact that imshow() used to require IPT). It fills the available area a bit better than using the 'axes equal' trick does, even with axes position set to [0 0 1 1].
Of course, it's hard to recommend after R2018a, since it doesn't play nice if the user tries to also use the view controls in the floating axes toolbar. I still think the new view controls are clumsier than what akZoom() offers, so the change doesn't really bother me. Maybe I should get around to fixing it again.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by