ginput with scroll panel does not work when running from a gui
이전 댓글 표시
I have a code that opens an image and a scroll panel of the same image, and using ginput i select points to get the coordinates. The code works fine when i run it from the workspace, but doesn't work when i run it from a gui. The problem is that when i run it from the gui, matlab uses the ginput function on the scroll panel and not on the image. Any help will be appreciate it.
here's the code:
drawnow
[nomb, direc]=uigetfile('*.jpg', 'Abrir Imagen para análisis');
if nomb == 0
return
end
rgbImage = imread(fullfile(direc,nomb));
% 1. Create a scroll panel.
hFig = figure('Toolbar','none',...
'Menubar','none');
hIm = imshow(rgbImage);
hSP = imscrollpanel(hFig,hIm);
set(hSP,'Units','normalized',...
'Position',[0 0 1 1])
% 2. Add a Magnification Box and an Overview tool.
hMagBox = immagbox(hFig,hIm);
pos = get(hMagBox,'Position');
set(hMagBox,'Position',[0 0 pos(3) pos(4)])
imoverview(hIm)
% 3. Get the scroll panel API to programmatically control the view.
api = iptgetapi(hSP);
% 4. Get the current magnification and position.
mag = api.getMagnification();
r = api.getVisibleImageRect();
% 5. View the top left corner of the image.
api.setVisibleLocation(0.5,0.5)
% 6. Change the magnification to the value that just fits.
api.setMagnification(api.findFitMag())
% 7. Zoom in to 1600% on the dark spot.
api.setMagnificationAndCenter(2,306,800)
v = ginput;
[var1,var2] = size(v);
v2 = zeros(var1,var2);
v2(:,1) = v(:,2);
v2(:,2) = v(:,1);
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!