I have created a matlab program for extracting characters from an image. The program takes an image name which i edit in the program and then i get the output when i run the program. The problem is that, i want all this to take a systematic shape, i.e., i want to run it through a GUI. I am a new comer in MATLAB GUI, hence have a little knowledge of it. can you please suggest something, such that the gui takes an imae address and then when i press a specific button, it should give the output.
MATLAB: GUI
graphic user interfaceguiimage processingImage Processing ToolboxMATLAB
Related Solutions
Basically you get the edit field contents as a string, convert it to a double of 20 and then use it somehow in your code. So, in any callback, like the callback for a push button, do
userEntry = handles.editText1.String; % A string.
myNumber = str2double(userEntry); % Convert string to double number.
% More code goes here....
Hi monu,
I think what you want to do is invoke your program (in the m-file) from a callback that is associated with your button. Presumably you are using GUIDE to develop your GUI with buttons and other widgets. Within the *.fig (GUIDE) layout for your GUI, double-click on the button that is to call your program. Observe the that Inspector: uicontrol(pushbutton…) window appears. Look for the Callback item and press the edit button (pencil on paper image) that is beside it. This should bring up your GUI *.m file with code similar to the following:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)% 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)
Note that pushbutton1 is the name or Tag (see inspector window for Tag) for this button widget and so may be different from the tag assigned to your widget. This is just an empty function that (currently) does nothing but will get called whenever the user pushes the button on the GUI. It is within this function (pushbutton1_Callback) that you will add some code to invoke your program (in the other m-file):
% call your other program here
[results] = otherProgram(…);
Now that you have called your other program and the results have been returned, these results should be displayed in an edit box on your GUI. Like this button whose Tag is 'pushbutton1' (in my example) the edit control will have its own unique Tag say "edit1". (Note that you can change these tag names to something more obvious given the nature of the button, edit control, etc.) The tag acts as an identifier within the list of handles for the GUI. So you can use the tag to get the control and update its contents like:
function pushbutton1_Callback(hObject, eventdata, handles)% 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)% call your other program here[results] = otherProgram(…);% assume that results is a number of some kind (for this example)
% update edit1 control with results
set(handles.edit1,'String',num2str(results));% in the above we use the "handles" input to this function (see callback signature)
% to grab the control (given by the Tag "edit1") that we wish to update;
% since the edit control is populated with a string of characters, we set its 'String'
% property to the results (that have been converted to a string)
Hope this helps!
geoff
Best Answer