MATLAB: Display image in axes Matlab GUI.

Image Processing Toolbox

Hello!
I want to display an image in an axes Matlab GUI. Therefore, I selected an axes and a button to trigger the moment. In the button function I wrote:
myImage = imread('as.jpg');
axes(handles.axes7);
imshow(myImage);
The problem is that the image doesn't cover the all surface of the axes. Is it displayed little in the center of the axes. How can I display my image on entire surface of the axes?
Thank you!

Best Answer

this indeed means that the size of your image is much smaller than the size of your axes. To make it work on different computers (with different resolutions) and if you have set all units to normalized to obtain this you can use this code to circumvent the problem:
myImage = imread('as.jpg');
set(handles.axes7,'Units','pixels');
resizePos = get(handles.axes7,'Position');
myImage= imresize(myImage, [resizePos(3) resizePos(3)]);
axes(handles.axes7);
imshow(myImage);
set(handles.axes7,'Units','normalized');