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.

GenerateGraph(ImName,Dimention,RunTimes,FirstDistri,SecondDistri)
function GenerateGraph(ImName,Dimention,RunTimes,FirstDistri,SecondDistri)
%dbstop 27

NonUniNum=CalNonUniNum(ImName);
AbsError=double(uint16(NonUniNum/3));

DirName=[ImName,'Dimen',num2str(Dimention),'RandError',num2str(AbsError),'test'];
if exist(DirName)==0
   mkdir(DirName);
end


img0=double(imread([ImName,'.png']));
imwrite(mat2gray(img0),[DirName,'\',ImName,'.png'],'bitdepth',1);
img=img0;
DistTable=CalDisTable(ImName,Dimention);
[rows,cols]=find(img0~=1);
[i,j]=size(rows);
TotalDist=0;
AveDist=0;
%graph_num=0;
%splot_num=1;
%SaveDist=1;
%InitialSaveDist=SaveDist;
%IncVal=(1-SaveDist)/4;

for time=1:RunTimes
    SubNum=double(uint16(time/3000))+1;
    SubDirName=['FD',num2str(double(FirstDistri)*100),'SD',num2str(double(SecondDistri)*100),'Num',num2str(SubNum)];
    if exist([DirName,'\',SubDirName])==0
       mkdir([DirName,'\',SubDirName]);
    end
    
    img=img0;
    TotalDist=0;
       
    for m=1:AbsError
        ChoosePoint=randperm(i);
        InterIndex=ChoosePoint(1);
        RowIndex=rows(InterIndex);
        ColIndex=cols(InterIndex);
    
        FirstSelect=binornd(1,FirstDistri)+1;
        switch FirstSelect
        case 1,
            SecondSelect=binornd(1,SecondDistri);
            switch SecondSelect
            case 1,
                SelectNum=double(uint16(rand*8))+1;
                [RowLength,ColLength]=CalRandIndex(SelectNum,3);
                TotalDist=TotalDist+DistTable((RowIndex+RowLength),(ColIndex+ColLength));
                img((RowIndex+RowLength),(ColIndex+ColLength))=~img((RowIndex+RowLength),(ColIndex+ColLength));
            case 0,
                RowLength=0;
                ColLength=0;
                TotalDist=TotalDist+DistTable((RowIndex+RowLength),(ColIndex+ColLength));
                img((RowIndex+RowLength),(ColIndex+ColLength))=~img((RowIndex+RowLength),(ColIndex+ColLength));
            end
        case 2,
            SelectNum=double(uint16(rand*16))+1;
            [RowLength,ColLength]=CalRandIndex(SelectNum,5);
            TotalDist=TotalDist+DistTable((RowIndex+RowLength),(ColIndex+ColLength));
            img((RowIndex+RowLength),(ColIndex+ColLength))=~img((RowIndex+RowLength),(ColIndex+ColLength));
        end
    end
             
    absDiff=abs(img-img0);
    ErrorSum=sum(sum(absDiff));
    if AbsError==ErrorSum
        AveDist=TotalDist/AbsError;
        AveDistStr=sprintf('%.5f',AveDist);
        imwrite(mat2gray(img),[DirName,'\',SubDirName,'\',ImName,'AbsError',num2str(AbsError),'AveDist',AveDistStr,'.png'],'bitdepth',1);   
        fout=fopen([DirName,'\',SubDirName,'\','ResultNames.xls'],'a');
        fprintf(fout,'%.5f\n',AveDist);
        fclose(fout);
    end
  
end
    

Contact us