数字水印图像的嵌入与提取源代码

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

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

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

资源描述

clearall;closeall;clc;M=256;%原图像长度N=64;%水印长度[filename1,pathname]=uigetfile('*.*','selecttheimage');image1=imread(num2str(filename1));subplot(2,2,1);imshow(image1);title('原图');%orginalimageforwatermarkingimage1=double(image1);imagew=imread('shuiyin.bmp');imagew=im2bw(imagew,0.5);subplot(2,2,2);imshow(imagew);title('原水印');%originalwatermark%嵌入水印[ca,ch,cv,cd]=dwt2(image1,'db1');[cas,chs,cvs,cds]=dwt2(ca,'db1');fori=1:Nforj=1:Nifimagew(i,j)==0a=-1;elsea=1;endCa(i,j)=cas(i,j)*(1+a*0.03);endendIM=idwt2(Ca,chs,cvs,cds,'db1');markedimage=double(idwt2(IM,ch,cv,cd,'db1'));%显示嵌入后水印图像subplot(2,2,3);colormap(gray(256));image(markedimage);title('含水印图');imwrite(markedimage,gray(256),'watermarked.bmp','bmp');%提取水印image1=imread(num2str(filename1));image1=double(image1);imaged=imread('watermarked.bmp');[ca,ch,cv,cd]=dwt2(image1,'db1');[cas,chs,cvs,cds]=dwt2(ca,'db1');[caa,chh,cvv,cdd]=dwt2(imaged,'db1');[caas,chhs,cvvs,cdds]=dwt2(caa,'db1');forp=1:Nforq=1:Na=caas(p,q)/cas(p,q)-1;ifa0W(p,q)=0;elseW(p,q)=255;endendend%显示提取的水印subplot(2,2,4);colormap(gray(256));image(W);title('从含水印图像中提取的水印');imwrite(W,gray(256),'提取的水印.bmp','bmp');

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

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

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

×
保存成功