MATLAB Answers

keeping original size of image when using imagesc

4 views (last 30 days)
Mara Fries
Mara Fries on 28 Nov 2020
Commented: Mara Fries on 29 Nov 2020
I'm programming a GUI and trying to show an image using imagesc. The GUI should be able to show images of different sizes. I put axes with a specific size in there but it's more of a placeholder - I'd like to change its size depending on the size of the image being displayed.
So for example I'm having the figure window with a rectangular shape but want to show a squared image without it being streched to fit the window, I hope I got my problem across. It does work when im using imshow, then the image keeps its original size automatically, but it doesn't when I'm using imagesc to display the image.


Sign in to comment.

Accepted Answer

M.Many on 28 Nov 2020
Hi, you can use
axis image
to keep the ratio 1 to 1
I hope this helps

  1 Comment

Mara Fries
Mara Fries on 29 Nov 2020
Yes, that works, thank you so much for the quick help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!