# 双倒谱数字图像水印算法

• y8_303623
了解作者
• 1.5KB
文件大小
• rar
文件格式
• 0
收藏次数
• VIP专享
资源类型
• 0
下载次数
• 2022-05-25 01:05
上传日期

main_yuanshi_hanshuiyin_weiyixing.rar
• main_yuanshi_hanshuiyin_weiyixing.m
5.1KB

clear all clc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %读取原始灰度图像，并得到相应的double类型。 source_image=imread('Stream and bridge.tif'); source_image1=double(source_image); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %得到原始图像的尺寸大小：行数MM和列数NN。 I=source_image1; [MM,NN]=size(I); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %定义分块后子块的行数和列数，m表示行数，n表示列数。 m=8; n=8; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %得到子块的个数：M表示行数，N表示列数。 M=fix(MM/n); N=fix(NN/m); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %生成由约束长度yueshu产生的伪随机水印信息watermarkr。 yueshu=log2(M*N); watermarkr=weisuiji_generator(yueshu); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %水印嵌入强度arlfa. arlfa=0.01; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %水印的嵌入过程. block=zeros(m,n); k=1; Y=I; for i0=1:M for j0=1:N for p=1:m for q=1:n block(p,q)=Y(m*(i0-1)+p,n*(j0-1)+q); end end %得到需要嵌入水印的子块矩阵； x=bicceps(block); %对子块进行双倒谱变换； ampli=abs(x); angl=angle(x); %得到幅度信息ampli和相位信息angl； angl1=angl; ccc=imag(x); bbb=any(any(ccc)); if bbb==1 for ii1=1:2:m for jj1=1:2:n angl1(ii1,jj1)=angl(ii1,jj1)+arlfa*watermarkr(k); end end k=k+1; end y2=ampli.*exp(j*angl1); y=ibicceps(y2); %对得到的复数矩阵进行逆双倒谱变换； for p=1:m for q=1:n Y(m*(i0-1)+p,n*(j0-1)+q)=y(p,q); end end %得到嵌入水印信息后的子块矩阵； end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %得到含水印图像，类型为double。 watermarked_image1=Y; watermarked_image=uint8(watermarked_image1); PSNR=PSNR_calculate(source_image1,watermarked_image1) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %画仿真图：包括原始图像，含水印图像和水印信息。 figure (1); % subplot(1,2,1); imshow(source_image); % title('原始图像'); figure (2); % subplot(1,2,2); imshow(watermarked_image); % title('含水印图像'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %水印的提取过程. block=zeros(m,n); block1=zeros(m,n); k=0; YY=watermarked_image1; Y1=I; kk=1; for i0=1:M for j0=1:N for p=1:m for q=1:n block(p,q)=YY(m*(i0-1)+p,n*(j0-1)+q); block1(p,q)=Y1(m*(i0-1)+p,n*(j0-1)+q); end end %得到需要嵌入水印的子块矩阵； x=bicceps(block); %对子块进行双倒谱变换； x1=bicceps(block1); angl1=angle(x); angl2=angle(x1); ccc=imag(x1); bbb=any(any(ccc)); if bbb==1 for ii1=1:2:m for jj1=1:2:n iii1 = (ii1-1)/2+1; jjj1 = (jj1-1)/2+1; angl11(iii1,jjj1)=angl1(ii1,jj1); angl22(iii1,jjj1)=angl2(ii1,jj1); end end yy1(kk)=sum(sum(angl11-angl22)); if yy1(kk)>0 watermark1(kk)=1; else watermark1(kk)=-1; end kk=kk+1; end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %水印的检测. watermark11=[watermark1,watermarkr(kk:M*N)]; watermark2=watermarkr; m=0; for i1=1:length(watermark2) if watermark11(i1)==watermark2(i1) m=m+1; end end rightrate=m./(length(watermark2)) temp1=watermark11.*watermark2; temp2=watermark2.*watermark2; NC=(sum(temp1)/sqrt(sum(temp2))) waterrr = randn(1000,4096); for i = 1:1000 for j=1:4096 if waterrr(i,j) == 0 waterrr(i,j) = -1; end if i == 200 waterrr(i,:)=watermark11; end end end for i=1:1000 temp = waterrr(i,:); temp1 = temp .* watermark2; NC1(i) = sum(temp1)./ sqrt(4096); end figure (3) plot(NC1) xlabel('随机水印序列') ylabel('水印检测器响应/sim')

相关推荐
• 算法
算法 算法
• 程序员算法
这是一个算法文档压缩包，其中包括《可能与不可能的边界》、《具体数学》、《算法的乐趣》、《啊哈！算法》。这些书很适合对算法感兴趣的朋友，书籍讲解算法非常有趣。注意，其中有些文档是试读版本。
• 算法实验
算法实验算法实验算法实验算法实验算法实验算法实验算法实验算法实验
• SIFT 算法
SIFT 算法SIFT 算法SIFT 算法SIFT 算法
• RSA算法
RSA算法是公钥加密算法中重要的算法之一，本算法即实现RSA的加解密过程。
• 分词算法介分词算法
算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语分词介绍分词算法 汉语...
• unify算法
unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法unify算法
• 寻路算法
寻路算法 寻路封装
• dsp算法算法算法算法
dsp各种算法
• 大数据算法
本书共分为10章，第1章概述大数据算法，第2章介绍时间亚线性算法，第3章介绍空间亚线性算法，第4章概述外存算法，第5章介绍大数据外存查找结构，第6章讲授外存图数据算法，第7章概述MapReduce算法，第8章通过一系列...