Using GUI, use one push button as an image browser and another to process the image that was chosen?
Show older comments
Hi, this is the very first time I use Matlab & post on a forum so please bare with me. Im working on creating a simple image processing program, I currently have a button that browses a directory for images and loads it. I want the next button to take the loaded image and perform image processing on it. I cannot figure out how to use the same image. This is what I have for the first button.
% --- Executes on button press in Load_Image.
function Load_Image_Callback(hObject, eventdata, handles)
axes(handles.axes1);
path = '[file path]';
filter = '*.jpeg';'*.jpg';'*.png';'*.bmp';
selectedFile = uigetfile(fullfile(path , filter));
imshow(selectedFile);
Accepted Answer
More Answers (2)
Niels
on 6 Jan 2017
there are several ways.
if you are using guide, you could just use the handlea structur and save the image within handles:
handles.image=selectedFile;
so if you update handles after each callback, you will be able to use this in every callback as well.
guidata(hObject, handles);
if you dont use guise i propose to save the imagedata within the figure with appdata. Name the figure (=Fig1 in example:)
%setappdata(FigureName,'Name',Variable)
setappdata(Fig1,'ImageSavings',selectedFile)
at the start of your 2nd callback function type
selectedFile=getappdata(Fig1,'ImageSavings');
to get the data you saved back
Image Analyst
on 6 Jan 2017
1 vote
I recommend you start with MAGIC. http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
It does all the "plumbing" for you - batch processing, listing images in a listbox, click to display then, button to select images folder, writing results to Excel, etc. You just plug your script (image analysis algorithm) into the "AnalyzeSingleImage" function.
Categories
Find more on Display Image in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!