Effacer les filtres
Effacer les filtres

digital image watermarking. using DWT

1 vue (au cours des 30 derniers jours)
TJ Singh
TJ Singh le 24 Mar 2012
Commenté : meziane madani le 19 Mai 2017
I'm working in digital image watermarking. I've found DWT matlab code on internet, but it can't give proper results. plz debug it, so that it works properly.
% Watermark Embeding
clear all;
% save start time
start_time=cputime;
k=2; % set the gain factor for embeding
% read in the cover object
file_name='_lena_std_bw.bmp';
cover_object=double(imread(file_name));
% determine size of watermarked image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
% read in the message image and reshape it into a vector
file_name='_copyright.bmp';
message=double(imread(file_name));
Mm=size(message,1); %Height
Nm=size(message,2); %Width
message_vector=round(reshape(message,Mm*Nm,1)./256);
[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_uint8=uint8(watermarked_image);
% write watermarked Image to file
imwrite(watermarked_image_uint8,'dwt_watermarked.bmp','bmp');
% display processing time
elapsed_time=cputime-start_time,
% display watermarked image
figure(1)
imshow(watermarked_image_uint8,[])
title('Watermarked Image')
% Watermark Recovery
clear all;
% save start time
start_time=cputime;
% read in the watermarked object
file_name='dwt_watermarked.bmp';
watermarked_image=double(imread(file_name));
% determine size of watermarked image
Mw=size(watermarked_image,1); %Height
Nw=size(watermarked_image,2); %Width
% read in original watermark
file_name='_copyright.bmp';
orig_watermark=double(imread(file_name));
% determine size of original watermark
Mo=size(orig_watermark,1); %Height
No=size(orig_watermark,2); %Width
% initalize message to all ones
message_vector=ones(1,Mo*No);
[cA1,cH1,cV1,cD1] = dwt2(watermarked_image,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mw/2,Nw/2)-0.5));
pn_sequence_v=round(2*(rand(Mw/2,Nw/2)-0.5));
correlation_h(kk)=corr2(cH1,pn_sequence_h);
correlation_v(kk)=corr2(cV1,pn_sequence_v);
correlation(kk)=(correlation_h(kk)+correlation_v(kk))/2;
end
for (kk=1:length(message_vector))
if (correlation(kk) > mean(correlation))
message_vector(kk)=0;
end
end
% reshape the message vector and display recovered watermark.
figure(2)
message=reshape(message_vector,Mo,No);
imshow(message,[])
title('Recovered Watermark')
% display processing time
elapsed_time=cputime-start_time,
  2 commentaires
DAVID KING
DAVID KING le 17 Jan 2016
Modifié(e) : DAVID KING le 17 Jan 2016
If u have any query thn regarding ur project either mail at matlabprojects35@gmail.com or, https://www.facebook.com/MatlabProjects-909644652486619. Kindly Spread it to Help Others.
meziane madani
meziane madani le 19 Mai 2017
hi, what is exectly your problem ?

Connectez-vous pour commenter.

Réponses (2)

Afroja Akter
Afroja Akter le 30 Juil 2013
could u give any code for evalution purpose like NC(NORMALISED CORRELATION),,also could u tell me why not i could not save ma image wchich has been embedded,,
  2 commentaires
Soujanya Dirisinam
Soujanya Dirisinam le 25 Fév 2015
im aslo getting errors while running could you plz tell me tha correct code by taking an example image
DAVID KING
DAVID KING le 17 Jan 2016
If u have any query thn regarding ur project either mail at matlabprojects35@gmail.com or, https://www.facebook.com/MatlabProjects-909644652486619

Connectez-vous pour commenter.


azz taha
azz taha le 25 Fév 2017
Error using reshape To RESHAPE the number of elements must not change.
Error in Untitled (line 17) message_vector=round(reshape(message,Mm*Nm,1)./256);
  1 commentaire
Walter Roberson
Walter Roberson le 25 Fév 2017
imread() returns 3 dimensional data for color images. You are extracting the rows and columns but neglecting the number of color planes.
Note: images are sometimes stored as color but look grey. Equal amounts of Red, Blue, and Green make different brightnesses of white.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by