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.

blk_scores=CalImBlkDRDM(img,this_blkrows,this_blkcols,MaskSize,WeiTable,blksize);
function  blk_scores=CalImBlkDRDM(img,this_blkrows,this_blkcols,MaskSize,WeiTable,blksize);

[Rows, Cols]=size(img);
blk_scores=ones(blksize);
tabwid=double((MaskSize-1)/2);
left_m=1+tabwid;
right_m=Rows-tabwid;
upper_n=1+tabwid;
lower_n=Cols-tabwid;
for m=this_blkrows%1:Rows
    for n=this_blkcols%1:Cols
        left_m_img=m-tabwid;
        right_m_img=m+tabwid;
        upper_n_img=n-tabwid;
        lower_n_img=n+tabwid;
        if m<left_m || m>right_m || n<upper_n || n>lower_n
            if m<left_m, left_m_img=1; end;
            if m>right_m, right_m_img=Rows; end;
            if n<upper_n, upper_n_img=1;end;
            if n>lower_n, lower_n_img=Cols;end;
            DifBlk=ones(MaskSize);
            left_m_corner=left_m_img-(m-tabwid)+1;
            right_m_corner=right_m_img-(m+tabwid)+MaskSize;
            upper_n_corner=upper_n_img-(n-tabwid)+1;
            lower_n_corner=lower_n_img-(n+tabwid)+MaskSize;
            DifBlk(left_m_corner:right_m_corner,upper_n_corner:lower_n_corner)=xor(img(left_m_img:right_m_img,upper_n_img:lower_n_img),~img(m,n));
        else
            DifBlk=xor(img(left_m_img:right_m_img,upper_n_img:lower_n_img),~img(m,n));
            %if img(m,n)==0, DifBlk=~DifBlk; end; %If 0 is flipped to 1, Difference Matrix is NOT
        end        
        DRD_blk=sum(sum(DifBlk.*WeiTable));
        %DistTable(m,n)=DRD_blk;
        blk_scores((m-this_blkrows(1)+1),(n-this_blkcols(1)+1))=DRD_blk;     
    end
end

Contact us