I want to put a slider in GUI to zoom into my image with certain center

Hi. I have written a GUI without using GUIDE. I have an image (in Image matrix) with 2 pushbuttons in it. I have several points (in point matrix) that I want to ask the user to choose the proper type of that point. I have two questions.
1. specifying the point by a marker in the image, I want a slider so that the user can zoom into the picture with that point in the center of the picture.
2. after pushing the pushbutton, I want the marker to go to the next point and ask the user about the new point. Obviously, I need a for loop to change the points, but I am not sure where to use it, in my main script or in the gui script.
I read the image from my workspace, and I have the coordinates of the point that I want to zoom into.
function myGui
% create the figure
Fig = figure('Position',[0 0 1200 800],'Visible','off');
movegui(Fig,'center');
set(Fig,'Tag','screen','HandleVisibility','on','Visible','on');
%read image and point from workspace:
trueImage= axes('Units','Pixel','Position', [20 70 900 750]);
Image=evalin('base','trueImage');
point=evalin('base',point);
imshow(Image);
hold on;
plot(point(1,1),point(1,2),'c.','MarkerSize',10); %specifying the marker to the point I want
% create the buttons
falsePositive_handle = uicontrol(Fig,'Style','pushbutton','String','False Positive',...
'Position',[950 700 200 60], 'Callback', @falsePositive_Callback);
falseNegative_handle = uicontrol(Fig,'Style','pushbutton','String','False Negative',...
'Position',[950 600 200 60], 'Callback', @falseNegative_Callback);
zoomingSlider = uicontrol(Fig,'Style','slider','Min', 0, 'Max', 400,...
'Value', 0, 'Units', 'Pixel', 'Position', [20 75 200 20],...
'Callback', zoomingSlider_Callback);
end
function falsePositive_Callback(hObject, eventdata)
label=1;
assignin('base','label',label);
end

5 Comments

Jahandar - which function or algorithm are you using to zoom in or out of the image? By moving the slider to the right, does that mean that you zoom in with some factor?
Also, please explain these two lines of code
trueImage= axes('Units','Pixel','Position', [20 70 900 750]);
Image=evalin('base','trueImage');
Your trueImage is a handle to the axes that you just created, but then you evaluate it in the workspace? Or do you have an image already defined in the workspace with the same variable name of trueImage? Please clarify.
Geoff, I didn't use any function for the zooming... I just created the slider. I was hoping if anyone can refer me to a proper callback function so that when slide the slider, it zooms into the point that I want.
Regarding to those lines, sorry for my bad coding... In the first line, I defined the handle of the axes to "trueImage". In the second line I passed the "trueImage" matrix from my workspace and assigned it to the matrix "Image".
Did you even try my answer/demo below?
Yes. I just did. Thanks for your demo. actually I can use the "iptgetapi" function to get the magnification and the center of the zoomed image.

Sign in to comment.

 Accepted Answer

See Mathworks attached zoom demo. See if anything in there helps you.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!