数字图像处理程序.docVIP

  • 5
  • 0
  • 约3.46千字
  • 约 4页
  • 2017-08-21 发布于云南
  • 举报
试验一图像变换 %lena.bmp的傅里叶频谱 clear clc I=imread(lena.bmp); imshow(I); J=fft2(I); figure,imshow(log(1+abs(J)),[8,10]); J1=fftshift(J); figure,imshow(log(1+abs(J1)),[8,10]); % J2=fftshift(fft2(I)); % figure,imshow(log(1+abs(J2)),[8,10]); %lena.bmp旋转45度后的傅里叶谱 I1=imrotate(I,315,bilinear,crop);%逆时针旋转315度, 相当于顺时针放置45度 figure,imshow(I1) J3=fftshift(fft2(I1)); figure,imshow(log(1+abs(J3)),[8,10]); %lena.bmp的DCT频谱 J4=dct2(I); figure,imshow(log(1+abs(J4)),[]) %DCT反变换求原始图像 I2=idct2(J4)/255; figure,imshow(I2) %利用DCT变换对图像lena.bmp进行压缩,压缩率为80% I=double(I)/255;%不可缺少 T=dctmtx(8); B=blkproc(I,[8 8],P1*x*P2,T,T); mask=[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; B2=blkproc(B,[8 8],P1.*x,mask); I3=blkproc(B2,[8 8],P1*x*P2,T,T); figure,imshow(I3) 试验二图像灰度修正技术和直方图均衡化 %显示图像cameraman.tif的灰度直方图和灰度等值图 clear clc I=imread(cameraman.tif); imhist(I); figure; subplot(1,2,1),imshow(I); subplot(1,2,2),imcontour(I); %对图像pout.tif进行灰度变换、增强对比度 I1=imread(pout.tif); J=imadjust(I1,[0.3 0.7],[ ]); figure subplot(1,2,1),imshow(I1); subplot(1,2,2),imshow(J); figure subplot(1,2,1),imhist(I1); subplot(1,2,2),imhist(J); %对图像pout.tif进行直方图均衡化处理 J1=histeq(I1); figure subplot(1,2,1),imshow(I1); subplot(1,2,2),imshow(J1); figure subplot(1,2,1),imhist(I1); subplot(1,2,2),imhist(J1); 实验三 图像的平滑 f0=imread(lena.bmp); imshow(f0); %添加高斯噪声 f1=imnoise(f0,gaussian,0,0.02);%均值为0,方差为0.02 f1=im2double(f1); %均值滤波即邻域平均法实现平滑 h1=fspecial(average); %默认模板大小为3*3 g1=filter2(h1,g1,same); %中值滤波实现图像平滑 g2=medfilt2(f1);%默认模板大小为3*3 g3=medfilt2(f1,[5 5]);%模板大小为5*5 figure subplot(2,2,1),imshow(f1); subplot(2,2,2),imshow(g1); subplot(2,2,3),imshow(g2); subplot(2,2,4),imshow(g3); %添加椒盐噪声 f2=imnoise(f0,salt pepper,0.02); %密度为0.02 f2=im2double(f2); %均值滤波即邻域平均法实现平滑 h2=fspecial(average); %默认模板大小为3*3 g4=filter2(h2,f2,same); %中值滤波实现图像平滑 g5=medfilt2(f2);%默认模板大小为3*3 g6=medfilt2(f2,[5 5]);%模板大小为5*5 figure subplot(2,2,1),imshow(f2); su

文档评论(0)

1亿VIP精品文档

相关文档