i'm working on my 4th year final project . i'm implementing image watermarking in dwt-svd hybrid domain .. i'm able to do the embedding part .. but cannot add noise and the extraction part ...


%


clear;
clc
img= imread('lena.bmp');
img=imresize(img,[256 256]);
[M,N]=size(img);
img=double(img);
[ca1,ch1,cv1,cd1]=dwt2(img,'haar');
[ca2,ch2,cv2,cd2]=dwt2(ca1,'haar');
[ca3,ch3,cv3,cd3]=dwt2(ca2,'haar');
[U1img,S1img,V1img]=svd(ca3);
S1img_temp=S1img;


img_wat= imread('juit.bmp');
img_wat=imresize(img_wat,[32 32]);


alfa= input('The alfa Value = ');
[x y]=size(img_wat);
img_wat=double(img_wat);
% [caw2,chw2,cvw2,cdw2]=dwt2(img_wat,'haar');
[u11 s11 v11]=svd(img_wat);
S1img =S1img + alfa * s11;

[U_SHL_w1,S_SHL_w1,V_SHL_w1]=svd(S1img);

Wimg1 =U1img* S_SHL_w1 * V1img';
Wimg2= idwt2(Wimg1,ch3,cv3,cd3,'haar',[M,N]);
Wimg3= idwt2(Wimg2,ch2,cv2,cd2,'haar',[M,N]);
Wimg4= idwt2(Wimg3,ch1,cv1,cd1,'haar',[M,N]);
figure(1)
imshow(uint8(img));
title('The Original Image')
figure(2)
imshow(uint8(img_wat));
title('The Watermark ')
figure(3)
imshow(uint8(Wimg4));
title('The Watermarked Image')










mse=mean(squeeze(sum(sum((double(img)-double(Wimg4)).^2))/(M*N)));
PSNR=10*log10(255^2./mse);
msg=sprintf('\n\n-------------------------\nWatermark by SVD PSNR=%fdB\n-----------------------------\n\n', PSNR);
disp(msg);

nimg=imnoise(Wimg4 ,'speckle');
mse=mean(squeeze(sum(sum((double(img)-double(nimg)).^2))/(M*N)));
PSNR=10*log10(255^2./mse);
msg=sprintf('\n\n-------------------------\nWatermark by SVD PSNR with noise speckle=%fdB\n-----------------------------\n\n', PSNR);
disp(msg);


n1img=imnoise(Wimg4 ,'poisson');
mse=mean(squeeze(sum(sum((double(img)-double(n1img)).^2))/(M*N)));
PSNR=10*log10(255^2./mse);
msg2=sprintf('\n\n-------------------------\nWatermark by SVD PSNR with noise poisson=%fdB\n-----------------------------\n\n', PSNR);
disp(msg2);

J = medfilt2(Wimg4);
r=corr2(Wimg4,J);
msg1=sprintf('\n\n------------------------\n Correlation Coefficient=%fdB \n------------------------\n\n',r);
disp(msg1);

%










[ca111,ch111,cv111,cd111]=dwt2(Wimg4,'haar');
[ca222,ch222,cv222,cd222]=dwt2(ca111,'haar');
[ca333,ch333,cv333,cd333]=dwt2(ca222,'haar');


[U1Wimg S1Wimg V1Wimg]=svd(ca333);
% [U2Wimg S2Wimg V2Wimg]=svd(ch111);
% [U3Wimg S3Wimg V3Wimg]=svd(cv111);
% [U4Wimg S4Wimg V4Wimg]=svd(cd111);
% D_1=U_SHL_w1 * S1Wimg * V_SHL_w1';
% D_2=U_SHL_w2 * S2Wimg * V_SHL_w2';
% D_3=U_SHL_w3 * S3Wimg * V_SHL_w3';
% D_4=U_SHL_w4 * S4Wimg * V_SHL_w4';


Watermark1= (S1Wimg- S1img_temp)/alfa ;
% Watermark2= (D_2- S2img_temp)/alfa ;
% Watermark3= (D_3- S3img_temp)/alfa ;
% Watermark4= (D_4- S4img_temp)/alfa ;
%

[Uw1 Sw1 Vw1]=svd(Watermark1);
% [Uw2 Sw2 Vw2]=svd(Watermark2);
% [Uw3 Sw3 Vw3]=svd(Watermark3);
% [Uw4 Sw4 Vw4]=svd(Watermark4);
w1=u11*Sw1*v11;
% w2=u22*Sw2*v22;
% w3=u33*Sw3*v33;
% w4=u44*Sw4*v44;
% Watermark=idwt2(w1,w2,w3,w4,'haar',[M,N]);



figure(8)
imshow(uint8(w1));
mse=mean(squeeze(sum(sum((double(img_wat)-(double(w1))).^2))/(M*N)));
PSNR=10*log10(255^2./mse);
msg=sprintf('\n\n-------------------------\nWatermark by SVD PSNR=%fdB\n-----------------------------\n\n', PSNR);
disp(msg);