X1=imread('aav.jpg');
Y1=rgb2gray(X1);
X2=imread('kh1.jpg');
Y2=rgb2gray(X2);

Y1=double(Y1)/255;
Y2=double(Y2)/255;

%ff1=fft2(Y1,370,322);
%ff2=fft2(Y2,370,322);

s1=size(Y1);
s2=size(Y2);

ff1=fft2(Y1,s1(1),s2(2));
ff2=fft2(Y2,s1(1),s2(2));
ro1=abs(ff1);
ro2=abs(ff2);
theta1=angle(ff1);
theta2=angle(ff2);
 p=randn(s1,s2);

new_ff1=ro1.*exp(j*p(455,545));

%new_ff1=ro1.*exp(j*theta2);
new_ff2=ro2.*exp(j*theta1);

Z1=ifft2(new_ff1);
Z2=ifft2(new_ff2);
figure(1);
subplot(221);
imshow((Z1));
subplot(222);
imshow((Z2));
subplot(223);
imshow(Y1);
subplot(224);
imshow(Y2);