I am trying to use guide and could use some help with functions in 2014a
1 次查看(过去 30 天)
显示 更早的评论
I have a function "imgImport" which passes these output "im, hdr,old, datafile, hdrfile" but I can not grab this data in the next function. I noticed it is not propagating the data to the work space, and found that it is stored in the GUI. I have two buttons one to grab the image the second to crop the image; here is the function as I tried.
function pushbutton1_Callback(hObject, eventdata, handles)
%disp('imgImport')
[im, hdr,old, datafile, hdrfile]= imgImport;
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
[imgVIS, imgSWIR, rect,img,rowend, rowstart, colend, colstart]= cropping(im, hdr);
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
How do I get one button to grab outputs from the other buttons data.
0 个评论
采纳的回答
Geoff Hayes
2014-6-2
You can use the handles structure with the guidata function to store/save user data to the structure. Try something like this
function pushbutton1_Callback(hObject, eventdata, handles)
% call your script
[im, hdr,old, datafile, hdrfile]= imgImport;
% assign the user data to the structure
handles.im = im;
handles.hdr = hdr;
% save the data
guidata(hObject,handles);
Now in your other button callback, just access the data directly from the handles structure:
function pushbutton2_Callback(hObject, eventdata, handles)
[imgVIS, imgSWIR, rect,img,rowend, rowstart, colend, colstart] = …
cropping(handles.im, handles.hdr);
Try the above and see if that does what you wish.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!