Zooming into an image by clicking on it

4 次查看(过去 30 天)
Hello,
I'm in progress of making an algorithm that allows me to load a group of pictures and lets me save the X,Y position for where ever it is that i click on each file (in my case the most distal part of a fly's leg) onto an xls file. I have most of the code done, however i would also like to add a zoom on click function to it, as at times it's hard to see the ends of the legs. Here is what i have:
function Leg_Selection_Multiple_Images()
%Creates the file that the data will be saved to.
helpmsg1 = 'Save File As';
[xlsname1,xlspath] = uiputfilehelp('*.xls', 'Save File As', 'helpmsg',helpmsg1);
pathtoxlsfile = [xlspath, xlsname1];
%Loads folder where images are stored.
helpmsg1 = 'Choose Picture to Analyse';
[imgname1,imgpath] = uigetfilehelp('*.*','Choose Picture to Analyse','helpmsg',helpmsg1);
if isnumeric(imgname1) && imgname1 == 0,
return;
end
myFolder = imgpath;
filePattern = fullfile(myFolder, '*.tif');
tiffFiles = dir(filePattern);
for k = 1:length(tiffFiles)
baseFileName = tiffFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
set(gcf,'Units','normalized','Position',[0 0 1 1])%zooms in
set(gca,'Units','normalized','Position',[0 0 1 1]);%Zooms in
fprintf([ 'Select the plot origin with the left mouse button ...\n' ])
[XLegs,YLegs] = ginput(6); %X,Y position for the legs.
end
end
I would like to zoom in without using a GUI, as i don't know how to program those yet, and i know that it should go before line 37 ( [XLegs,YLegs] = ginput(6); ) however, i'm not sure how to make it so that i could zoom in to the spot by clicking where the fly is and then going onto the ginput to select the ends of each leg.
PS i trimmed out the remaining of the code that does the arithmetic work i need done, as well as the saving to the xls file as i already knew how to do that, and it wasn't necesary for what i do need.
Thanks in advance.
  1 个评论
Image Analyst
Image Analyst 2011-7-9
How would it know if your were clicking to zoom, or clicking to indicate the leg's x,y location? You could do what I do: have a slider control on the Gui for zooming. Search the newsgroup for zoomLevel or zoomFactor or something like that - I've posted code there before.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2011-7-8
By which amount do you want to zoom in? What about dragging a rectangle (e.g. rbbox or dragrect) to define the visible part of the image? Have you read the help text of the function "zoom"?

更多回答(1 个)

Guillermo
Guillermo 2011-7-8
Actually, zoom on by itself was what i originally was interested in, as i could zoom in/out of the area I chose, however, I wasn't able to get it to work because it would go on to the next section (ginput) without allowing me to zoom in. I figured out that i just needed to place a pause after zoom on to let me zoom in the picture to the size i want. Thanks for helping Jan.

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by