1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| x=imread('lena.gif');
subplot(2,2,1);
imshow(x);
title('Image originale');
[M,M]=size(x);
z = randn(M); % the watermark has a normal distribution (pseudo-random sequence)
subplot(2,2,2);
imshow(z);
title('mark');
y=zeros(M,M); %declaration de la matrice nulle de meme dimension aque x
%%%%%%%%%%%%%%%%%%%% calcul de DTC de X %%%%%%%%%%%%%%%%%%%
%Calcul of the coefficients of tranformes dct
%u,v are the indices dof the new matriix y
%i,j are the indices of the matrix x
for u=0:M-1
for v=0:M-1
for i=0:M-1
for j=0:M-1
%Test permettant de determiner la valeur des variables C1 et C2
if u==0
c1=1/sqrt(2);
else
c1=1;
end;
if v==0
c2=1/sqrt(2);
else
c2=1;
end
y(u+1,v+1)=y(u+1,v+1)+1/sqrt(2*M)*c1*c2*x(i+1,j+1)*cos(pi*u/M*(i+1/2))*cos(pi*v/M*(j+1/2));
end;
end;
end;
end;
%%%%%%%%%%%%%%%%%%%%% calcul de l'image tatouee(w)=image originale+ marque z %%%%%%%%%%%%%%%%%%%
for i=1:M
for j=1:M
w(i,j) = y(i,j) + z(i,j); % calcul de l'image tatouee(w)=image originale+ marque z
end
end
%%%%%%%%%%%%%%%%%%%% calcul de IDTC de w %%%%%%%%%%%%%%%%%%%
[N,N]=size(w);
%declaration d'une matrice nulle de meme dimension que w
b=zeros(N,N);
for i=0:N-1
for j=0:N-1
for u=0:N-1
for v=0:N-1
%Test permettant de determiner la valeur des variables C1 et C2
if u==0
c1=1/sqrt(2);
else
c1=1;
end;
if v==0
c2=1/sqrt(2);
else
c2=1;
end;
b(i+1,j+1)=b(i+1,j+1)+1/sqrt(2*N)*c1*c2*w(u+1,v+1)*cos(pi*u/N*(i+1/2))*cos(pi*v/N*(j+1/2));
end;
end;
end;
end;
subplot(2,2,3);
imshow(b);
title('Image marqueé'); |
Partager