Problem in extracting the watermark ! !
Ältere Kommentare anzeigen
Dear Sir,
I have an issue in extracting the watermark..
PROPOSED APPROACH :
1.Bring the image to frequency domain by applying the DCT
2.generate a watermark signal
3.Use the thousand largest coefficients of the original image to embed a watermark sequence of length 1000.
4.Coefficients are modified according to the stream bits of the message using the equation below,
CAW = CA (1 + α Wi)
5.Extraction process – simply subtracting the original DCT coefficients from the watermarked image coefficients.
--------------------------------------------------------------------------------------------------------------------------------
*The code for embedding and extraction is as follows :*
______________________________________________________________
[fname pthname]=uigetfile('*.jpg;*.png;*.tif;*bmp','Select the Asset Image'); %select image
I=imread([pthname fname]);
wmsz=1000; %watermark size
I=I(:,:,1);%get the first color in case of RGB image
[r,c]=size(I);
D=dct2(I);%get DCT of the Asset
D_vec=reshape(D,1,r*c);%putting all DCT values in a vector
[D_vec_srt,Idx]=sort(abs(D_vec),'descend');%re-ordering all the absolute values
W=randn(1,wmsz);%generate a Gaussian spread spectrum noise to use as watermark signal
Idx2=Idx(2:wmsz+1);%choosing 1000 biggest values other than the DC value
%finding associated row-column order for vector values
IND=zeros(wmsz,2);
for k=1:wmsz
x=floor(Idx2(k)/r)+1;%associated culomn in the image
y=mod(Idx2(k),r);%associated row in the image
IND(k,1)=y;
IND(k,2)=x;
end
D_w=D;
for k=1:wmsz
%insert the WM signal into the DCT values
D_w(IND(k,1),IND(k,2))=D_w(IND(k,1),IND(k,2))+.1*D_w(IND(k,1),IND(k,2)).*W(k);
end
I2=idct2(D_w);%inverse DCT to produce the watermarked asset
%The extraction process is simply subtracting the original DCT %coefficients from the
%watermarked image ones. The code can be written like below:
W2=[];%will contain watermark signal extracted from the image
for k=1:wmsz
W2=[W2(D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10];%watermark extraction
end
_____________________________________________________________
The ERROR appears as follows in the 25th line :
??? Attempted to access W2(-0.0432565); index must be a positive integer or logical.
Error in ==> pooya at 29
W2=[W2(D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10];%watermark extraction
-----------------------------------------------------------
Please help
Thank you.
1 Kommentar
Walter Roberson
am 14 Dez. 2011
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Akzeptierte Antwort
Weitere Antworten (4)
mcc mscelec
am 18 Mär. 2012
5 Kommentare
mcc mscelec
am 18 Mär. 2012
Pardeep Kumar
am 15 Apr. 2013
Bearbeitet: Walter Roberson
am 15 Apr. 2013
plzz fix this problem ...i am facing problem in
fw=D_w((IND(k,1),IND(k,2)); and W2(k)=((D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10);
in this lines .
%WATERMARK EMBEDDING
for k=1:wmsz
fw=D_w((IND(k,1),IND(k,2));
fw=fw+0.1*fw.*W(k);
end
I2=idct2(D_w);%inverse DCT to produce the watermarked asset
I2_int=uint8(I2);
imwrite(I2_int,'I2_watermarkedn.bmp','bmp');
subplot(2,3,3),imshow('I2_watermarkedn.bmp'),title('Watermarked Image');
%WATERMARK EXTRACTION
W2=[];
for k=1:wmsz
W2(k)=((D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10);
end
Walter Roberson
am 15 Apr. 2013
What problem are you encountering, Pardeep ?
Pardeep Kumar
am 15 Apr. 2013
Bearbeitet: Walter Roberson
am 15 Apr. 2013
pls correct these errors
fw=D_w(IND(k,1),IND(k,2));
and
%WATERMARK EXTRACTION
W2=(2500000);
for k=1:wmsz
W2(k)=((D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10);
end
subplot(2,3,4),plot(W2),title('Extracted Watermark');
Walter Roberson
am 15 Apr. 2013
What error message are you seeing ?
mcc mscelec
am 14 Apr. 2012
1 Kommentar
Pardeep Kumar
am 26 Mai 2013
sir ,there is error showing in the line store(k)=WM_detect(ext_wm,orig_wm);
ie.value assigned to variable store might be unused .
Lester
am 2 Mär. 2013
0 Stimmen
sir ,
may i know what are the steps followed for embedding and extracting the image in DCT domain in the above code....???
Alaa Eleyan
am 22 Nov. 2013
0 Stimmen
the code is working properly..
You just need to add space between W2 and (D_w(....... in the for loop :
Wrong : W2=[W2(D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10];
Correct : W2=[W2 (D_w(IND(k,1),IND(k,2))/D(IND(k,1),IND(k,2))-1)*10];
Kategorien
Mehr zu Watermarking finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!