필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

code works when running from workspace, but doesn't work when running from gui

조회 수: 2 (최근 30일)
Alejandro
Alejandro 2014년 5월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a code that display an image and an overview image with a scroll panel(from the same image). Using ginput i select some points and i get the coordinates from those points. The overview image allows me to move around (scroll panel), because the original image is too big (1800X1920). The code works fine when i run it from the workspace, but when i run it from a gui (button callback), does not. what happen is that when i run it from a gui, matlab thinks the overview image with the scroll panel is the principal image, and restrict the cross-hair to this image. The cross-hair has to be in the larger or principal image
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)
%plot_size = get(0,'ScreenSize');
%fg = figure(1);
%set(fg, 'Color', [1 1 1], 'Position', plot_size, 'Visible', 'on');
%imshow(a),
%title('lalala')
%figure, imshow(a,'InitialMagnification',1000);
%axis on
v = ginput;
[var1,var2] = size(v);
v2 = zeros(var1,var2);
v2(:,1) = v(:,2);
v2(:,2) = v(:,1);

답변 (1개)

Guillermo Soriano
Guillermo Soriano 2018년 1월 15일
variables made in the gui are not saved therefore workspace do not find values

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by