Extract watermark from any size image ?
1 view (last 30 days)
Show older comments
I wanna to generalize this extraction code to work to any image size , It was basically for only extraction 512*512 Image , I waana make it work for any Image size so I can later on extract the watermark from comressid image and cropped image could any one help, please? Here is the code
function [wm]=exwmarkGeneral()
% exwmark will extract the watermark which were
% embedded by the wtmark function
% embimg = Embedded image
% wt = Extracted Watermark
embimg=imread('cout.jpg');
[rows, columns , numberOfColorBands] = size(embimg);
% figure(1),imshow(EmbeddedImage),title('EmbeddedImage');
m=embimg;
%==========================================================================
blockSizeR = 8; % Rows in block.
blockSizeC = 8; % Columns in block.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = blockSizeR * ones(1, wholeBlockRows);
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = blockSizeC * ones(1, wholeBlockCols);
ca=mat2cell(m,blockVectorR,blockVectorC);
numplotR=size(ca,1);
numplotC=size(ca,2);
%%%%%%%%%%%%%%%%%To divide image in to 4096---8X8 blocks %%%%%%%%%%%%%%%%%%
k=1; dr=0; dc=0;
% dr is to address 1:8 row every time for new block in x
% dc is to address 1:8 column every time for new block in x
% k is to change the no. of cell
for ii=1:8:numplotR % To address row -- 8X8 blocks of image
for jj=1:8:numplotC % To address columns -- 8X8 blocks of image
for i=ii:(ii+7) % To address rows of blocks
dr=dr+1;
for j=jj:(jj+7) % To address columns of block
dc=dc+1;
z(dr,dc)=m(i,j);
end
dc=0;
end
x{k}=z; k=k+1;
z=[]; dr=0;
end
end
nn=x;
%%Extract water mark %%
wm=[]; wm1=[]; k=1; wmwd=[]; wmwd1=[]
while(k<1025)
for i=1:32
kx=x{k}; % Extracting Blocks one by one
dkx=blkproc(kx,[8 8],@dct2); % Applying Dct
nn{k}=dkx; % Save DCT values in new block to cross check
%%Change me for pixel location
wm1=[wm1 dkx(8,8)]; % Forming a row of 32 by 8,8 element
% Extracting water mark without dct
wmwd1=[wmwd1 kx(8,8)];
k=k+1;
end
wm=[wm;wm1]; wm1=[]; % Forming columns of 32x32
wmwd=[wmwd;wmwd1]; wmwd1=[];
end
for i=1:32
for j=1:32
diff=wm(i,j) ;
if diff >=0
wm(i,j)=0;
elseif diff < 0
wm(i,j)=1;
end
end
end
wm=wm';
imwrite(wm,'wexg.jpg');
imshow('wexg.jpg');
Answers (1)
Saira Khalid
on 21 Jul 2018
blockSizeR = 8; % Rows in block.
blockSizeC = 8; % Columns in block.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = blockSizeR * ones(1, wholeBlockRows);
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = blockSizeC * ones(1, wholeBlockCols);
ca=mat2cell(m,blockVectorR,blockVectorC);
numplotR=size(ca,1);
numplotC=size(ca,2);
i think there is no need of this code .. Make it comment and run
and also Show your embedding code here..
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!