Using GUI, use one push button as an image browser and another to process the image that was chosen?
Show older comments
Hi I'm creating a GUI for part of an image processing project at university. To this point I've created a push button which allows me to browse through my working directory and select either a 'jpg' or 'bmp' image: below is the code:
% --- Executes on button press in pushbutton1(Image Browser).
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)
[filename pathname] = uigetfile({'*.jpg';'*.bmp'},'File Selector');
image = strcat(pathname, filename);
axes(handles.axes1);
imshow(image)
set(handles.edit1,'string',filename);
set(handles.edit2,'string',image);
I'm looking to create another push button which will plot a histogram of the image I read in, I'm not sure how to define the image under the new function as the image that was chosen previously, could any one help, below is the code I have at the minute for the histogram push button but it is giving out errors;
% --- Executes on button press in pushbutton2 (Histogram plot).
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
histogram(double(image(:)),'Normalization','pdf');
could any one help me out?
Accepted Answer
More Answers (2)
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!