我做的一个界面,功能都是在菜单里面,首先打开一幅图象到界面的axes1中,这步没有任何问题,代码如下:
function open_menu_Callback(hObject, eventdata, handles)
% hObject handle to open_menu (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename pathname]=uigetfile({'*.bmp','BMP图象(*.bmp)';...
'*.jpg','JPG图象(*.jpg)';'*.gif','GIF图象(*.gif)';...
'*.tif','TIF图象(*.tif)';'*.png','PNG图象(*.png)';...
'*.*','ALL FILES(*.*)'},'请选择一幅图像');
%L=length(filename);
if isequal([filename pathname],[0,0])
return;
end
str=[pathname filename];
handles.im=imread(str);
axes(handles.axes2);
imshow(handles.im);
guidata(hObject, handles);
然后点击“转换为灰度图象”菜单,虽然处理成功,但是显示的时候新开了一个界面,没有了我的菜单项,并且关闭了源界面,代码如下:
function gray_menu_Callback(hObject, eventdata, handles)
% hObject handle to gray_menu (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
imgray=rgb2gray(handles.im);
axes(handles.axes2);
%figure;
imshow(imgray);
请问这是为什么?如果加上figure;的话,则原界面消失不了,只不过是在另一个界面中显示处理后的图象,现在我想要的效果是把处理后的图象直接显示到原界面的axes2中,覆盖掉源图象,怎么实现啊?需要加什么代码?
如果想看源代码的话,见附件。
[本帖最后由 edifiers 于 -12-9 17:04 编辑]
-12-9 17:03 上传
点击文件名下载附件
5.68 KB, 下载次数: 495
如果觉得《matlab 关闭imshow matlab imshow 的问题》对你有帮助,请点赞、收藏,并留下你的观点哦!