%JPEG压缩
WImage5=idctF1;
WImage5=im2double(WImage5);
cnum=10;
dctm=dctmtx(8);
P1=dctm;
P2=dctm.';
imageDCT=blkproc(WImage5,[8,8],'P1*x*P2',dctm,dctm.');
DCTvar=im2col(imageDCT,[8,8],'distinct').';
n=size(DCTvar,1);
DCTvar=(sum(DCTvar.*DCTvar)-(sum(DCTvar)/n).^2)/n;
[dum,order]=sort(DCTvar);
cnum=64-cnum;
Mask=ones(8,8);
mask(order(1:cnum))=zeros(1,cnum);
im88=zeros(9,9);
im88(1:8,1:8)=mask;
im128128=kron(im88(1:8,1:8),ones(16));
dctm=dctmtx(8);
P1=dctm.';
P2=mask(1:8,1:8);
P3=dctm;
WImage5=blkproc(imageDCT,[8,8];'P1*(x.*P2)*P3',dctm.',mask(1:8,1:8),dctm);
figure;
imshow(WImage5,[]);
title('JPEG压缩');
watermark_detect(WImage5,Y1,I0,waterMark1,alfa);
WImage5=idctF1;
WImage5=im2double(WImage5);
cnum=10;
dctm=dctmtx(8);
P1=dctm;
P2=dctm.';
imageDCT=blkproc(WImage5,[8,8],'P1*x*P2',dctm,dctm.');
DCTvar=im2col(imageDCT,[8,8],'distinct').';
n=size(DCTvar,1);
DCTvar=(sum(DCTvar.*DCTvar)-(sum(DCTvar)/n).^2)/n;
[dum,order]=sort(DCTvar);
cnum=64-cnum;
Mask=ones(8,8);
mask(order(1:cnum))=zeros(1,cnum);
im88=zeros(9,9);
im88(1:8,1:8)=mask;
im128128=kron(im88(1:8,1:8),ones(16));
dctm=dctmtx(8);
P1=dctm.';
P2=mask(1:8,1:8);
P3=dctm;
WImage5=blkproc(imageDCT,[8,8];'P1*(x.*P2)*P3',dctm.',mask(1:8,1:8),dctm);
figure;
imshow(WImage5,[]);
title('JPEG压缩');
watermark_detect(WImage5,Y1,I0,waterMark1,alfa);