课程设计所需资料.docx
- 文档编号:25548986
- 上传时间:2023-06-09
- 格式:DOCX
- 页数:10
- 大小:17.55KB
课程设计所需资料.docx
《课程设计所需资料.docx》由会员分享,可在线阅读,更多相关《课程设计所需资料.docx(10页珍藏版)》请在冰豆网上搜索。
课程设计所需资料
图像通信系统设计
摘要
本文设计了一个图像通信系统,使用Matlab编程实现图像压缩和图像重建,其中的编解码算法是基于DCT变换的JPEG图像压缩标准。
本文仿真是对512*512大小、8bit/pixel灰度、BMP典型测试图像Lena进行仿真实验。
现实环境里,图像在采集与传输过程中常常混入噪声(高斯噪声、椒盐噪声等),所以本设计测试图像时对模拟图像进行加噪。
首先用不同的去噪算法去噪(均值滤波、中值滤波、自适应中值滤波、Wiener滤波、高斯平滑滤波等),然后对去噪后的图像压缩重建,分析了压缩性能。
经仿真验证,基于DCT变换的JPEG的算法不复杂,当进行低压缩率的静止图像压缩,图像质量较高;当进行高压缩率的静止图像压缩时,图像压缩出现“模块效应”,图像质量急剧下降。
关键词:
图像通信系统;Matlab;JPEG图像压缩;噪声;压缩性能
1.在源图像上加zero-padding(为了第二部分块)
2.分块,把图像分为每个8x8(或16x16)的block(这就是为什么第一步要调整图像大小,以可以整分图像)
3.做DCT变换
4.量化(失真在这里产生)
以上步骤已经算压缩了源图像了
还可以附加一步,根据一定算法将量化好的图像进行编码,以减小文件大小
附 录
DC译码程序
function x =DCHuffmanDecoding(bit_seq,bit_len)
if (bit_len==3);
elseif(bit_len<=8 & bit_len>=5),
j=4;
elseif(bit_len==10)
j=5;
elseif(bit_len==12)
j=6;
elseif(bit_len==14)
j=7;
elseif(bit_len==16)
j=8;
elseif(bit_len==18)
j=9;
elseif(bit_len==20)
j=10;
end
m=bit_seq(j:
bit_len);
if m
(1)=='1'
val=bin2dec(m);
x=val;
Else
val=bitcmp(bin2dec(m),length(m));
x=-val;
end
维纳滤波器
I=imread('lena512.bmp');
figure; imshow(I);
figure;
title('原始图像');
[m,n]=size(I);
F=fftshift(fft2(I));
k=0.005;
for u=1:
m
for v=1:
n
H(u,v)=exp(-k)*(((u-m/2)^2+(v-n/2)^2));
end
end
G=F.*H;
I0=real(ifft2(fftshift(G)));
I1=imnoise(uint8(I0),'gaussian',0,0.001)
figure;imshow(uint8(I1));title('加噪图像');
F0=fftshift(fft2(I1));
K=0.1;
for u=1:
m
for v=1:
n
H(u,v)=exp(-k*(((u-m/2)^2+(v-n/2)^2)));
H0(u,v)=(abs(H(u,v)))^2;
H1(u,v)=H0(u,v)/(H(u,v)*(H0(u,v)+K));
end
end
F2=H1.*F0;
I2=ifft2(fftshift(F2));
figure; imshow(uint8(I2));
title('去噪图像 ');
下采样和插值程序段:
I=imread('lena512.bmp');
figure; imshow(I,[]);
[m,n]=size(I);
I1=I(1:
2:
m-1,1:
2:
n-1);
[m1,n1]=size(I1);
Re=zeros(2*m1,2*n1);
for i=1:
m1,
for j=1:
n1,
Re(2*i-1,2*j-1)=ReconImage(i,j);
end
end
figure,imshow(Re,[]);
for i=2:
m1-1,
for j=2:
n1-1,
Re(2*i,2*j)=(Re(2*i-1,2*j-1)+Re(2*i+1,2*j+1))/2;
Re(2*i,2*j-1)=(Re(2*i-1,2*j-1)+Re(2*i+1,2*j-1))/2; Re(2*i-1,2*j)=(Re(2*i-1,2*j-1)+Re(2*i-1,2*j+1))/2; end
end
Re(1,:
)=Re(2,:
);
Re(:
1)=Re(:
2);
Re(m1,:
)=Re(m1-1,:
);
Re(:
n1)=Re(:
n1-1);
figure;imshow(Re,[]);
title('重建图像')
三、实验内容及步骤
1.完成对图像加噪声,使用均值滤波器、中值滤波器对不同噪声类型、不同强度的噪声图像进行滤波处理,并评价处理的结果,进行理论上的解释。
(a)读入图像electric.tif;
(b)利用imnoise函数在图像上加入高斯噪声;
(c)利用预定义函数fspecial产生平均(average)滤波器;
(d)分别采用3×3和5×5的模板,用平均滤波器以及中值滤波器,对加入噪声的图像进行处理并观察不同噪声水平下,上述滤波器处理的结果;
(e)选择不同大小的模板,对加入某一固定噪声的图像进行处理,观察上述滤波器处理的结果;
(f)利用imnoise函数在图像上加入椒盐噪声;
(g)重复(c)~(e)的步骤;
(h)输出全部结果并进行讨论;
高斯噪声0.02,分别用3×3和5×5的模板,进行平均滤波和中值滤波
A=imread(‘cameraman.tif’);
B=im2double(A);
CX=imnoise(B,’gaussian’,0.02);
A3=fspecial(‘average’,3);
A5=fspecial(‘average’,5);
DX=filter2(A3,CX);
EX=filter2(A5,CX);
FX=medfilt2(CX,[33]);
GX=medfilt2(CX,[55]);
subplot(2,3,1),imshow(A),title(‘原图’);
subplot(2,3,2),imshow(CX),title(‘高斯噪声0.02′);
subplot(2,3,3),imshow(DX),title(‘平滤波均3×3′);
subplot(2,3,4),imshow(EX),title(‘平滤波均5×5′);
subplot(2,3,5),imshow(FX),title(‘中值滤波3×3′);
subplot(2,3,6),imshow(GX),title(‘中值滤波5×5′)
高斯噪声0.05,分别用3×3和5×5的模板,进行平均滤波和中值滤波
A=imread(‘cameraman.tif‘);
B=im2double(A);
CY=imnoise(B,’gaussian’,0.05);
A3=fspecial(‘average’,3);
A5=fspecial(‘average’,5);
DY=filter2(A3,CY);
EY=filter2(A5,CY);
FY=medfilt2(CY,[33]);
GY=medfilt2(CY,[55]);
subplot(2,3,1),imshow(A),title(‘原图’);
subplot(2,3,2),imshow(CY),title(‘高斯噪声0.05′);
subplot(2,3,3),imshow(DY),title(‘平滤波均3×3′);
subplot(2,3,4),imshow(EY),title(‘平滤波均5×5′);
subplot(2,3,5),imshow(FY),title(‘中值滤波3×3′);
subplot(2,3,6),imshow(GY),title(‘中值滤波5×5′)
椒盐噪声0.02,分别用3×3和5×5的模板,进行平均滤波和中值滤波
A=imread(‘cameraman.tif‘);
B=im2double(A);
CZ=imnoise(B,’salt&pepper’,0.02);
A3=fspecial(‘average’,3);
A5=fspecial(‘average’,5);
DZ=filter2(A3,CZ);
EZ=filter2(A5,CZ);
FZ=medfilt2(CZ,[33]);
GZ=medfilt2(CZ,[55]);
subplot(2,3,1),imshow(A),title(‘原图’);
subplot(2,3,2),imshow(CZ),title(‘椒盐噪声0.02′);
subplot(2,3,3),imshow(DZ),title(‘平滤波均3×3′);
subplot(2,3,4),imshow(EZ),title(‘平滤波均5×5′);
subplot(2,3,5),imshow(FZ),title(‘中值滤波3×3′);
subplot(2,3,6),imshow(GZ),title(‘中值滤波5×5′)
不同噪声类型和强度,滤波后进行比较:
subplot(3,5,1),imshow(CX),title(‘高斯噪声0.02′);
subplot(3,5,2),imshow(DX),title(‘平滤波均3×3′);
subplot(3,5,3),imshow(EX),title(‘平滤波均5×5′);
subplot(3,5,4),imshow(FX),title(‘中值滤波3×3′);
subplot(3,5,5),imshow(GX),title(‘中值滤波5×5′)
subplot(3,5,6),imshow(CY),title(‘高斯噪声0.05′);
subplot(3,5,7),imshow(DY),title(‘平滤波均3×3′);
subplot(3,5,8),imshow(EY),title(‘平滤波均5×5′);
subplot(3,5,9),imshow(FY),title(‘中值滤波3×3′);
subplot(3,5,10),imshow(GY),title(‘中值滤波5×5′)
subplot(3,5,11),imshow(CZ),title(‘椒盐噪声0.02′);
subplot(3,5,12),imshow(DZ),title(‘平滤波均3×3′);
subplot(3,5,13),imshow(EZ),title(‘平滤波均5×5′);
subplot(3,5,14),imshow(FZ),title(‘中值滤波3×3′);
subplot(3,5,15),imshow(GZ),title(‘中值滤波5×5′)
2.完成对图像的加噪、降噪、边缘增强
A)在MATLAB中读入名为eight.tif的图像给矩阵X,将X强制类型转换为double,最大值归一化并显示X。
B)使用imnoise函数对图像矩阵X加噪(均值为零,方差为0.005的高斯噪声),加噪后图像矩阵名为J。
C)使用平滑滤波模板和conv2函数对加噪图像进行平滑滤波即降噪,输出图像Y1并显示。
D)使用锐化滤波模板和conv2函数对图像X进行锐化滤波即边缘增强,输出图像Y2并显示。
E)在一个图形窗口中建立2×2子窗口,分别显示原始图像X,加噪图像J,降噪后图像Y1和边缘增强图像Y2。
X=imread(‘eight.tif’);
Y=double(X);
X=(255-Y)./255;
J=imnoise(X,’gaussian’,0,0.005);
d1=0.04.*[1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;1,1,1,1,1];
Y1=conv2(J,d1);
d2=[0,-1,0;-1,4,-1;0,-1,0];
Y2=conv2(X,d2);
subplot(2,2,1),imshow(X),title(‘原图’);
subplot(2,2,2),imshow(J),title(‘高斯噪声’);
subplot(2,2,3),imshow(Y1),title(‘降噪Y1′);
subplot(2,2,4),imshow(Y2),title(‘边缘增强Y2′)
3.完成图像的边缘检测
a)使用edge函数和同样的锐化滤波器对图像X进行锐化滤波即边缘增强,输出图像Y3并显示。
b)将上述得到的结果图像与第二步的边缘增强结果进行比较,给出合理的解释。
X=imread(‘eight.tif’);
Y=double(X);
X=(255-Y)./255;
J=imnoise(X,’gaussian’,0,0.005);
d2=[0,-1,0;-1,4,-1;0,-1,0];
Y2=conv2(X,d2);
Y3=edge(X,’sobel’);
subplot(1,3,1),imshow(X),title(‘原图’);
subplot(1,3,2),imshow(Y2),title(‘锐化滤波’);
subplot(1,3,3),imshow(Y3),title(‘edge函数’);
四、思考与回答:
1.结合实验内容,定性评价平均滤波器/中值滤波器对高斯噪声和椒盐噪声的去噪效果?
subplot(1,2,1),imshow(DX),title(‘高斯噪声0.02平滤波均3×3′);
subplot(1,2,2),imshow(DZ),title(‘椒盐噪声0.02平滤波均3×3′);
平均滤波对两种噪声去噪效果差不多。
subplot(1,2,1),imshow(FX),title(‘高斯噪声0.02中值滤波3×3′);
subplot(1,2,2),imshow(FZ),title(‘椒盐噪声0.02中值滤波3×3′);
中值滤波明显对椒盐噪声去噪效果好。
2.结合实验内容,定性评价滤波窗口对去噪效果的影响?
subplot(1,2,1),imshow(FZ),title(‘中值滤波3×3′);
subplot(1,2,2),imshow(GZ),title(‘中值滤波5×5′)
subplot(1,2,1),imshow(DZ),title(‘平滤波均3×3′);
subplot(1,2,2),imshow(EZ),title(‘平滤波均5×5′);
比较可知,滤波窗口越大,去噪效果越好。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课程 设计所 资料
