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.

DesignNoise(ImName,Dimention,IgnoreT,blksize,IncVal,Differ,plot_rownum,plot_colnum)
function DesignNoise(ImName,Dimention,IgnoreT,blksize,IncVal,Differ,plot_rownum,plot_colnum)
%dbstop 20
if exist([ImName,'Dimention',num2str(Dimention)])==0
   mkdir([ImName,'Dimention',num2str(Dimention)]);
end
DistTable=CalDisTable(ImName,Dimention);
img0=double(imread([ImName,'.png']));
[Rows, Cols]=size(img0);
RowsNum=double(floor(Rows/blksize));
ColsNum=double(floor(Cols/blksize));
rows = 1:blksize;
cols = rows;
blksize=double(blksize);
imwrite(mat2gray(img0),[[ImName,'Dimention',num2str(Dimention)],'\',ImName,'.png'],'bitdepth',1);
img=img0;
TotalDist=0;
AveDist=0;
SaveDist=0;
NonbwNum=0;
splot_num=1;
graph_num=1;
for InterVal=IncVal:IncVal:1
    for m=1:RowsNum
       for n=1:ColsNum
           DistBlk=DistTable((m-1)*blksize+rows,(n-1)*blksize+cols);
           if mean(mean(DistBlk))>=IgnoreT
               continue
           else
           DiffBlk=abs(DistBlk-InterVal);
           [MinRow,i1]=min(DiffBlk);
           [RowMin,i2]=min(MinRow);
           row_No=i1(i2);
           col_No=i2;
           img((m-1)*blksize+row_No,(n-1)*blksize+col_No)=~img((m-1)*blksize+row_No,(n-1)*blksize+col_No);
           TotalDist=TotalDist+DistTable((m-1)*blksize+row_No,(n-1)*blksize+col_No);
           NonbwNum=NonbwNum+1;
           end
       end
   end
   AveDist=TotalDist/NonbwNum;
   if (AveDist-SaveDist)>=Differ
       SaveDist=AveDist;
       imwrite(mat2gray(img),[[ImName,'Dimention',num2str(Dimention)],'\',ImName,'flip',num2str(NonbwNum),'AveDist',num2str(AveDist),'.png'],'bitdepth',1);
      if splot_num==1
         subplot(plot_rownum,plot_colnum,splot_num),imshow(img0),title([ImName,'Dimention',num2str(Dimention)])  ;
         splot_num=splot_num+1;
      end
      if splot_num>1   
         title_name=sprintf('flip%dAveDist%.2f',NonbwNum,AveDist);
         subplot(plot_rownum,plot_colnum,splot_num),imshow(img),title(title_name)
         splot_num=splot_num+1;
      end
      if splot_num==plot_rownum*plot_colnum+1
         print(1,'-dpng','-r90',[[ImName,'Dimention',num2str(Dimention)],'\',ImName,'Dist',num2str(graph_num),'.png']);
         graph_num=graph_num+1;
         delete(1);
         splot_num=1;
      end
   end
   TotalDist=0;
   NonbwNum=0;
   img=img0;
end
if splot_num<=plot_rownum*plot_colnum
   for control=splot_num:(plot_rownum*plot_colnum)
   title_name=sprintf([ImName,'Dimention',num2str(Dimention)]);
   subplot(plot_rownum,plot_colnum,control),imshow(img0),title(title_name)
      if control==plot_rownum*plot_colnum
         print(1,'-dpng','-r90',[[ImName,'Dimention',num2str(Dimention)],'\',ImName,'Dist',num2str(graph_num),'.png']);
         graph_num=graph_num+1;
         delete(1);
      end
   end
end
    

   
       
       
           
       
           

Contact us