필터 지우기
필터 지우기

How to read image loaded in another function in GUI

조회 수: 1 (최근 30일)
Audrey
Audrey 2018년 1월 17일
편집: bon sai 2018년 1월 25일
I am a Matlab beginner, and am confused by the way that functions work in a GUI.
I'd like to use one pushbutton to prompt the user to load a file, and then another pushbutton to start analyzing that image. I can't figure out how to read the image that the user uploaded in the previous pushbutton callback function.
In the attached file, I tried to use the first suggestion in these FAQs by adding an image variable to the handles structure. I get the error "Reference to non-existent field 'image'."
What is the best way to call the image again?
  댓글 수: 1
KSSV
KSSV 2018년 1월 17일
When you push a button, and upload file..you will get the name of the file with its path...you can use this to read/ analyse.

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

답변 (1개)

bon sai
bon sai 2018년 1월 25일
편집: bon sai 2018년 1월 25일
If your pushbutton1_Callback to get the filepath, then read the image to array. Finally store it in handles and update handles. So the code seems like this:
[file,path]= uigetfile(......);
fullname = fullfile(path,file);
image = imagesc(fullname);
handles.image = image;
guidata(hObject,handle)
When you call your image array in pushbutton2 just use
imageinbtn2 = handles.image

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by