| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 756 人关注过本帖
标题:一个数字水印的问题
只看楼主 加入收藏
我是我0322
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-7
收藏
 问题点数:0 回复次数:0 
一个数字水印的问题
毕业设计是水印的仿真实验,要求用DWT实现水印的嵌入和提取,最后进行攻击的仿真测试,包括几何攻击和拷贝攻击等等,嵌入的程序调通了,可是提取的程序最后怎么也调不出来,问题就出在最后那个水印的图像重构的问题,不知道怎么办了,各位前辈帮帮忙,不胜感激~~~~

程序代码如下:

clear all;
clc;

%保存开始时间
start_time=cputime;
figure(1);

%读出原始图像
subplot(1,2,1);
input=imread('复活之夜.bmp');
imshow(input);
title('原始图像');

%读出水印图像
subplot(1,2,2);
watermarked_image=imread('watermarked.bmp');
imshow(watermarked_image,[]);
title('水印嵌入图像');

%三色分离
input=double(input);
watermarked_image=double(watermarked_image);
inputr=input(:,:,1);
watermarked_imager=watermarked_image(:,:,1);
inputg=input(:,:,2);
watermarked_imageg=watermarked_image(:,:,2);
inputb=input(:,:,3);
watermarked_imageb=watermarked_image(:,:,3);
%------------------------------------------------------------
%水印图像R的分解
[Cwr,Swr]=WAVEDEC2(watermarked_imager,2,'haar');
%图像R的分解
[Cr,Sr]=WAVEDEC2(inputr,2,'haar');

%水印图像G的分解
[Cwg,Swg]=WAVEDEC2(watermarked_imageg,2,'haar');
%图像G的分解
[Cg,Sg]=WAVEDEC2(inputg,2,'haar');

%水印图像B的分解
[Cwb,Swb]=WAVEDEC2(watermarked_imageb,2,'haar');
%图像B的分解
[Cb,Sb]=WAVEDEC2(inputb,2,'haar');

%---------------------------------------------------------------
%提取水印的小波系数
r=0.06;
for k=0:3
    whr(k+1,:)= Cwr(1+size(Cwr,2)/4+k*size(Cwr,2)/16:...
        size(Cwr,2)/4+(k+1)*size(Cwr,2)/16)-...
        Cr(1+size(Cr,2)/4+k*size(Cr,2)/16:...
        size(Cr,2)/4+(k+1)*size(Cr,2)/16);
   
    wvr(k+1,:)= Cwr(1+size(Cwr,2)/2+k*size(Cwr,2)/16:...
        size(Cwr,2)/2+(k+1)*size(Cwr,2)/16)-...
        Cr(1+size(Cr,2)/2+k*size(Cr,2)/16:...
        size(Cr,2)/2+(k+1)*size(Cr,2)/16);
   
    wdr(k+1,:)= Cwr(1+3*size(Cwr,2)/4+k*size(Cwr,2)/16:...
        3*size(Cwr,2)/4+(k+1)*size(Cwr,2)/16)-...
        Cr(1+3*size(Cr,2)/4+k*size(Cr,2)/16:...
        3*size(Cr,2)/4+(k+1)*size(Cr,2)/16);
end
whr=(whr(1,:)+whr(2,:)+whr(3,:)+whr(4,:))/(4*r);
wvr=(wvr(1,:)+wvr(2,:)+wvr(3,:)+wvr(4,:))/(4*r);
wdr=(wdr(1,:)+wdr(2,:)+wdr(3,:)+wdr(4,:))/(4*r);
war=(Cwr(1:size(Cwr,2)/16)-Cr(1:size(Cr,2)/16))/r;

%--------------------------------------------------------------
g=0.03;
for k=0:3
    whg(k+1,:)= Cwg(1+size(Cwg,2)/4+k*size(Cwg,2)/16:...
        size(Cwg,2)/4+(k+1)*size(Cwg,2)/16)-...
        Cg(1+size(Cg,2)/4+k*size(Cg,2)/16:...
        size(Cg,2)/4+(k+1)*size(Cg,2)/16);
   
    wvg(k+1,:)= Cwg(1+size(Cwg,2)/2+k*size(Cwg,2)/16:...
        size(Cwg,2)/2+(k+1)*size(Cwg,2)/16)-...
        Cg(1+size(Cg,2)/2+k*size(Cg,2)/16:...
        size(Cg,2)/2+(k+1)*size(Cg,2)/16);
   
    wdg(k+1,:)= Cwg(1+3*size(Cwg,2)/4+k*size(Cwg,2)/16:...
        3*size(Cwg,2)/4+(k+1)*size(Cwg,2)/16)-...
        Cg(1+3*size(Cg,2)/4+k*size(Cg,2)/16:...
        3*size(Cg,2)/4+(k+1)*size(Cg,2)/16);
end
whg=(whg(1,:)+whg(2,:)+whg(3,:)+whg(4,:))/(4*g);
wvg=(wvg(1,:)+wvg(2,:)+wvg(3,:)+wvg(4,:))/(4*g);
wdg=(wdg(1,:)+wdg(2,:)+wdg(3,:)+wdg(4,:))/(4*g);
wag=(Cwg(1:size(Cwg,2)/16)-Cg(1:size(Cg,2)/16))/g;

%--------------------------------------------------------------
b=0.12;
for k=0:3
    whb(k+1,:)= Cwb(1+size(Cwb,2)/4+k*size(Cwb,2)/16:...
        size(Cwb,2)/4+(k+1)*size(Cwb,2)/16)-...
        Cb(1+size(Cb,2)/4+k*size(Cb,2)/16:...
        size(Cb,2)/4+(k+1)*size(Cb,2)/16);
   
    wvb(k+1,:)= Cwb(1+size(Cwb,2)/2+k*size(Cwb,2)/16:...
        size(Cwb,2)/2+(k+1)*size(Cwb,2)/16)-...
        Cb(1+size(Cb,2)/2+k*size(Cb,2)/16:...
        size(Cb,2)/2+(k+1)*size(Cb,2)/16);
   
    wdb(k+1,:)= Cwb(1+3*size(Cwb,2)/4+k*size(Cwb,2)/16:...
        3*size(Cwb,2)/4+(k+1)*size(Cwb,2)/16)-...
        Cb(1+3*size(Cb,2)/4+k*size(Cb,2)/16:...
        3*size(Cb,2)/4+(k+1)*size(Cb,2)/16);
end
whb=(whb(1,:)+whb(2,:)+whb(3,:)+whb(4,:))/(4*b);
wvb=(wvb(1,:)+wvb(2,:)+wvb(3,:)+wvb(4,:))/(4*b);
wdb=(wdb(1,:)+wdb(2,:)+wdb(3,:)+wdb(4,:))/(4*b);
wab=(Cwb(1:size(Cwb,2)/16)-Cb(1:size(Cb,2)/16))/b;

%---------------------------------------------------------------
[bo]

%重构水印图像
cwr=[war,whr,wvr,wdr];
swr(:,:,1)=[sqrt(size(war,2)),sqrt(size(war,2)),2*sqrt(size(war,2))];
swr(:,:,2)=[sqrt(size(war,2)),sqrt(size(war,2)),2*sqrt(size(war,2))];
wr=waverec2(cwr,swr,'haar');

cwg=[war,whg,wvg,wdg];
swg(:,:,1)=[sqrt(size(wag,2)),sqrt(size(wag,2)),2*sqrt(size(wag,2))];
swg(:,:,2)=[sqrt(size(wag,2)),sqrt(size(wag,2)),2*sqrt(size(wag,2))];
wg=waverec2(cwg,swg,'haar');

cwb=[wab,whb,wvb,wdb];
swb(:,:,1)=[sqrt(size(wab,2)),sqrt(size(wab,2)),2*sqrt(size(wab,2))];
swb(:,:,2)=[sqrt(size(wab,2)),sqrt(size(wab,2)),2*sqrt(size(wab,2))];
wb=waverec2(cwb,swb,'haar');
%------------------------------------------------------------------
[/bo]

%三色叠加
temp=size(wr);
pic=zeros(temp(1),temp(2),3);
for i=1:temp(1);
    for j=1:temp(2);
        pic(i,j,1)=wr(i,j);
        pic(i,j,2)=wg(i,j);
        pic(i,j,3)=wb(i,j);
    end;
    output=uint8(round(pic));
   
%转化为uint8
watermark_image_uint8=uint8(output);
imwrite(watermark_image_uint8,'watermark.bmp','bmp');
figure(2);
imshow(watermark_image_uint8);
title('水印');

问题出现在我标记的那段程序,希望大家帮忙~~~

[[it] 本帖最后由 我是我0322 于 2008-5-7 13:30 编辑 [/it]]
搜索更多相关主题的帖子: 数字水印 
2008-05-07 13:28
快速回复:一个数字水印的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042245 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved