• 大小: 553KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-28
  • 语言: 其他
  • 标签: DWT,  彩色图像  

资源简介

数字水印的经典算法源代码,对于研究数字水印编程有很大的指导意义,尤其是彩色图像编程网上更难找。

资源截图

代码片段和文件信息

function dwtgl
clear all
clc;
%保存开始时间
start_time=cputime;
figure(1);
%读出原始图像
subplot(221);
input=imread(‘image.bmp‘);
imshow(input);
title(‘原始图像‘);
%读出水印
subplot(222);
water=imread(‘watermark.bmp‘);
imshow(water);
title(‘水印‘);
%三色分离
input=double(input);
water=double(water);
inputr=input(::1);
waterr=water(::1);
inputg=input(::2);
waterg=water(::2);
inputb=double(input(::3));
waterb=double(water(::3));
%系数r大,增加鲁棒性,r小增加透明性
r=0.04;
%水印R的分解
[CwrSwr]=wavedec2(waterr1‘haar‘);
%图像R的分解
[CrSr]=wavedec2(inputr2‘haar‘);
%水印的嵌入
Cr(1:size(Cwr2)/16)=...
    Cr(1:size(Cwr2)/16)+r*Cwr(1:size(Cwr2)/16);
k=0;
while k<=size(Cr2)/size(Cwr2)-1
    Cr(1+size(Cr2)/4+k*size(Cwr2)/4:size(Cr2)/4+...
        (k+1)*size(Cwr2)/4)=Cr(1+size(Cr2)/4+...
        k*size(Cwr2)/4:size(Cr2)/4+(k+1)*size(Cwr2)/4)+...
        r*Cwr(1+size(Cwr2)/4:size(Cwr2)/2);
    Cr(1+size(Cr2)/2+k*size(Cwr2)/4:size(Cr2)/2+...
        (k+1)*size(Cwr2)/4)=Cr(1+size(Cr2)/2+...
        k*size(Cwr2)/4:size(Cr2)/2+(k+1)*size(Cwr2)/4)+...
        r*Cwr(1+size(Cwr2)/2:3*size(Cwr2)/4);
    Cr(1+3*size(Cwr2)/4+k*size(Cwr2)/4:3*size(Cwr2)/4+...
        (k+1)*size(Cwr2)/4)=Cr(1+3*size(Cr2)/4+...
        k*size(Cwr2)/4:3*size(Cr2)/4+(k+1)*size(Cwr2)/4)+...
        r*Cwr(1+3*size(Cwr2)/4:size(Cwr2));
    k=k+1;
end;
Cr(1:size(Cwr2)/4)=Cr(1:size(Cwr2)/4)+r*Cwr(1:size(Cwr2)/4);
g=0.02;
%水印G的分解
[CwgSwg]=WAVEDEC2(waterg1‘haar‘);
%图像G的分解
[CgSg]=WAVEDEC2(inputg2‘haar‘);
%水印的嵌入
Cg(1:size(Cwg2)/16)=...
    Cg(1:size(Cwg2)/16)+g*Cwg(1:size(Cwg2)/16);
k=0;
while k<=size(Cg2)/size(Cwg2)-1
    Cg(1+size(Cg2)/4+k*size(Cwg2)/4:size(Cg2)/4+...
        (k+1)*size(Cwg2)/4)=Cg(1+size(Cg2)/4+...
        k*size(Cwg2)/4:size(Cg2)/4+(k+1)*size(Cwg2)/4)+...
        g*Cwg(1+size(Cwg2)/4:size(Cwg2)/2);
    Cg(1+size(Cg2)/2+k*size(Cwg2)/4:size(Cg2)/2+...
        (k+1)*size(Cwg2)/4)=Cg(1+size(Cg2)/2+...
        k*size(Cwg2)/4:size(Cg2)/2+(k+1)*size(Cwg2)/4)+...
        g*Cwg(1+size(Cwg2)/2:3*size(Cwg2)/4);
    Cg(1+3*size(Cg2)/4+k*size(Cwg2)/4:3*size(Cg2)/4+...
        (k+1)*size(Cwg2)/4)=Cg(1+3*size(Cg2)/4+...
        k*size(Cwg2)/4:3*size(Cg2)/4+(k+1)*size(Cwg2)/4)+...
        g*Cwg(1+3*size(Cwg2)/4:size(Cwg2));
    k=k+1;
end;
Cg(1:size(Cwg2)/4)=Cg(1:size(Cwg2)/4)+g*Cwg(1:size(Cwg2)/4);
b=0.16;
%水印B的分解
[CwbSwb]=WAVEDEC2(waterb1‘haar‘);
%图像B的分解
[CbSb]=WAVEDEC2(inputb2‘haar‘);
%水印的嵌入
Cb(1:size(Cwb2)/16)+b*Cwb(1:size(Cwb2)/16);
k=0;
while k<=size(Cb2)/size(Cwb2)-1
    Cb(1+size(Cb2)/4+k*size(Cwb2)/4:size(Cb2)/4+...
        (k+1)*size(Cwb2)/4)=Cb(1+size(Cb2)/4+...
        k*size(Cwb2)/4:size(Cb2)/4+(k+1)*size(Cwb2)/4)+...
        g*Cwb(1+size(Cwb2)/4:size(Cwb2)/2);
    Cb(1+size(Cb2)/2+k*size(Cwb2)/4:size(Cb2)/2+...
        (k+1)*size(Cwb2)/4)=Cb(1+size(Cb2)/2+...
        k*size(Cwb2)/4:size(Cb2)/2+(k+1)*size(Cwb2)/4)+..

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     786486  2007-05-27 12:52  image.bmp

     文件     196662  2007-05-10 10:58  watermark.bmp

     文件       3978  2008-03-01 21:11  dwt.m

     文件       4611  2008-02-27 20:12  tiqu.m

----------- ---------  ---------- -----  ----

               991955                    5


评论

共有 条评论