Implementing Watermarking DWT bad result?
Afficher commentaires plus anciens
I tried to implement this journal on matlab, i finally finish the code but sometimes it still give wrong output. I wanted to ask if i missed something in my code from the journal?
Embedding method :
f=wavread('classic1.wav','double');
if mod(length(f),2)~=0
f=[f 0];
end
rawsignal=f;
leftchanel=f(1:size(f),1);
rightchanel=f(1:size(f),2);
[cA1,cD1] = dwt(leftchanel,'haar');
[cA2,cD2] = dwt(cA1,'haar');
[cA3,cD3] = dwt(cA2,'haar');
l_crop=mod(length(cD3),10);
crop=cD3(end-(l_crop-1):end);
segmentT=cD3(1:end-(l_crop));
segment=buffer(segmentT,10);
m=1:10;
sumS=sum(abs(segment(m,:)));
c=sumS/10;
k=6;
l=1;
alpha=2;
Watermark='Test watermarking';
word = char(Watermark);
binary = dec2bin(word,8);
binary_t=transpose(binary);
bin=binary_t(:)-'0';
[X,Y]=size(segment);
for i=1:Y
if(l==length(bin)+1), break, end
for j=1:X
if(l==length(bin)+1), break, end
if(c(i)==0), break,end
if (abs(segment(j,i)/c(i))<(k)) && (abs(segment(j,i)/c(i))>-(k) )
if(bin(l)==1)
segment(j,i)=c(i).*alpha;
l=l+1;
elseif (bin(l)==0)
segment(j,i)=-(c(i)).*alpha;
l=l+1;
end
else
if(l==length(bin)+1), break, end
segment(j,i)=segment(j,i);
end
end
end
segmentd3=segment(:);
segmentd3(end+1:end+l_crop)=crop;
cA2=idwt(cA3,segmentd3,'haar');
cA1=idwt(cA2,cD2,'haar');
leftchanel_recon=idwt(cA1,cD1,'haar');
watermarked2=[leftchanel_recon,rightchanel];
hasil=(rawsignal-watermarked2);
wavwrite(watermarked2,44100,'watermarked.wav');
Extracting method :
f=wavread('watermarked.wav','double');
if mod(length(f),2)~=0
f=[f 0];
end
rawsignal=f;
leftchanel=f(1:size(f),1);
rightchanel=f(1:size(f),2);
[cA1,cD1] = dwt(leftchanel,'haar');
[cA2,cD2] = dwt(cA1,'haar');
[cA3,cD3] = dwt(cA2,'haar');
l_crop=mod(length(cD3),10);
crop=cD3(end-(l_crop-1):end);
segmentT=cD3(1:end-(l_crop));
segment=buffer(segmentT,10);
m=1:10;
sumS=sum(abs(segment(m,:)));
c=sumS/10;
k=6;
l=1;
alpha=2;
con=(k+alpha)/2;
[X,Y]=size(segment);
for i=1:Y
if(l==209), break, end
for j=1:X
if(l==209), break, end
if(c(i)==0), break,end
if (segment(j,i)/c(i)<(k)) && (segment(j,i)/c(i)>-(k) )
if (segment(j,i)/c(i)<=con) && (segment(j,i)/c(i)>=0)
watermark(l,1)=1;
l=l+1;
elseif (segment(j,i)/c(i)>=-con) && (segment(j,i)/c(i)<0)
watermark(l,1)=0;
l=l+1;
end
end
end
end
hasil=char(bin2dec(reshape(num2str(watermark),8,[]).')).';
1 commentaire
AQ
le 26 Juin 2013
Hi, Have you been able to get the correct output? Regards
Réponses (0)
Catégories
En savoir plus sur Discrete Multiresolution Analysis dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!