geogeneration
Newbie level 1
- Joined
- Mar 21, 2010
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Jordan,Amman
- Activity points
- 1,318
Hello all,
I am a having a bit of difficulty in my final graduation project and i really hope that some of you here can help me out.
my project is: adding watermark using DWT into a medical image. (i have no knowledge in watermarking)
I have the following code
%----------------------------- Watermark embedding ----------------------
% set the gain factor for embeding and threshold for evaluation
thresh=.5;
k=2;
%--------------------------------------------------------------------------
% ------------- read in the original image or the cover object ------------
%--------------------------------------------------------------------------
% read and display original image
file_name='_lena_std_bw.bmp';
I=imread(file_name);
cover_object=double(I);
%imshow(I)
%figure(1)
%imshow(cover_object,[])
%title('Original Image')
% determine size of original image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
%--------------------------------------------------------------------------
% ------------- read in the original watermark image ----------------------
%--------------------------------------------------------------------------
% read in the message image and reshape it into a vector
file_name='_copyright.bmp';
message=double(imread(file_name));
%size of the embedded watermark
Mo=size(message,1);
No=size(message,2);
N=No*Mo;
% reshape the message to a vector
message_vector=round(reshape(message,Mo*No,1)./256);
W=message_vector;
% display original watermark
%figure(2)
%imshow(message,[])
%title('Original Watermark')
%--------------------------------------------------------------------------
% -- Set Random Generator, DWT2 the original image and Embed watermark ----
%--------------------------------------------------------------------------
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
[cA1,cH1,cV1,cD1] = dwt2(cover_object,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mc/2,Nc/2)-0.5));
pn_sequence_v=round(2*(rand(Mc/2,Nc/2)-0.5));
if (message(kk) == 0)
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
end
% perform IDWT
watermarked_image = idwt2(cA1,cH1,cV1,cD1,'haar',[Mc,Nc]);
% convert back to uint8
watermarked_image_int=uint8(watermarked_image);
%--------------------------------------------------------------------------
%- write the watermarked image out to a file and display watermarked image
%--------------------------------------------------------------------------
imwrite(watermarked_image,'dwt_watermarked.bmp','bmp');
% display watermarked image
%figure(3)
%imshow(watermarked_image_int,[])
%title('Watermarked Image')
J=watermarked_image_int;
%--------------------------------------------------------------------------
My problem is in "% -- Set Random Generator, DWT2 the original image and Embed watermark ----"
how did we embed the watermark image??
I took the code from above that deals with setting random generator , DWT2 the origional image and embedding the watermark..
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
[cA1,cH1,cV1,cD1] = dwt2(cover_object,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mc/2,Nc/2)-0.5));
pn_sequence_v=round(2*(rand(Mc/2,Nc/2)-0.5));
if (message(kk) == 0)
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
end
my problem starts on line "Add pn sequence to H1 and V1 components..."
Here we are adding to each quadrant a sequence (from a Random generator) , how does that has got to do with embedding ?
please can anybody explain the code to me , i would really appreciate it
thanks in advanced
I am a having a bit of difficulty in my final graduation project and i really hope that some of you here can help me out.
my project is: adding watermark using DWT into a medical image. (i have no knowledge in watermarking)
I have the following code
%----------------------------- Watermark embedding ----------------------
% set the gain factor for embeding and threshold for evaluation
thresh=.5;
k=2;
%--------------------------------------------------------------------------
% ------------- read in the original image or the cover object ------------
%--------------------------------------------------------------------------
% read and display original image
file_name='_lena_std_bw.bmp';
I=imread(file_name);
cover_object=double(I);
%imshow(I)
%figure(1)
%imshow(cover_object,[])
%title('Original Image')
% determine size of original image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
%--------------------------------------------------------------------------
% ------------- read in the original watermark image ----------------------
%--------------------------------------------------------------------------
% read in the message image and reshape it into a vector
file_name='_copyright.bmp';
message=double(imread(file_name));
%size of the embedded watermark
Mo=size(message,1);
No=size(message,2);
N=No*Mo;
% reshape the message to a vector
message_vector=round(reshape(message,Mo*No,1)./256);
W=message_vector;
% display original watermark
%figure(2)
%imshow(message,[])
%title('Original Watermark')
%--------------------------------------------------------------------------
% -- Set Random Generator, DWT2 the original image and Embed watermark ----
%--------------------------------------------------------------------------
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
[cA1,cH1,cV1,cD1] = dwt2(cover_object,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mc/2,Nc/2)-0.5));
pn_sequence_v=round(2*(rand(Mc/2,Nc/2)-0.5));
if (message(kk) == 0)
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
end
% perform IDWT
watermarked_image = idwt2(cA1,cH1,cV1,cD1,'haar',[Mc,Nc]);
% convert back to uint8
watermarked_image_int=uint8(watermarked_image);
%--------------------------------------------------------------------------
%- write the watermarked image out to a file and display watermarked image
%--------------------------------------------------------------------------
imwrite(watermarked_image,'dwt_watermarked.bmp','bmp');
% display watermarked image
%figure(3)
%imshow(watermarked_image_int,[])
%title('Watermarked Image')
J=watermarked_image_int;
%--------------------------------------------------------------------------
My problem is in "% -- Set Random Generator, DWT2 the original image and Embed watermark ----"
how did we embed the watermark image??
I took the code from above that deals with setting random generator , DWT2 the origional image and embedding the watermark..
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
[cA1,cH1,cV1,cD1] = dwt2(cover_object,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mc/2,Nc/2)-0.5));
pn_sequence_v=round(2*(rand(Mc/2,Nc/2)-0.5));
if (message(kk) == 0)
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
end
my problem starts on line "Add pn sequence to H1 and V1 components..."
Here we are adding to each quadrant a sequence (from a Random generator) , how does that has got to do with embedding ?
please can anybody explain the code to me , i would really appreciate it
thanks in advanced