subplot(2,2,1);
imshow(input);
title('原始图像');
water=imread('water.bmp');
subplot(2,2,2);
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=0.06;
[Cwr,Swr]=WAVEDEC2(waterr,2,'haar');
[Cr,Sr]=WAVEDEC2(inputr,2,'haar');
%水印的嵌入
Cr(1:size(Cwr,2)/16)=Cr(1:size(Cwr,2)/16)+r*Cwr(1:size(Cwr,2)/16);
k=0;
while k<=size(Cr,2)/size(Cwr,2)-1
Cr(1+size(Cr,2)/4+k*size(Cwr,2)/4:size(Cr,2)/4+(k+1)*size(Cwr,2)/4)=Cr(1+size(Cr,2)/4+k*size(Cwr,2)/4:size(Cr,2)/4+(k+1)*size(Cwr,2)/4+r*Cwr(1+size(Cwr,2)/4:size(Cwr,2)/2));
Cr(1+size(Cr,2)/2+k*size(Cwr,2)/4:size(Cr,2)/2+(k+1)*size(Cwr,2)/4)=Cr(1+size(Cr,2)/2+k*size(Cwr,2)/4:size(Cr,2)/2+(k+1)*size(Cwr,2)/4+r*Cwr(1+size(Cwr,2)/2:3*size(Cwr,2)/4));
Cr(1+3*size(Cr,2)/4+k*size(Cwr,2)/4:3*size(Cr,2)/4+(k+1)*size(Cwr,2)/4)=Cr(1+3*size(Cr,2)/4+k*size(Cwr,2)/4:3*size(Cr,2)/4+(k+1)*size(Cwr,2)/4+r*Cwr(1+3*size(Cwr,2)/4:size(Cwr,2)));
k=k+1;
end;
Cr(1:size(Cwr,2)/4)=Cr(1:size(Cwr,2)/4)+r*Cwr(1:size(Cwr,2)/4);