Clear Filters
Clear Filters

How to get jpeg/png image for processing thanks to GUI?

1 view (last 30 days)
Well I need to browse my folder, get an image (basically .jped or .png) and then processing that image (filter, segmentation etc). I already create my GUI
but my problem is how to get this image in my main code. Let's explain better.
I have this callback function:
and then on my main i just have I = browse; ---> Where browse is the name for this GUI but I don't get my image and then I can't process it, so how can I do? I'd like to obtain something like that on my workspace:
Thanks for any help :)
  3 Comments
Giovanni Lo Bocchiaro
Giovanni Lo Bocchiaro on 17 Dec 2017
It's ok, I get it, but my problem is that i can't process my image (which is called I for example) on my main code, because it doesn't appear on my workspace.
I want to browse for an image, save on my workspace and then work on this image (converto from rgb to gray for example!): how can i get image output fron GUI after browse and select?

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 17 Dec 2017
If you just need to get the image out of an axes in a callback, you can use getimage().

Jan
Jan on 17 Dec 2017
What is "my main" and "my workspace"? Remember, that each function has its own workspace.
You can use e.g. guidata to store a value in the figure (to be exact in the struct called "handles", when you use GUIDE). This can be used to share data between callbacks. It is recommended, not to create a variable ion the base workspace or in another function, because this remote creation of variables is hard to debug and prone to bugs. Prefer to process all data inside the GUI by using callbacks, e.g. a "Process" button. You know this behavior from almost all other programs running on your computer.
Maybe you want the GUI just to be a kind of "open file dialog" called from a main program. Then use an output from the dialog: https://blogs.mathworks.com/videos/2010/02/12/advanced-getting-an-output-from-a-guide-gui/. You can find such links asking your favorite internet search engine for "Matlab GUIDE output".

Community Treasure Hunt

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

Start Hunting!