Code covered by the BSD License  

Highlights from
Binary Image Watermarking/Data Hiding: Data, Algorithms, and Distortion Measure

Binary Image Watermarking/Data Hiding: Data, Algorithms, and Distortion Measure

by

 

26 Apr 2012 (Updated )

A package on binary image watermarking/data hiding, including data, algorithms & distortion measure.

decode_t1.m
clear all 
% scaling=90;
% bias=0.0004;

Im0_2 = imread('french-4.tif');
Im_wm=imread(['french-4-wm.tif']);%'french-4-wm.tif');
[Rows,Cols]=size(Im0_2);
RowsNum=64;%512/8
ColsNum=64;

h = fspecial('gaussian',5,1);
FImg=filter2(h,Im0_2);
length=mark_length(Im0_2,8,RowsNum,ColsNum,1);
wm_extracted=zeros(1,length);

k=1;
blkrows = 1:8;
blkcols = blkrows;
for i=0:(RowsNum-1)
   for j=0:(ColsNum-1)
      blk0_2=Im0_2(i*8+blkrows, j*8+blkcols);
      if max(max(blk0_2))~=min(min(blk0_2))
          blk0=FImg(i*8+blkrows, j*8+blkcols);
          blkdct0= dct2(blk0);

          blk_wm=Im_wm(i*8+blkrows, j*8+blkcols);
          blkdct_wm= dct2(blk_wm);
          wm_extracted(k)=blkdct_wm(1,1)-blkdct0(1,1);  %fail if blkdct_wm(1,1)/blkdct0(1,1);
          k=k+1;
    end
  end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
corrs=zeros(1,1000);
for i=1:1000
   corrs(i)=corr2(wm_extracted,randn(1,length));
end
load wm
corrs(500)=corr2(wm,wm_extracted);
disp(['Correlation is ',num2str(corrs(500))]);

diffimg=xor(Im_wm,Im0_2);

x=1:1000;
plot(x,corrs)
title(['Diff=',num2str(sum(sum(diffimg))),', PNSR=',num2str(psnr(double(Im_wm),double(Im0_2))),', Correlation=',num2str(corrs(50))]);
print(1,'-dpng','-r90',['detection.png']);
delete(1);

Contact us