Zooming into an image by clicking on it
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Image Analyst
el 9 de Jul. de 2011
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.
Respuesta aceptada
Jan
el 8 de Jul. de 2011
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"?
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!