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.

[Erec_noi,Erwm_noi,change]=noiseone(ImWmed,variance);
function [Erec_noi,Erwm_noi,change]=noiseone(ImWmed,variance);

%clear all 
load Results\ecc
load Results\paras
load Results\key key
%ImIn = imread(['Results\',testimg,'-wm','.tif']);
Im_wm=imnoise(ImWmed,'gaussian',0,variance);
Im_wm=im2bw(Im_wm);
ImIn=Im_wm;
[inRows, inCols]=size(ImIn);
RowsNum=double(floor(inRows/blksize));
ColsNum=double(floor(inCols/blksize));
Rows=blksize*RowsNum;
Cols=blksize*ColsNum;
Im_1=zeros(Rows,Cols);%ignore rest if blocks don't fit well. Testing purpose only. Zero-padding in practice.
Im_1=ImIn(1:Rows,1:Cols);

clear ImIn 

Im_1=double(Im_1);

% Im_1pp=ones(Rows+6,Cols+6);
% Im_1pp(4:(Rows+3),4:(Cols+3))=Im_1;
% h = fspecial('gaussian',5,1);
% FIm_1=FIm_1pp(4:(Rows+3),4:(Cols+3));

wm_2extract=zeros(RowsNum*ColsNum,1);

blkrows = 1:blksize;
blkcols = blkrows;
wk=0;
kk=0;
for i=0:(RowsNum-1)
    for j=0:(ColsNum-1)
        kk=kk+1;
        if key(kk)~=0
            blk_im1=Im_1(i*8+blkrows, j*8+blkcols);
            testdc=sum(sum(blk_im1));
            wk=wk+1;
            if testdc>key(kk)
                wm_2extract(wk)=1;  %fail if blkdct_wm(1,1)/blkdct0(1,1);
            end            
        end
    end
end

codeword_num=floor(wk/ecc_n);
wm_len=codeword_num*ecc_k;
wmecc_len=codeword_num*ecc_n;
dataextracted=wm_2extract(1:wmecc_len);
wmdecoded = decode(dataextracted,ecc_n,ecc_k,'bch/binary');

%save Results\dataextracted dataextracted wmdecoded
%disp('Data Hidden Extracted!');
load Results\datahidden
diff_data=xor(data2hide,dataextracted);
diff_wm=xor(wmb4ecc,wmdecoded);
Erwm_noi=sum(sum(diff_wm))/max(size(wmdecoded));
Erec_noi=sum(sum(diff_data))/max(size(data2hide));

diffimg=xor(Im_wm,ImWmed);
change=sum(sum(diffimg))/(Rows*Cols);

Contact us