From: Wayne King on
"Ravi Rastogi" <raviras(a)gmail.com> wrote in message <hsunhd$mt$1(a)fred.mathworks.com>...
> 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

Hi Ravi, are you just talking about the axis() command?

imagesc(randn(300,300))
axis([58 112 225 275])


Wayne
From: Ravi Rastogi on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9f07ec22-3297-4342-9d15-2005c472787d(a)o39g2000vbd.googlegroups.com>...
> 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;

I am so sorry but i dont know how to use this callback function. Hope you will be patient with me. Here is a small code that i made, now how can i use it with this code.

img= imread('cameraman.tif');
figure;
imshow(img);
title('Original Image');

%I want to see only the camera part, which should be around 125 to 175 along x %and 50 to 90 along y axis. How will i do that using the callback function you %mentioned?

RAvi