多媒体图像处理第二次实验 下载本文

在matlab环境中,程序首先读取图像,然后调用图像增强(中值滤波)函数,设置相关参数,再输出处理后的图像。

I = imread('cameraman.tif'); figure,imshow(I);

_________ J = medfilt2(I,[3,3]) ____ 中值滤波 figure,imshow(J);

3.

空域滤波

A) 对上述噪声图像进行均值滤波和中值滤波,比较滤波效果。

I=imread(rgb2gray(' sample1.jpg '));

J = imnoise(I,'gauss',0.02); %添加高斯噪声 %J = imnoise(I,'salt & pepper',0.02); %添加椒盐噪声 K=filter2(fspecial('average',3),I)/255; %均值滤波 3 ×3 L=filter2(fspecial('average',5),I)/255; %均值滤波 5 ×5 M = medfilt2(I,[3,3]) %中值滤波3 ×3 模板

N = medfilt2(I,[4,4]) % 中值滤波4 ×4 模板%显示以上滤波后的图片

imshow(I);

figure,imshow(J); figure,imshow(K); figure,imshow(L); figure,imshow(M); figure,imshow(N);