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.

encode_t1.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function encode_t1(scaling,bias) %Embedding(winsize,sigma,scaling,bias)
clear all
scaling=90;
bias=0.0004;
Im0_2 = imread('french-4.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);
disp(['There are ',num2str(length), ' non-uniform blocks out of ',num2str(RowsNum*ColsNum)]);
wm=randn(1,length);
I_wm=Im0_2;
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);
          blkdct0(1,1)=blkdct0(1,1)*(1+scaling* wm(k));    
          wmblk= idct2(blkdct0);
          
          blkmax=max(max(wmblk));
          blkmin=min(min(wmblk));

          Tbib=(blkmin+blkmax)*(0.5-bias);
          biwmblk=zeros(8);
          for ii=1:8
         	for jj=1:8
           		if wmblk(ii, jj)>=Tbib
             		biwmblk(ii, jj)=1;
		        else
      		        biwmblk(ii, jj)=0;
           		end
         	end
         end
         I_wm(i*8+blkrows, j*8+blkcols)=biwmblk;
         k=k+1;
       end
   end
end
save wm wm
imwrite(I_wm, ['french-4-wm.tif']);
diffimg=xor(I_wm,Im0_2);
imwrite(diffimg,['french-4-dif.tif']);
disp(['The number of changed pixels are ',num2str(sum(sum(diffimg)))]);
disp(['PNSR is ',num2str(psnr(double(I_wm),double(Im0_2)))]);

Contact us