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 件のコメント

DAVID KING
DAVID KING 2016 年 1 月 17 日
編集済み: DAVID KING 2016 年 1 月 17 日
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 2017 年 5 月 19 日
hi, what is exectly your problem ?

サインインしてコメントする。

回答 (2 件)

Afroja Akter
Afroja Akter 2013 年 7 月 30 日

0 投票

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 件のコメント

Soujanya Dirisinam
Soujanya Dirisinam 2015 年 2 月 25 日
im aslo getting errors while running could you plz tell me tha correct code by taking an example image
DAVID KING
DAVID KING 2016 年 1 月 17 日
If u have any query thn regarding ur project either mail at matlabprojects35@gmail.com or, https://www.facebook.com/MatlabProjects-909644652486619

サインインしてコメントする。

azz taha
azz taha 2017 年 2 月 25 日

0 投票

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 件のコメント

Walter Roberson
Walter Roberson 2017 年 2 月 25 日
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.

サインインしてコメントする。

質問済み:

2012 年 3 月 24 日

コメント済み:

2017 年 5 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by