0
votes

I am evaluating the Fourier transform of an image multiplied with a random phase mask. The random phase is so adjusted that the values of the angle (i.e A1 in the following code) of the initial quantity lies between 0 to pi. On inverse Fourier transforming the value range changes to -pi to pi (i.e of A in the code), as because the angle function in MATLAB returns the values in -pi to pi range. Is there any way to restrict the value range of angles (i.e A) to 0 to pi? The code is attached. fft2 and ifft2 are the inbuilt function of MATLAB to generate the Fourier transform and inverse Fourier transform respectively.

clear all;
close all;
clc;

%generation of two concentric circles image

 [x,y]=meshgrid(-64:1:63);
 g0= (x.^2+y.^2<=25^2).*(x.^2+y.^2>=20^2)+(x.^2+y.^2>=50^2).*(x.^2+y.^2<=55^2);

 figure;
 imagesc(abs(g0));
 colormap(gray);
 axis off; 
 axis equal;
 title('input image');

 delta1=rand(128);%random phase generation

%generating initial quantity  EL

EL=(g0/(sqrt(2))).*exp(1i*pi*delta1);
A1=angle(EL);
FT=fft2(EL);
IFT=ifft2(FT);
A=angle(IFT);
1

1 Answers

0
votes

After ifft, zero would not be perfectly recovered into zero, but will become very small number like 1e-17+j*2e-17.

You could change very small numbers into zero by force, after ifft.

Please, insert some codes, like below.

 [x,y]=meshgrid(-64:1:63);
 g0= (x.^2+y.^2<=25^2).*(x.^2+y.^2>=20^2)+(x.^2+y.^2>=50^2).*(x.^2+y.^2<=55^2);

 figure(1);
 imagesc(abs(g0));
 colormap(gray);
 axis off; 
 axis equal;
 title('input image');

 delta1=rand(128);%random phase generation

%generating initial quantity  EL

EL=(g0/(sqrt(2))).*exp(1i*pi*delta1);
A1=angle(EL);
FT=fft2(EL);
IFT=ifft2(FT);

dim=size(IFT);

for k=1:dim(1);
    for m=1:dim(2);
        if real(IFT(k,m)) < 1e-10 & imag(IFT(k,m)) < 1e-10
               IFT(k,m) = 0;
        end
    end
end %changing very small number into zero by force


A=angle(IFT);