dear sir i am doing project on watermarkimg using dct and dwt and i have a problem in extraction

1 view (last 30 days)
this is where i am not getting any idea to do with plz help me out....
imgWMrked=imread('lena.jpg');
[LL11, HL11, LH11, HH11] = dwt2(imgWMrked, 'db1');
lvl1 = [LL11, HL11;LH11, HH11];
imshow(lvl1)
% figure(2), imshow(uint8(WTr_Im_L1));
[LL22, HL22, LH22, HH22] = dwt2(HL11, 'db1');
lvl2 = [LL22, HL22;LH22, HH22];
lvl3 = [LL11, lvl2; LH11, HH11];
subplot(1,2,2),
imshow(uint8(lvl3));
title('After DWT Image')
% Divide the sub-band HL22 (or HH22 ) into 4 x 4 blocks.
[R C] = size(HL22);
startR = 1;
endR = R/4;
for m = 1:4
startC = 1;
endC = C/4;
for n = 1:4
parts(m,n) = {HL22(startR:endR, startC:endC)};
startC = startC + (C/4);
endC = endC + (C/4);
end
startR = startR + (R/4);
endR = endR + (R/4);
end
% Apply DCT to each block in the chosen sub-band (HL22).
for m = 1:4
for n = 1:4
tempData = cell2mat(parts(m,n));
dctPartsWMarkd(m,n) = {dct2(tempData)};
end
end
% Select and Re-formulate the grey-scale watermark image into a
% vector of zeros and ones.
imgMarka = imread('peppers.png');
if(~isgray(imgMarka))
imgMarka = rgb2gray(imgMarka);
imgMarkb = im2bw(imgMarka);
end
%Psuedorandom numbers generation
key0=0.3;
for i=1:200
key0=2.925*key0*(1-key0);
end
key1=3.925;
for i=1:1
for j=1:2
key0=key1*key0*(1-key0);
a(i,j)=key0;
end
end
key3=0.2;
key2=3.925;
for i=1:1
for j=1:2
key3=key2*key3*(1-key3);
b(i,j)=key3;
end
end
key16=0.3;
key2=3.925;
for i=1:1
for j=1:2
key16=key2*key16*(1-key16);
c(i,j)=key16;
end
end
t=0.16;
w0=0.2;
w1=0.5;
w2=0.3;
w=(1-t)^2*w0+2*t*(1-t)*w1+t^2*w2;
for i=1:1
for j=1:2
P(i,j)=(1-t)^2*a(i,j)*w0+2*t*(1-t)*b(i,j)*w1+t^2*c(i,j)*w2;
% d(i,j)=P(i,j)/w;
d(i,j)=P(i,j);
end
end
x=d;
e1=round(x*255);
pseudoSequence3=e1(1);
pseudoSequence4=e1(2);
% Embed the two pseudorandom sequences, PN_0 and PN_1, with a gain factor
% alpha, in the DCT transformed 4x4 blocks of the selected DWT sub-bands of
% the host image.
% extractedMark = imgMark;
alpha = 0.05;
markCount = 1;
for m = 1:4
for n = 1:4
pseudoCount = 1;
tempDataWMarkd = cell2mat(dctPartsWMarkd(m,n));
tempDataHost = cell2mat(dctPartsHost(m,n));
for i = 29:226
ind = find(index == i);
diff1 = (tempDataHost(ind)) - ((tempDataWMarkd(ind)) - ((alpha * pseudoSequence3(pseudoCount))));
diff2 = (tempDataHost(ind)) - ((tempDataWMarkd(ind)) - ((alpha * pseudoSequence4(pseudoCount))));
if abs(diff1) < abs(diff2)
extractedMark(markCount) = 0;
else
extractedMark(markCount) = 1;
end
markCount = markCount + 1;
end
dctPartsWMarkd(m,n) = {tempDataWMarkd};
end
end
figure(7),
extractedMark1=imresize(extractedMark,[256 256]);
imshow(extractedMark1)
title('Extracted WaterMark');
imwrite(extractedMark, 'extractedMark.bmp');

Answers (0)

Categories

Find more on Wavelet Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!