基于MATLAB的数字图像水印技术

发布时间 : 星期四 文章基于MATLAB的数字图像水印技术更新完毕开始阅读

《MATLAB应用与通信仿真》课程设计

case 2

x0(i,5)=1;x0(i,6)=1;x0(i,7)=0; case 3

x0(i,5)=1;x0(i,6)=0;x0(i,7)=1; case 4

x0(i,5)=1;x0(i,6)=1;x0(i,7)=1; case 5

x0(i,5)=1;x0(i,6)=0;x0(i,7)=0; case 6

x0(i,5)=0;x0(i,6)=0;x0(i,7)=1; case 7

x0(i,5)=0;x0(i,6)=1;x0(i,7)=0; case 8

x0(i,5)=1;x0(i,6)=0;x0(i,7)=1; case 9

x0(i,5)=1;x0(i,6)=1;x0(i,7)=0; case 10

x0(i,5)=0;x0(i,6)=1;x0(i,7)=1; case 11

x0(i,5)=0;x0(i,6)=0;x0(i,7)=0; case 12

x0(i,5)=0;x0(i,6)=1;x0(i,7)=0; case 13

x0(i,5)=0;x0(i,6)=0;x0(i,7)=1; case 14

x0(i,5)=1;x0(i,6)=0;x0(i,7)=0; case 15

x0(i,5)=1;x0(i,6)=1;x0(i,7)=1; end; end;

21

《MATLAB应用与通信仿真》课程设计

% 对 x0 进行行向位扩展,得到一个由(-1,1)组成的扩展序列 y。其中cr 为扩展因子。 cr=256; for i=1:252 if x0(i)==1 y(i,1:cr)=1; else y(i,1:cr)=-1; end; end;

y(253:256,:)=0;

% 以下产生伪随机序列 p。为此先设定密钥(1114)并产生高斯正态分布序列g2,再由g2产生由(-1,1)组成的伪随机序列 p。 randn('state',1114); g2=randn(256,256); for i=1:256 for j=1:256 if g2(i,j)>0 p(i,j)=1; else p(i,j)=-1; end; end; end; yp=y.*p;

% 设定的每类块基准噪声阈值 jnd1 t1=1.7; t2=2.1; t3=2.5; t4=2.9; t5=3.3; t6=3.7; t7=4.1; t8=4.5;

% 读入原图象并转换成双精度,k 是 8×8 图像块数。 f0=imread('cameraman.tif'); f0=double(f0); [c,s]=size(f0);

22

《MATLAB应用与通信仿真》课程设计

k=c*s/64;

% 计算每块的方差 std2 和能量 e,并对能量 e 按升序排列。 cf0=im2col(f0,[8,8],'distinct'); std1=std(cf0); std2=std1.^2; for i=1:k

e(i)=sum(cf0(:,i).^2); end;

[e1,ind1]=sort(e);

% 按能量 e 的索引 ind1 顺序重排方差 std2,将结果存于 std3。 j=1; for i=1:k z=ind1(i); std3(j)=std2(z); j=j+1; end;

% 设定分类界限。 m1=median(std3(1:k/4)); m2=median(std3(k/4+1:k/2)); m3=median(std3(k/2+1:3*k/4)); m4=median(std3(3*k/4+1:k)); n1=e1(k/4); n2=e1(2*k/4); n3=e1(3*k/4); n4=e1(k);

% 按能量 e 和方差 std2 将原图像块分成 8 类,并给每类块赋基准噪声阈值。 for i=1:k if e(i)<=n1 if std2(i)>=m1 jnd1(i)=t1; else jnd1(i)=t2; end;

23

《MATLAB应用与通信仿真》课程设计

elseif (n1=m2 jnd1(i)=t3; else jnd1(i)=t4; end;

elseif(n2=m3 jnd1(i)=t5; else jnd1(i)=t6; end;

elseif (n3=m4 jnd1(i)=t7; else jnd1(i)=t8; end; end; end;

% 计算每类块的噪声阈值 jnd,它等于基准噪声阈值 jnd1 和附加噪声阈值 jnd2 之和。 deta=0.0035; jnd2=deta*cf0; for i=1:k

jnd(:,i)=jnd1(:,i)+jnd2(:,i); end;

% 嵌入已调制的水印信号 yp。并重构成含水印的图像 f1。 recf0=reshape(cf0,256,256); rejnd=reshape(jnd,256,256); recf1=recf0+rejnd.*yp; % 重构嵌入水印的图像 f1。 cf1=reshape(recf1,64,1024);

24

联系合同范文客服:xxxxx#qq.com(#替换为@)