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.

DistValue=CalImDist(OriImg,DistImg,MaskSize)
function DistValue=CalImDist(OriImg,DistImg,MaskSize)
%CalImDist: calculate the distortion value after passing the original 
%image,the distorted image and the masksize, older versoin, not NUBN yet.

%Read Images
img0=double(imread([OriImg,'.png']));
img1=double(imread([DistImg,'.png']));

%Find Distorted Points
RecordMetri=img1-img0;
[rows,cols]=find(RecordMetri~=0);
RunTimes=max(size(rows));

%Calculate Normalized WeiTable
CenX=double(floor(MaskSize/2))+1;
CenY=double(floor(MaskSize/2))+1;
WeiTable=zeros(MaskSize,MaskSize);
InterWei=0;
for m=1:MaskSize
    for n=1:MaskSize
        if (m==CenX)&&(n==CenY)
           InterWei=0;
        else
           InterWei=1/sqrt((m-CenX)^2+(n-CenY)^2);
        end
        WeiTable(m,n)=InterWei;
    end
end
Total=sum(sum(WeiTable));
WeiTable=WeiTable/Total;

%Calculate Distortion Values
TotalDist=0;
length=double((MaskSize-1)/2);
for Circle=1:RunTimes
   MetriBlk=img0((rows(Circle)-length):(rows(Circle)+length),(cols(Circle)-length):(cols(Circle)+length));
   InterBlk=MetriBlk.*WeiTable;
   InterDist=sum(sum(InterBlk));
   if img0(rows(Circle),cols(Circle))==0
      InterDist=1-InterDist;
   end
   TotalDist=TotalDist+InterDist;
end
DistValue=TotalDist/RunTimes;


Contact us