图像处理实验空域滤波增强
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
南京信息工程大学实验(实习)报告实验名称实验四空域滤波的增强实验日期得分指导教师徐旦华院计算机与软件学院专业计算机科学与技术年级 2012 班次 3 姓名宗仰学号20121308097
1.实验目的
1.了解空域滤波增强的Matlab实现方法;
2.掌握噪声模拟和图像滤波函数的使用方法;
3.能够将给定图像+噪声,使用均值滤波器、中值滤波器对不同强度的高斯噪声和椒
盐噪声,进行滤波处理;
4.能够正确地评价处理的结果;并从理论上作出合理的解释。
2.实验内容
1.噪声模拟
利用函数imnoise给图像‘eight.tif’分别添加高斯(gaussian)噪声和椒盐(salt & pepper)噪声。
I=imread('33.jpg');
suptitle('20121308097');
subplot(2,3,1),imshow(I),title('原图 20121308097');
I1=imnoise(I,'gaussian',0,0.01);
subplot(2,3,2),imshow(I1),title('高斯1 均值0 方差0.01');
I2=imnoise(I,'gaussian',0,0.02);
subplot(2,3,3),imshow(I1),title('高斯2 均值0 方差0.04');
I3=imnoise(I,'gaussian',0.01,0.01);
subplot(2,3,4),imshow(I1),title('高斯3 均值1 方差0.01');
I4=imnoise(I,'salt & pepper');
subplot(2,3,5),imshow(I2),title('椒盐 20121308097');
2.均值滤波和中值滤波
A)均值滤波
在matlab环境中,程序首先读取图像,然后调用图像增强(均值滤波)函数,设置相关参数,再输出处理后的图像。
I = imread('cameraman.tif');
suptitle('20121308097');
subplot(2,3,1),imshow(I),title('原图 20121308097');
J=filter2(fspecial('average',3),I)/255;
subplot(2,3,2),imshow(J),title('3*3均值滤波');
J1=filter2(fspecial('average',5),I)/255;
subplot(2,3,3),imshow(J1),title('5*5均值滤波');
J2=filter2(fspecial('average',7),I)/255;
subplot(2,3,4),imshow(J2),title('7*7均值滤波');
B)中值滤波
在matlab环境中,程序首先读取图像,然后调用图像增强(中值滤波)函数,设置相关参数,再输出处理后的图像。
I = imread('cameraman.tif');
suptitle('20121308097');
subplot(2,3,1),imshow(I),title('原图 20121308097');
J=medfilt2(I,[3,3]);
subplot(2,3,2),imshow(J),title('3*3中值滤波');
J1=medfilt2(I,[5,5]);
subplot(2,3,3),imshow(J1),title('5*5中值滤波');
J2=medfilt2(I,[7,7]);
subplot(2,3,4),imshow(J2),title('7*7中值滤波');
3.空域滤波
C)对上述噪声图像进行均值滤波和中值滤波,比较滤波效果。
I=imread('cameraman.tif');
J = imnoise(I,'gauss',0.02); %添加高斯噪声
J1 = imnoise(I,'salt & pepper',0.02); %添加椒盐噪声
K = filter2(fspecial('average',3),J)/255; %均值滤波 3 ×3 L = filter2(fspecial('average',5),J)/255; %均值滤波 5 ×5 M = medfilt2(J,[3 3]); %中值滤波3 ×3 模板
N = medfilt2(J,[4 4]); % 中值滤波4 ×4 模板
suptitle('20121308097');
subplot(3,3,1),imshow(I),title('原图');
subplot(3,3,2),imshow(J),title('高斯噪声');
subplot(3,3,3),imshow(J1),title('椒盐噪声');
subplot(3,3,4),imshow(K),title('均值滤波 3 ×3');
subplot(3,3,5),imshow(L),title('均值滤波 5 ×5');
subplot(3,3,6),imshow(M),title('中值滤波3 ×3 模板');
subplot(3,3,7),imshow(N),title('中值滤波4 ×4 模板');
A)总结均值滤波和中值滤波的特点及使用场合。
均值滤波器是一种最常用的线性低通平滑滤波器。可抑制图像中的噪声,但同时也使图像变得模糊
中值滤波器是一种最常用的非线性平滑滤波器。可消除图像中孤立的噪声点,又可产生较少的模糊
B)*对图像采用'laplacian'高通滤波器进行锐化滤波。
I=imread('tire.tif');
suptitle('锐化滤波'),
h=fspecial('laplacian',0.1);
I2=filter2(h,I);
k=fspecial('laplacian',0.3);
I3=filter2(k,I);
m=fspecial('laplacian',0.4);
I4=filter2(m,I);
subplot(2,2,1),imshow(I), title('原图')
subplot(2,2,2),imshow(I2), title('拉普拉斯算子0.1')
subplot(2,2,3),imshow(I3), title('拉普拉斯算子0.3')
subplot(2,2,4),imshow(I4), title('拉普拉斯算子0.4')