机械原理第九章习题

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

创新课程课后作业多媒体信息安全及其应用学生姓名杨刚学号1416240318专业班级14级计算机科学与技术3班指导教师张秋余学院计算机与通信学院成绩实验作业一DCT变换域数字水印调试一、experiment1.m调试结果:原始图像原始水印图像置乱后的水印图像含水印的图像二、experiment2.m调试结果含水印的图像提取的水印图像恢复的水印图像三、experiment3.m调试结果原始水印图像提取的水印图像NC归一化相关系数=0.9341回答NC值的大小决定了什么因素?是不是NC值越大越好?NC的值决定了原始水印和提取出来的水印大的相似度,NC值越大原始水印与提取出来的水印越相似。四、总结:数字水印是现代信号处理领域研究的热点之一,涉及图像处理、数字通信、密码学、信息安全等多学科领域,增强数字水印的鲁棒性是数字水印问题的关键。变换域技术,即把待隐藏的信息嵌入到载体的一个变换空间(如频域)中。变换域法具有可与数据压缩标准兼容的优点,对诸如压缩、剪裁和某些图像处理等攻击的鲁棒性更强。利用基于二维DCT的信息隐藏算法对图像进行的处理具有良好的安全性、不可感知性、鲁棒性和可证明性。它可以应用到静止图像水印、视频水印、版权保护、篡改提示、使用控制等领域中。在以图像为隐蔽载体的信息隐藏技术中有着广泛的应用前景。附件:程序代码experiment1.m0%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%嵌入水印%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clearcloseallW=imread('yanggang-watermark.bmp');%watermarkW应该为64*64的图像W=rgb2gray(W);W=im2bw(W,0.5);subplot(1,2,1);imshow(W);title('originalyanggang-watermark');W=Torus(W,20);%对W进行Torus变换函数待实现;subplot(1,2,2);imshow(W);title('yanggang-watermarkaftertorustransform');size1=size(W);M1=size1(1);M2=size1(2);w=zeros(1,M1*M2);forj=1:M1fori=1:M2w((i-1)*M1+j)=W(i,j);endend%将水印存入w中%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%I=imread('lena.jpg');%image256*256figure;subplot(1,2,1);imshow(I);title('originalimage');size2=size(I);N1=size2(1);N2=size2(2);n1=N1/8;n2=N2/8;fora=1:n1forb=1:n2f{a,b}=I(((a-1)*8+1):(a*8),((b-1)*8+1):(b*8));F{a,b}=dct2(f{a,b});endend%将原图分成8*8的小块,共32*32块分别做dct变换%n=(64*M1*M2)/(N1*N2);%n=4???%Q=intensity(F);%求出每块图像里被选定区域的水印嵌入强度F=embed(F,Q,w);%将水印嵌入到选定的区域上每小块嵌入4bit的水印信息%I2=zeros(256,256);forn=1:N2/8form=1:N1/8f{m,n}=idct2(F{m,n}/255);I2((m*8-7):m*8,(n*8-7):n*8)=f{m,n};endendsubplot(1,2,2);imshow(I2);%得到嵌入水印后的图像title('markedimage')imwrite(I2,'marked.bmp','bmp');savemarkedI2;Experiment2.m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%提取水印%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%I2=imread('marked.bmp');figure;imshow(I2);title('markedimage');N1=256;N2=256;n1=N1/8;n2=N2/8;fora=1:n1forb=1:n2f{a,b}=I2(((a-1)*8+1):(a*8),((b-1)*8+1):(b*8));F{a,b}=dct2(f{a,b});endendQ=intensity(F);w=pick_up(F,Q);%将水印提取出来到一维数组w里面forj=1:64fori=1:64W(i,j)=w((i-1)*64+j);endendfigure;subplot(1,2,1);imshow(W);title('pickedoutwatermark');W=Torus(W,44);subplot(1,2,2);imshow(W);title('resumedwatermark');imwrite(W,'Wpick.bmp','bmp');saveWpickW;experiment3.m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%相似度检测%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clearcloseallWori=imread('yanggang-watermark.bmp');%原始水印Wori=im2bw(Wori,0.5);Wpick=imread('Wpick.bmp');%待检测水印subplot(1,2,1);imshow(Wori);title('originalyanggang-watermark');subplot(1,2,2);imshow(Wpick);title('pickedoutyanggang-watermark');a=0;b=0;size=size(Wori);M1=size(1);M2=size(2);W1=ones(M1,M2);W2=ones(M1,M2);fori=1:M1forj=1:M2if(Wori(i,j)==0)W1(i,j)=-1;endif(Wpick(i,j)==0)W2(i,j)=-1;enda=a+W1(i,j)*W2(i,j);b=b+W2(i,j)^2;endendNC=a/b%将NC的值与阀值比较得出结论Embed.mfunctionF=embed(F,Q,w)%w=1:64.*64Fsize4=size(F);N1=size4(1);%32N2=size4(2);%32k=1;forj=1:N1fori=1:N2if(w(k)==1)F{i,j}(1,5:7)=round(F{i,j}(1,5:7)./Q{i,j}(1,5:7)).*Q{i,j}(1,5:7)+Q{i,j}(1,5:7)./2;%F{i,j}(2,5:7)=round(F{i,j}(2,5:7)./Q{i,j}(2,5:7)).*Q{i,j}(2,5:7)+Q{i,j}(2,5:7)./2;elseF{i,j}(1,5:7)=round(F{i,j}(1,5:7)./Q{i,j}(1,5:7)).*Q{i,j}(1,5:7);%F{i,j}(2,5:7)=round(F{i,j}(2,5:7)./Q{i,j}(2,5:7)).*Q{i,j}(2,5:7);endk=k+1;if(w(k)==1)F{i,j}(3,5:7)=round(F{i,j}(3,5:7)./Q{i,j}(3,5:7)).*Q{i,j}(3,5:7)+Q{i,j}(3,5:7)./2;%F{i,j}(4,4:6)=round(F{i,j}(4,4:6)./Q{i,j}(4,4:6)).*Q{i,j}(4,4:6)+Q{i,j}(4,4:6)./2;elseF{i,j}(3,5:7)=round(F{i,j}(3,5:7)./Q{i,j}(3,5:7)).*Q{i,j}(3,5:7);%F{i,j}(4,4:6)=round(F{i,j}(4,4:6)./Q{i,j}(4,4:6)).*Q{i,j}(4,4:6);endk=k+1;if(w(k)==1)F{i,j}(5,4)=round(F{i,j}(5,4)./Q{i,j}(5,4)).*Q{i,j}(5,4)+Q{i,j}(5,4)./2;elseF{i,j}(5,4)=round(F{i,j}(5,4)./Q{i,j}(5,4)).*Q{i,j}(5,4);endk=k+1;if(w(k)==1)F{i,j}(7,2)=round(F{i,j}(7,2)./Q{i,j}(7,2)).*Q{i,j}(7,2)+Q{i,j}(7,2)./2;elseF{i,j}(7,2)=round(F{i,j}(7,2)./Q{i,j}(7,2)).*Q{i,j}(7,2);endk=k+1;endEndIntensity.mfunctionQ=intensity(F)Q1=[1410111419253445;1011111215202633;1111151821253138;1412182428333947;1915212836435159;2520253343546474;3426313951647791;45333847597491108];Fdc=0;forb=1:32fora=1:32Fdc=Fdc+F{a,b}(1,1);endendFdc=Fdc/32/32;fori=1:32forj=1:32Q{i,j}=Q1*([F{i,j}(1,1)/Fdc]^0.649);forn=1:8form=1:8if(m~=1|n~=1)Q{i,j}(m,n)=max(Q{i,j}(m,n),(abs(F{i,j}(m,n)))^0.75*(Q{i,j}(m,n))^0.25);endendendendendpick_up.mfunctionw=pick_up(F,Q)size4=size(F);N1=size4(1);N2=size4(2);w=(1:64*64);k=1;forj=1:N1fori=1:N2F1=F{i,j};Q1=Q{i,j};if((mod(round(F1(1,6)./(Q1(1,6)/2)),2))==1)w(k)=1;k=k+1;elsew(k)=0;k=k+1;endif((mod(round(F1(3,6)./(Q1(3,6)/2)),2))==1)w(k)=1;k=k+1;elsew(k)=0;k=k+1;endif((mod(round(F1(5,4)./(Q1(5,4)/2)),2))==1)w(k)=1;k=k+1;elsew(k)=0;k=k+1;endif((mod(round(F1(7,2)./(Q1(7,2)/2)),2))==1)w(k)=1;k=k+1;elsew(k)=0;k=k+1;endendEndTorus.mfunctionW=Torus(W,n)%W为64*64矩阵K=64k=12;fori=1:64forj=1:64X(1,i,j)=i;Y(1,i,j)=j;endendform=1:nf

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功