フィルターのクリア

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