필터 지우기
필터 지우기

*m file works but GUI doesn't. i don't get it ... :( please if some1 can help

조회 수: 1 (최근 30일)
Quick Click
Quick Click 2011년 6월 2일
Hello,
I'm a student and I'm working on a program for my final exam.
The ideea of the program is to make anaglyph pictures.I have 2 buttons that open image files : 1 for left eye and 1 for the right eye and 2 axes to see the images in them.
The problem I have is that when I open my program's GUI from matlab (File->Open ) the program doesn't work properly (BUT when I run the program from the main *m file it works ok).The problem ocurs when i try to open an image file. This is the error that I get when I open the GUI :
??? Attempt to reference field of non-structure array.
Error in ==> Convertor3Dbeta>ImagineSt_Callback at 98
axes(handles.AxaImSt);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Convertor3Dbeta at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Convertor3Dbeta('ImagineSt_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
As the error point out the error is somewhere here:
function ImagineSt_Callback(hObject, eventdata, handles)
% hObject handle to ImagineSt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imagine_st
global im_st
global i_st
imagine_st = uigetfile({'*.jpg;*.bmp'});
im_st=imread(imagine_st);
i_st=im_st;
axes(handles.AxaImSt);
imshow(imagine_st);
set(handles.AxaImSt,'Visible','Off')
The code is the same for both buttons Please if someone can help me. Thank you very much in advance.
PS : The program doesn't work either when i try to export it, using deploytool, as a windows application

답변 (1개)

Walter Roberson
Walter Roberson 2011년 6월 2일
You cannot just open the .fig file: you have to run the .m file. The .m file contains initialization for the .fig file.
We will need more information about what happens when you attempt to deploy the code.
  댓글 수: 2
Quick Click
Quick Click 2011년 6월 4일
Hi,
Thanks for th info.
I didn't expressed myself very well. my application didn't work as I wanted.There was no error with the deplytool.It was that i couldn't select images from my desktop.But it turned out i have to move my images to the src folder that is generated.Wich by the way gets me to the question : is there possible to modify the code so that I can take pictures from wherever I want, not only from the src folder?
Image Analyst
Image Analyst 2011년 6월 4일
Yes. You have to use fullfile(), exist(), and possibly uigetfile(). Basically you have to know what folder your images live in because assuming they are always in the current folder is not a good idea - ESPECIALLY when you're dealing with compiled applications, which is a whole other level of complication and confusion (see the FAQ). For that reason you have to build up your full filename (folder + base file name) and then check if it exists with exist(fullFileName, 'file') so you don't throw an exception. Warn user it doesn't exist with warndlg().

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by