Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Meshooo
Meshooo am 28 Sep. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 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

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by