MATLAB: display image in original size

Can we show the image in its original size in MATLAB?

Right now, when we show, it exactly matches the size of the image window. However, I want to show the image in its original size. When the image is larger, a scroll bar should appear in the image window. This will allow the user to view the image in its original size.

Any ideas on how to achieve this? Is it possible?

+6
image matlab
source share
3 answers

I believe that you are looking for the IMTOOL utility (which is part of the Image Processing Tool ). This is the MATLAB graphical interface, which allows you to view images in their original size (100% increase) with horizontal and vertical sliders.

EDIT:

The above solution will display your image in a new figure window (IMTOOL GUI). If you do not want the image to appear in a new window, but instead you need to adjust its size in your own window, it will be more difficult. To adjust the size of the image, which I assume you have displayed on multiple axes using the IMAGE command, you will have to adjust the number of axes for the axes containing the image. The following are the properties you are likely to end up changing:

  • 'Units' : This can be set, for example, to 'inches' , 'centimeters' or 'pixels' .
  • 'Position' : This determines where the axes are placed in the drawing window, in units controlled by the 'Units' property.
  • 'DataAspectRatio'/'PlotBoxAspectRatio' : they control the relative scaling of the axes and the surrounding graph.
  • 'XLim'/'YLim' : minimum and maximum axis values.

After obtaining the size and scaling of the image to display as you want, parts of the image may be outside the area of ​​the figure window. Unfortunately, horizontal and vertical sliders will not be automatically added. You will need to create these slider controls yourself using the UICONTROL function. You will need to write callback functions for the slider controls so that they move the axes around the window.

If you decide to abandon the above path, here are some links to GUI design guides that may help you: a blinkdagger slider tutorial , a Doug Hull blog post and a video from the Doug on GUIDE basics .

+8
source share

There is a problem in the Matlab slider related to the callback only on MouseUp and not on MouseMove, so a pure matlab implementation will always be strange.

The best way is to switch to Java in Matlab. This way you don't have to re-execute the whole scroll logic. You can put the Java Swing GUI component inside the Matlab window, this is not at all complicated.

In particular, you should use the Swing JScrollPane Class. Using the Matlab javacomponent() function, you can put it in the Matlab window.

There are several examples on the Internet of how to get an image in the scroll pane, just check out the JScrollPane image . You can use Java classes inside matlab with the usual Matlab syntax (no new , ecc. Key needed)

+2
source share

try: figure, imshow (your_image), image axis This changes the image axis to its original size

+1
source share

All Articles