📄 dct_det.m
字号:
function QQ=dct_det(attacked,tao)
Q_table=[16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99
];
ZT=attacked;
[m n]=size(ZT);
chuangai=zeros(m,n);
quality=50;
%块dct变换
for i=1:(m/8);
for j=1:(n/8);
width=(i-1)*8+1;
height=(j-1)*8+1;
imdct(width:(width+7),height:(height+7))=dct2(ZT(width:(width+7),height:(height+7)));
end
end
%开辟要比较的数据空间
Q=zeros(1,m*n/8/8/2*6);
watermark=zeros(1,m*n/8/8*6);
%比较zig-zag前6个对应系数
k=1;
for i=1:(m/8/2);
for j=1:(n/8);
width=(i-1)*16+1;
height=(j-1)*8+1;
l=(k-1)*6+1;
if round(imdct(width,height))-round(imdct(width+8,height))<tao
Q(l)=0;
else
Q(l)=1;
end
if round(imdct(width+1,height))-round(imdct(width+9,height))<tao
Q(l+1)=0;
else
Q(l+1)=1;
end
if round(imdct(width,height+1))-round(imdct(width+8,height+1))<tao
Q(l+2)=0;
else
Q(l+2)=1;
end
if round(imdct(width,height+2))-round(imdct(width+8,height+2))<tao
Q(l+3)=0;
else
Q(l+3)=1;
end
if round(imdct(width+1,height+1))-round(imdct(width+9,height+1))<tao
Q(l+4)=0;
else
Q(l+4)=1;
end
if round(imdct(width+2,height))-round(imdct(width+10,height))<tao
Q(l+5)=0;
else
Q(l+5)=1;
end
k=k+1;
end
end
% imwrite(uint8(J2),'lena256.jpg','quality',quality);
% yy=imread('lena256.jpg');
em_cof=[1 4;2 3;3 2;4 1;4 2;3 3];
em_cof=[4 4;4 5;5 4;2 6;6 2;3 5];
NN=size(em_cof,1);
k=1;
err=0;
for i=1:(m/8/2)
for j=1:(n/8)
width=(i-1)*16;
height=(j-1)*8;
l=(k-1)*6+1;
for kk=1:3
qstep=Q_table(em_cof(kk,1),em_cof(kk,2))+1;
watermark(l)=mod(round(imdct(width+em_cof(kk,1),height+em_cof(kk,2))/qstep),2);
if watermark(l)~=Q(l)
err=err+1;
chuangai((width+1):(width+16),(height+1):(height+8))=1;
end
l=l+1;
end
width=(i-1)*16+8;
height=(j-1)*8;
for kk=4:NN
qstep=Q_table(em_cof(kk,1),em_cof(kk,2))+1;
watermark(l)=mod(round(imdct(width+em_cof(kk,1),height+em_cof(kk,2))/qstep),2);
if watermark(l)~=Q(l)
err=err+1;
chuangai((width-7):(width+8),(height+1):(height+8))=1;
end
l=l+1;
end
k=k+1;
end
end
figure(2);
imshow(logical(chuangai));
QQ=Q;
err
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -