MATLAB: Dear All iam trying to display image in axes1 and its hitogram in axes2 using single callback of pushbutton1, the code iam using is given below, please help me

guidehistogramImage Processing Toolbox

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)
global img
[FileName,PathName] = uigetfile('*.jpg','Select an image');
img=imread(strcat(PathName,FileName));
axes(handles.axes1);
imshow(img);
imhist(img);
axes(handles.axes2);

Best Answer

Try this:
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)
global img
[FileName,PathName] = uigetfile('*.jpg','Select an image');
img=imread(fullfile(PathName,FileName));
axes(handles.axes1);
imshow(img);
axes(handles.axes2);
imhist(img);
Related Question