利用Matlab的GUI设计图形用户界面,实现图像平滑功能

利用Matlab的GUI设计图形用户界面,实现图像平滑功能。

主要程序:

% --- Executes on button press in pushbutton1.
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';'*.jpeg';'*.bmp';'*.tif'});
fpath =[filename.pathname];
a=imread(fpath);
axes(handles.axes1);
imshow(a),title('原图像')
global I
I= rgb2gray(a);
axes(handles.axes2);
imshow(I),title('灰度图像')

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a = get(handles.popupmenu1,'value');
global I
axes(handles.axes3);
switch a
    case 1
        J1=imnoise(I,'salt & pepper',0.02);%添加椒盐噪声
        imshow(J1),title('添加椒盐噪声后的图像');
    case 2
        J2=imnoise(I,'gaussian',0.02); %添加高斯噪声
        imshow(J2),title('添加高斯噪声后的图像');
end

% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
b = get(handles.popupmenu2,'value');
global I
switch b
    case 1
        J1=imnoise(I,'salt & pepper',0.02);%添加椒盐噪声
        Z1= medfilt2(J1,[3,3]);%对添加椒盐噪声后图像进行中值滤波
        axes(handles.axes4);
        imshow(Z1),title('中值滤波');
        K1=imfilter(J1,fspecial('average',3));%对添加椒盐噪声后图像进行均值处理
        axes(handles.axes5);
        imshow(K1),title('均值滤波');
    case 2
        J2=imnoise(I,'gaussian',0.02); %添加高斯噪声
        Z2= medfilt2(J2,[3,3]);%对添加高斯噪声后图像进行中值滤波
        axes(handles.axes4);
        imshow(Z2),title('中值滤波');
        K2= imfilter(J2,fspecial('average',3)); %对添加高斯噪声后图像进行均值处理
        axes(handles.axes5);
        imshow(K2),title('均值滤波');
end

Guide设计界面
在这里插入图片描述
选择图像
在这里插入图片描述
在这里插入图片描述
加入椒盐噪声并处理
在这里插入图片描述
加入高斯噪声并处理
在这里插入图片描述

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值