基于DCT变换的信息隐藏(数字水印)嵌入算法的设计.
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
%------------------------------------------------------------------%
% 基于DCT变换的信息隐藏(数字水印嵌入算法的设计% % %-----------------------------------------------------------=------%
clear all; close all; clc
%-----------------读入"W",并进行WPP处理--------------------- wm0=imread('watermark.bmp';
% wm0=imresize(wm0,[64 64]; [Mm,Nm]=size(wm0 ; %计算水印图象的高度和宽度n=Mm*Nm;
subplot(131
imshow(wm0;
title('my watermark'; wm=double(wm0;
for i=1:Mm for j=1:Nm if wm(i,j==0 wm(i,j=-1;
end
end
end
%-----------------------读入"C",并进行CPP处理-------------------------- % cover_image=imread('cameraman.tif'; cover_image=imread('lena.bmp';
[Mc,Nc]=size(cover_image; %计算载体图象的高度和宽度
subplot(132;
imshow(cover_image;
title('my coverimage'; cover_image=double(cover_image;%读入原始宿主图象,并转换为双精度数组
%------------------分块DCT变换,嵌入水印----------------------------
%设置水印嵌入强度% k=369; k=70;
%设置嵌入位置x=3;
y=5;
%设定图象的分块大小为8*8 blocksize=8;
c=Mc/blocksize;
d=Nc/blocksize;
m=c*d;%计算图象划分的图象块
%判断载体图像尺寸是否适合水印大小if n>m error('^_^ Dear classmates~~~~~~The watermark is too large to be imbeded into the coverimage,hehe~~~';
end
%分块DCT变换,嵌入水印for j=1:c for i=1:d dct_block=dct2(cover_image((1+(j-1*8:j*8,(1+(i-1*8:i*8;
dct_block(x,y=k*wm(j,i;
watermarked_image((1+(j-1*8:j*8,(1+(i-1*8:i*8=idct2(dct_block;
end
end
%------------------------------------------------------------------
%生成并输出嵌入水印后的图象imwrite(uint8(watermarked_image,'watermarked_image.bmp','bmp';
%显示嵌入水印后的图象subplot(133;
imshow(uint8(watermarked_image
title('watermarkedImage'
隐藏信息提取程序,我写的!
clear all ; close all ; clc
%定义一个空空间来存储提取的水印wm_image=zeros(32,32;
% subplot(122; % imshow(wm_image;
%read the marked image and transfer it to double precise %-------------------------------------------------------
watermarked_image=imread('watermarked_image.bmp';
[M_marked,N_marked]=size(watermarked_image;
subplot(121;
imshow(watermarked_image;
title('The marked image' ; watermarked_image=double(watermarked_image;
blocksize=8;
k=1/70;
x=3;
y=5;
c=M_marked/blocksize;
d=N_marked/blocksize;
for j=1:c for i=1:d dct_markedblock=dct2(watermarked_image((1+(j-1*8:j*8,(1+(i-1*8:i*8;
if k*dct_markedblock(x,y>0 wm_image(j,i=1;
else
vm_image(j,i=0;
end
end
end
subplot(122;
imshow(wm_image;
title('mark image'; imwrite((wm_image,'MYwm_image.bmp','bmp';