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.

extraction.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function encode_t1(scaling,bias) %Embedding(winsize,sigma,scaling,bias)
clear all
% blksize=8;
% MaskSize=5;
% testimg='french-4';
load HidingResults\paras
ImIn = imread(['HidingResults\',testimg,'-wm-m',num2str(MaskSize),'.tif']);

[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);
nubn_blksize=mark_length(Im_1,blksize,RowsNum,ColsNum,1);
%disp(['There are ', num2str(nubn_blksize),' non-uniform ', num2str(blksize), 'x', num2str(blksize),' blocks out of ',num2str(RowsNum*ColsNum)]);

%calculate flipping scores (DRDM)
%im_scores=CalImDRDMs(Im0,MaskSize);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dataextracted=zeros(nubn_blksize,1);

blkrows = 1:blksize;
blkcols = blkrows;
k=0;
for i=0:(RowsNum-1)
    for j=0:(ColsNum-1)
        blk0=Im_1(i*blksize+blkrows, j*blksize+blkcols);
        if max(max(blk0))~=min(min(blk0))
            k=k+1;
            sum_blk=sum(sum(blk0));
            dataextracted(k)=mod(sum_blk,2);            
        end
    end
end
save HidingResults\dataextracted dataextracted
disp('Data Hidden Extracted!');
load HidingResults\datahidden
diff=xor(datahidden,dataextracted);
error=sum(sum(diff));
disp(['Error in data extracted is ',num2str(error),' bits']);

fid=fopen(['HidingResults\',testimg,'-hiding_LOG-m',num2str(MaskSize),'.tex'],'a');
fprintf(fid,'\n\nDATA HIDDEN EXTRACTION:');
fprintf(fid,'\nThere are %d non-uniform  %d by %d, blocks out of %d blocks.',nubn_blksize,blksize,blksize,RowsNum*ColsNum);
fprintf(fid,'\nError in the hidden data extracted is %d bits.',error);
fclose(fid);

Contact us