How to zoom out further (using image/imshow)
37 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have been working on a set of GUI tools that incorporate one or more axes for image viewing. One frustration has always been the inefficient view control behavior of IMSHOW when zooming. If my axes and image have contrary aspect ratios (one is short and wide and the other is tall and narrow), zooming in on an image doesn't allow the user any better use of the space defined by the parent axes. The effective viewport aspect ratio (abs(diff(xlim))/abs(diff(ylim)) remains the same no matter the zoom level. In any other image editing application, zooming such an image will fill the unused space in the axes until the displayed region and axes have the same aspect ratio.
So far, my approach has been to use a callback function (actionpostcallback) on each zoom event. If there is a mismatch of aspect ratios between the viewport and axes, i can scale the viewport in accordingly. This only changes anything when zooming in the first time. After this, the two aspect ratios are the same, and the ability to zoom out to the initial zoom level is unpredictable.
In R2009b, the normal gui zoom tools (zoom in/out or scroll wheel) can't zoom out further than the initial zoom level. In normal use, this works fine because the viewport aspect ratio never changes. Whichever dimension it's using to limit the scaling doesn't matter. But since I'm changing the viewport and i can never seem to predict whether it's Xlim or Ylim which will be clamped by the plot/zoom/graphics routines, I often can't zoom back out.
I can see a couple of ways which I could solve this issue:
1: If my callback function were able to know what zoom level was attempted but disallowed, I could make it zoom out manually. I don't know how I'd get that information in a callback that occurs after the zoom event. All I can hope to detect is that geometry stops changing between calls.
2: If I were able to find a way to change the "can't zoom further out" behavior, this could all be managed easily. I'm pretty sure that's not a trivial thing. In R2015b, one can easily zoom out further than the initial zoom factor, but I imagine that's a consequence of a lot of changes to the graphics handling routines.
3: Pad every image such that it has the same aspect ratio as the axes.
4: Do something entirely different.
I'm not sure this has been a clear problem description. I feel I almost need a video to show what happens, and I didn't want to post a mess of code. If anyone has any insight, it would be appreciated. If anyone wants further details, I can add them.
0 Commenti
Risposta accettata
Image Analyst
il 18 Lug 2016
You're not using api calls. See the Mathworks image zooming demo. You'll see you can change the aspect ratio. You're not stuck using the aspect ratio of the original image forever.
1 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Visual Exploration in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!