MATLAB Answers


"imshow" distorts jpeg

Asked by Matt
on 15 Jan 2013

I am using the following code to display an image on an axis in a Matlab GUI.

axes(handles.axis1); imshow('my_image.jpg');

This is distorting my image. (There is text on the image which becomes difficult to read). However it seems that Matlab is trying to keep the dimension ratio, because stretching the axis in one direction does not change the output of imshow at all.

I have tried using XData and YData to manually resize the jpeg, with limited success. If I open the jpeg directly, it looks perfect, so it must be something Matlab is doing.

Does anyone have any suggestions? I don't really have a firm grasp on what Matlab is doing when I call the imshow function, so please point out of I'm completely off-base. Thanks.



Are you being given a warning about the image being too large to view?

on 15 Jan 2013

Thanks for the reply. There is no warning.


No products are associated with this question.

2 Answers

Answer by Image Analyst
on 15 Jan 2013
 Accepted answer

It "shrinks to fit" the image into your axes. This means that it might subsample your image and lose some pixels, causing it to look bad. Try using a bigger axes, or maybe you can play around with the 'InitialMagnification' option for imshow(), or try using zoom().


Answer by Jurgen
on 15 Jan 2013

Are you displaying at the proper size? fine detail can be lost (aliasing) if your display size is too small, try maximizing it with e.g.:



on 15 Jan 2013

I tried this but it created a new figure. I want the image to appear in an axis that is on my GUI. Although, the image displayed in the new figure window did NOT seem to be distorted, so perhaps you're on to something.

on 15 Jan 2013

Yes obviously the new figure was because I thought your axis was too small. Just a test, guess it was right.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!