MATLAB: How to make only one image as input for all buttons in gui

image processing in matlabmatlab guitooth_pull

Hi, I am currently working on a project which edits images. I want the user to select an image in the starting by clicking open button designed on GUI. Then I want that this image is edited for all the functionality buttons that are clicked, for eg: brighten, invert colors, deblur and so on. I do not want the user to select an image every time he clicks some functionality button. Is it possible?

Best Answer

Yes, it is possible. Once the user has selected an image, set the 'enable' property of the image selection button to 'inactive'. Then when the image processing is complete and the image saved (or whatever) set the property back to 'on' for the next image.
I hope you do not mean that you programmed the GUI to prompt the user to open an image with every functionality button! If so, take that code out. Have the user prompted only with the first button. Then save the image in GUIDATA for access in other callbacks.
%
%
%
EDIT In response to your 'answers' below.
In your callback pushbutton6, you didn't store the handle in GUIDATA so it is not available later.
function pushbutton6_Callback(hObject, eventdata, handles)
H.Id = imread((uigetfile('*.JPG')));%read in the image file
H.Ih = imshow(H.Id)% display image in axis1
guidata(gcbf,H) % Store information in GUIDATA
Now in any other callback, you can access the image data (Id) and the image handle (Ih) by calling GUIDATA. For example, in your other callback,
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)
H = guidata(gcbf);
g = rgb2gray(H.Id); % Use the same field name! H.Id is image data.
imshow(g);
% guidata(object_handles,data) Not necessary, nothing changed in data.
If you wanted to save g for later use, you will need to do something similar as in the first callback, i.e.,
H.g = rgb2gray(H.Id); % Save gray out put in H.
imshow(H.g);
guidata(gcbf,H) % Store in GUIDATA
Also, you may instead want to not store both the original and the gray data. If so, simply overwrite H.Id instead of assigning an new field, H.g. The more large data you have stored, the more chances that your program will experience lag...