From: Ravi Rastogi on
Hi everyone,

I wanted to know if there is a way to zoom only on particular area in an image within user defined limits?
For example, suppose if the image is 300 X 300, and the area of interest is within
along x-axis: 58 to 112 and along y-axis: 225 to 275. Is there was way to just display this user defined part on the same window where original image was previously displayed?

Thanks

RAvi
From: ImageAnalyst on
On May 18, 2:50 pm, "Ravi Rastogi" <ravi...(a)gmail.com> wrote:
> Hi everyone,
>
> I wanted to know if there is a way to zoom only on particular area in an image within user defined limits?
> For example, suppose if the image is 300 X 300, and the area of interest is within
> along x-axis: 58 to 112 and along y-axis: 225 to 275. Is there was way to just display this user defined part on the same window where original image was previously displayed?
>
> Thanks
>
> RAvi

------------------------------------------------------------------------------------------------------------------------------------------
RAvi:
Sure. I set up a slider control where the user can control zoom.
When zoomed, there is a hand where the user can pan/scroll/move the
magnified image within the image viewport. Here's the code for the
zoom slider callback:
BE SURE TO JOIN ANY LINES SPLIT INTO TWO BY THE NEWSREADER.

% --- Executes on slider movement.
function sldZoom_Callback(hObject, eventdata, handles)
% hObject handle to sldZoom (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range
of slider
zoomFactor = get(hObject,'Value');
axes(handles.axesImage);
zoom('out');
zoom(zoomFactor);
txtInfo = sprintf('Zoom Factor = %.2f (%d %%)\n\nOnce zoomed, you
can pan by clicking and dragging in the image.', zoomFactor,
round(zoomFactor * 100));
set(handles.txtInfo, 'String', txtInfo);
txtInfo = sprintf('Zoom Factor = %.2f\n\nOnce zoomed, you can pan by
clicking and dragging in the image.', zoomFactor);
set(handles.sldZoom, 'TooltipString', txtInfo);
txtZoom = sprintf('Zoom Factor = %.2f (%d %%)', zoomFactor,
round(zoomFactor * 100));
set(handles.txtZoom, 'String', txtZoom);
% Set up to allow panning of the image by clicking and dragging.
% Cursor will show up as a little hand when it is over the image.
set(handles.axesImage, 'ButtonDownFcn', 'disp(''This executes'')');
set(handles.axesImage, 'Tag', 'DoNotIgnore');
h = pan;
set(h, 'ButtonDownFilter', @myPanCallbackFunction);
set(h, 'Enable', 'on');
return;