Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to show the zoom arround the mouse in subfigure window?

1 vue (au cours des 30 derniers jours)
Meshooo
Meshooo le 28 Sep 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
Dear all,
I want to have a figure with two subfigures such that in one subfigure the input image is shown, while in the other subfigure a live zoom is shown at the mouse position.
I am using this code but seems I don't have a correct control of the subfigure handles.
I = imread('cameraman.tif');
handleIN = subplot(1, 2, 1);
imshow(I);
pointersize = 30;
handles.side_pointer = scatter(nan, nan, pointersize, 'y', 'Marker', '*');
C = get (handleIN, 'CurrentPoint');
X = C(1,1);
Y = C(1,2);
[H W] = size(I);
if X>W;
X = W-(2*W);
end
if Y>H;
Y= H-(2*H);
end
%zoom around the mouse
zoomwidth = 100;
xleft = max(0, X-zoomwidth/2);
ybot = max(0, Y-zoomwidth/2);
hold on
handle = subplot(1, 2, 2);
set(handle,'HandleVisibility','ON');
set(handle, 'XLim', [xleft xleft+zoomwidth], 'YLim', [ybot ybot+zoomwidth]);
imshow(I)
hold off
drawnow();
Any idea how to make it works?
Best, Meshoo

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by