1 简介 文章对DCT(离散余弦变换)和FFT域图像数字水印算法进行了研究,并用matlab工具进行实验,结果表明该算法使水印的嵌入达到了较好的鲁棒性和不可见性. 2 部分代码 function [message_vec
1 简介
文章对DCT(离散余弦变换)和FFT域图像数字水印算法进行了研究,并用matlab工具进行实验,结果表明该算法使水印的嵌入达到了较好的鲁棒性和不可见性.
2 部分代码
function [message_vector,Mo,No] = dwtrecover(watermrkd_img,k,message)watermarked_image= watermrkd_img;
% determine size of watermarked image
Mw=size(watermarked_image,1); %Height
Nw=size(watermarked_image,2); %Width
Ow=size(watermarked_image,3);
% read in original watermark
orig_watermark=double(message);
% determine size of original watermark
Mo=size(orig_watermark,1); %Height
No=size(orig_watermark,2); %Width
% read in key for PN generator
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
j = 1;
for i =1:length(key)
rand('state',key(i,j));
end
message_vector=ones(1,Mo*No);
[cA1,cH1,cV1,cD1] = dwt2(watermarked_image,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mw/2,Nw/2,Ow)-0.5));
pn_sequence_v=round(2*(rand(Mw/2,Nw/2,Ow)-0.5));
if (message(kk) == 0)
% cH1(:,:,1)=cH1(:,:,1)+k*pn_sequence_h;
% cV1(:,:,1)=cV1(:,:,1)+k*pn_sequence_v;
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
cor_h(kk)=corr2(pn_sequence_h(:,:,1),cH1(:,:,1));
cor_v(kk)=corr2(pn_sequence_v(:,:,1),cV1(:,:,1));
if cor_h(kk) > cor_v(kk)
message_vector(kk)=0;
else
message_vector(kk)=1;
end
end
end
3 仿真结果
4 参考文献
[1]吴和静, 闵昆龙, 刘芳,等. 基于DCT域的图像数字水印算法及matlab实现[J]. 中国科技信息, 2014(9):2.