I want a image. Firstly I want to do fourier transform and get the magnitude and phase information. And then make a new random phase, finally use the changed random phase and original magnitude to make the inverse fourier transform. But I can not achieve it?
The code is shown here.
img = imread('flag.jpg'); imafft = fftn(double(img)); mag = abs(imafft); phi= angle(imafft); s= size (img); rand_phase= 4*pi*(rand(s(1),s(2))-0.5); newfft = mag.*exp(i*rand_phase); ima_out = ifft2(newfft); figure(2); imagesc(abs(ima_out)); axis image; title('Ramdom phase version');
The problem is in the sentence of
newfft = mag.*exp(i*rand_phase); I do not know how to modify.
Who can help me? Thank you so much.