Search code examples
matlabimage-processingmatlab-guidezoomingroi

How to Zoom in multi-axes in the same time in matlab GUI?


I have a GUI with two axes. The first one for original image while the second one is for interpolated image.

First in my code, I use imrect to select part of the original image and then I crop that part using imcrop . After that I display the cropped image in both axes.

What I want is to know how to zoom in the first axes (the original image) and it shows the same zooming the second axes ( interpolated image ) automatically.

Thanks a lot in advance.


Solution

  • It is not clear the relationship between the two actions you mention in your question:

    • using imrect and imcrop to work on the image

    • zooming on one axes and have the same zoom on the second

    A possible solution to automatically apply the zoom made on the first axes to the second one could be using the linkaxes built-in function.

    If in your GUI you have two axex with, respectively, tag axes1 and axes2, you can add the following statements in the GUI OpeningFcn

    linkaxes([handles.axes1 handles.axes2])
    

    This allows automatically applying the zoom you make on axes1 also to axes2.

    Hope this helps.