How do i convert a .m file to a GUI

I'm having a code that crops a portion of the image and finds the length of the line drawn on the image in terms of pixels. I'm new to MATLAb and a student so can someone help me out ?

Answers (2)

Adam
Adam on 14 Mar 2015
You can use Guide to create a GUI and then call your .m file function from a callback of a pushbutton or whatever control you want to use to trigger your code.

4 Comments

Can you show me how with an example, from the scratch will be great. And how do I call my .m file function ?
@NeoSeeker: You find many GUI examples in the net and in the documentation of Matlab. It would not be efficient, if someone creates a new example here in the forum. The M-file is called as usual simply be using its name.
I tried using the GUIDE method for creating the GUI but I have no idea how to apply the function . Can you tell me with an example of how to apply the function?
If you create a pushbutton then (assuming you have default GUIDE settings so that it created a .m file with the .fig) you will have a callback function for that
pushbutton1_Callback
if you didn't change the button's tag.
In that function you can call your other function although if you have inputs and outputs then that is more complicated as you need to get the inputs from somewhere.
Outputs can be saved on the handles structure as e.g.
handles.result = someFunction( );
guidata( hObject, handles )

Sign in to comment.

Description
This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can....................

2 Comments

See my attached spatial calibration demo that lets you draw a line and get the length. Put that code into a callback function of your GUI.
Thank you Image Analyst, I didn't the part where I need to enter the real life distance. Can you explain that part of the code?

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 14 Mar 2015

Commented:

on 20 Mar 2015

Community Treasure Hunt

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

Start Hunting!