MATLAB: Zooming narrow image should fill axes

axesimshowzoom

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

Best Answer

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.