[求助]请教一个GUI回调函数问题?
请教一个GUI回调函数问题?
set(0,'units','pixels');
pos=get(0,'ScreenSize');
set(0,'units','centimeters');
pos1=get(0,'ScreenSize');
set(0,'units','inches');
pos2=get(0,'ScreenSize');
pix_cent=pos1(3)/pos(3);
pix_inche=pos2(3)/pos(3);
unit_change=[pix_cent,pix_inche];
set(0,'userdata',unit_change);
这段代码加入回调函数中时,会出现我的
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.bw=[];
[filename,pathname]=uigetfile({'*.jpg','image file(*.jpg)';'*.bmp','image file(*.bmp)';...
'*.tif','image file(*.tif)';'*.hdf','image file(*.hdf)';...
'*.png','image file(*.hdf)';'*.xwd','image file(*.xwd)'},...
'Open Image File');
if(isequal([filename,pathname],[0,0]))
return
end
cd
olddata=imread(filename);
hfigure=figure;
imshow(olddata);
set(hfigure,'resize','on','MenuBar','none');
handles.olddata=olddata;
handles.data=olddata;
handles.hfigure=hfigure;
guidata(hObject,handles);
这样会打不开图片,不知道为什么?麻烦哪位大侠看看,应该怎么办?顺便问一下,各个机器的像素大小是不是一样?
pos=get(0,'ScreenSize');
set(0,'units','centimeters');
pos1=get(0,'ScreenSize');
set(0,'units','inches');
pos2=get(0,'ScreenSize');
pix_cent=pos1(3)/pos(3);
pix_inche=pos2(3)/pos(3);
unit_change=[pix_cent,pix_inche];
set(0,'userdata',unit_change);
这段代码加入回调函数中时,会出现我的
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.bw=[];
[filename,pathname]=uigetfile({'*.jpg','image file(*.jpg)';'*.bmp','image file(*.bmp)';...
'*.tif','image file(*.tif)';'*.hdf','image file(*.hdf)';...
'*.png','image file(*.hdf)';'*.xwd','image file(*.xwd)'},...
'Open Image File');
if(isequal([filename,pathname],[0,0]))
return
end
cd
olddata=imread(filename);
hfigure=figure;
imshow(olddata);
set(hfigure,'resize','on','MenuBar','none');
handles.olddata=olddata;
handles.data=olddata;
handles.hfigure=hfigure;
guidata(hObject,handles);
这样会打不开图片,不知道为什么?麻烦哪位大侠看看,应该怎么办?顺便问一下,各个机器的像素大小是不是一样?