External functions (with a GUI)
2 次查看(过去 30 天)
显示 更早的评论
Hey there.
I'm currently working on a GUI, that has to show images in 3 different axes. I have no problem handling it insides the main *.m file for the GUI, but if i try to put the plotting code in a file for itself, then I can't use "axes(handles.axes1)" because handles, apparently, only can be accessed from the main file. Is there anyway to cope with this? And preferably something somewhat refined, since this is for my bachelor degree.
Thanks in advance
0 个评论
采纳的回答
Chandra Kurniawan
2012-2-20
Hi,
Maybe this will helps.
I have GUI as shown in picture below :
For button "GRAY" and "BINARY", I perform image convertion with external functions.
I also call 'imshow' from external functions.
Here code about the main interface :
function pushbutton1_Callback(hObject, eventdata, handles)
handles.I = imread('peppers.png');
axes(handles.axes1);
imshow(handles.I);
guidata(hObject, handles);
function pushbutton2_Callback(hObject, eventdata, handles)
handles.J = rgb_to_gray(handles.I,handles.axes2);
guidata(hObject, handles);
function pushbutton3_Callback(hObject, eventdata, handles)
handles.K = im_to_bw(handles.J,handles.axes3);
guidata(hObject, handles);
And here the external functions
Perform rgb2gray
function J = rgb_to_gray(I,handles)
J = rgb2gray(I);
axes(handles);
imshow(J);
Perform im2bw
function J = im_to_bw(I,handles)
J = im2bw(I);
axes(handles);
imshow(J);
I hope this will helps
0 个评论
更多回答(2 个)
Jakob Sørensen
2012-2-21
2 个评论
Febrian Dhimas Syahfitra
2018-2-5
编辑:Febrian Dhimas Syahfitra
2018-2-5
please guys, help me to answer this https://www.mathworks.com/matlabcentral/answers/380619-how-do-i-use-the-edit-text-box-in-a-gui-to-change-variables-in-a-function
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!