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.

attack.m
clear all
load SecureResults\paras

ImIn = imread(['SecureResults\',testimg,'-wm-m',num2str(MaskSize),'.tif']);
ImInp = imread(['SecureResults\',testimg,'-wmp-m',num2str(MaskSize),'.tif']);

[inRows, inCols]=size(ImIn);
RowsNum=double(floor(inRows/blksize));
ColsNum=double(floor(inCols/blksize));
Rows=blksize*RowsNum;
Cols=blksize*ColsNum;
Im1=zeros(Rows,Cols);%ignore rest if blocks don't fit well. Testing purpose only. Zero-padding in practice.
Im1p=Im1;
Im1=ImIn(1:Rows,1:Cols);
Im1p=ImInp(1:Rows,1:Cols);
clear ImIn

WeiTable=WeiCal(MaskSize);

Im1=double(Im1);
Im1p=double(Im1p);
Im1p21=Im1p;
blkrows = 1:blksize;
blkcols = blkrows;

for i=0:(RowsNum-1)
    for j=0:(ColsNum-1)
        blk1=Im1(i*blksize+blkrows, j*blksize+blkcols);
        blk1p=Im1p(i*blksize+blkrows, j*blksize+blkcols);
        if max(max(blk1))==min(min(blk1))
            Im1p21(i*blksize+blkrows, j*blksize+blkcols)=blk1;
        else
            sum_blk1=sum(sum(blk1));
            sum_blk1p=sum(sum(blk1p));
            if mod(sum_blk1,2)~=mod(sum_blk1p,2)
                this_blkrows=i*blksize+blkrows;
                this_blkcols=j*blksize+blkcols;
                blk_scores=CalImBlkDRDM(Im1p,this_blkrows,this_blkcols,MaskSize,WeiTable,blksize);
                [MinRow,i1]=min(blk_scores);
                [RowMin,i2]=min(MinRow);
                row_No=i1(i2);
                col_No=i2;    
                blk1p(row_No,col_No)=~blk1p(row_No,col_No);
                %Problem: Confusion caused if after flipping, it becomes a uniform (all BLACK/WHITE) BLOCK
                Im1p21(i*blksize+blkrows, j*blksize+blkcols)=blk1p;
            end
        end
    end
end

imwrite(Im1p21, ['SecureResults\',testimg,'-wmp21-m',num2str(MaskSize),'.tif']);
diffimg=xor(Im1p,Im1p21);
imwrite(diffimg,['SecureResults\',testimg,'-difwmp-m',num2str(MaskSize),'.tif']);

Contact us