资源描述:
《数字图像处理实验参考程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数字图像处理实验参考程序(供芙蓉学院实验用)实验项目开设情况序号实验名称内容提要实验要求实验类型实验时数每组人数所在实验室名称备注1邻域平均法实验利用邻域平均法,给定阈值,对图像进行变换必开验证2图像处理实验室2中值滤波算法实验中值滤波算法,来抑制噪声必开验证213图像锐化算法实验利用Prewitt算子、laplacian算子、log算子对图像进行锐化必开验证214边缘检测算法实验边缘检测Sobel算子实现灰度图像边缘检测必开验证215直方图均衡化实验利用直方图统计实验的结果,对图像进行均衡化实验必开综合21第1个实验:邻域平均法实验I=imread('
2、eight.tif');J=imnoise(I,'salt&pepper',0.02);%Ìí¼Ó½·ÑÎÔëÉùsubplot(221),imshow(I)title('原图像')subplot(222),imshow(J)title('添加椒盐噪声图像')K1=filter2(fspecial('average',3),J)/255;%Ó¦ÓÃ3¡Á3ÁÚÓò´°¿Ú·¨subplot(223),imshow(K1)title('3×3窗的邻域平均滤波图像')K2=filter2(fspecial('average',7),J)/255;%Ó¦ÓÃ7
3、¡Á7ÁÚÓò´°¿Ú·¨subplot(224),imshow(K2)title('7×7窗的邻域平均滤波图像')I=imread('eight.tif');subplot(221),imshow(I)title('原图像')J=imnoise(I,'gaussian',0,0.005);subplot(222),imshow(J)title('添加高斯噪声图像')K1=wiener2(J);subplot(223),imshow(K1)title('3×3窗的邻域维纳滤波图像')K2=wiener2(J,[77]);subplot(224),imsh
4、ow(K2)title('7×7窗邻域的维纳滤波后的图像')第2个实验:中值滤波算法实验I=imread('eight.tif');J=imnoise(I,'salt&pepper',0.02);%图像添加椒盐噪声K=medfilt2(J);%缺省3×3邻域窗的中值滤波subplot(121),imshow(J)title('添加椒盐噪声图像')subplot(122),imshow(K)title('缺省3×3邻域窗的中值滤波图像')第三个实验:图像锐化算法实验I=imread('saturn.tif');subplot(211);imshow(I);
5、title('原图像');H=fspecial('laplacian');%应用Laplacian算子滤波锐化图像laplacianH=filter2(H,I);subplot(223);imshow(laplacianH);title('laplacian算子锐化图像');H=fspecial('prewitt');%应用prewitt算子滤波锐化图像prewittH=filter2(H,I);subplot(224);imshow(prewittH);title('prewitt算子锐化图像');I=imread('saturn.tif');J=im
6、noise(I,'salt&pepper',0.02);%图像添加椒盐噪声subplot(121),imshow(J)title('含有噪声的原图像')J=double(J);f=fft2(J);g=fftshift(f);[M,N]=size(f);n=3;d0=20;n1=floor(M/2);n2=floor(N/2);fori=1:Mforj=1:Nd=sqrt((i-n1)^2+(j-n2)^2);h=1/(1+0.414*(d/d0)^(2*n));g(i,j)=h*g(i,j);endendg=ifftshift(g);g=uint8(re
7、al(ifft2(g)));subplot(122),imshow(g)title('三阶Butterworth滤波图像')clearall;I1=imread(‘E:…………’)I1=double(I1);h1=fspecial(‘prewitt’)I2=filter2(h1,I1)Figure,imshow(I1,[]);I3=I1-I2;Figure,imshow(I3,[]);clearall;I1=imread(‘E:…………’)I1=double(I1);h1=fspecial(‘log’)I2=filter2(h1,I1)Figur
8、e,imshow(I1,[]);I3=I1-I2;Figure,imshow(I