Compute the fast Fourier transform of an image.
fft_generic computes the fast Fourier transform of the input image Image. Because several definitions of the forward and reverse transforms exist in the literature, this operator allows the user to select the most convenient definition.
The general definition of a Fourier transform is as follows:
M-1 N-1 --- --- 1 \ \ s*2*pi*i*(k*m/M+l*n/N) F(m,n) = - * / / e * f(k,l) c --- --- k=0 l=0Opinions vary on whether the sign s in the exponent should be set to 1 or -1 for the forward transform, i.e. the for going to the frequency domain. There is also disagreement on the magnitude of the normalizing factor c. This is sometimes set to 1 for the forward transform, sometimes to M*N, and sometimes (in case of the unitary FFT) to sqrt(M*N). Especially in image processing applications the DC term is shifted to the center of the image.
fft_generic allows to select these choices individually. The parameter Direction allows to select the logical direction of the FFT. (This parameter is not unnecessary; it is needed to discern how to shift the image if the DC term should rest in the center of the image.) Possible values are 'to_freq' and 'from_freq'. The parameter Exponent is used to determine the sign of the exponent. It can be set to 1 od -1. The normalizing factor can be set with Norm, and can take on the values 'none', 'sqrt' and 'n'. The parameter Mode determines the location of the DC term of the FFT. It can be set to 'dc_center' or 'dc_edge'.
In any case, the user must ensure the consistent use of the parameters. This means that the normalizing factors used for the forward and bacward transform must yield M*N when multiplied, the exponents must be of opposite sign, and Mode must be equal for both transforms.
A consistent combination is, for example ('to_freq',-1,'n','dc_edge') for the forward transform and ('from_freq',1,'none','dc_edge') for the reverse transform. In this case, the FFT can be interpreted as interpolation with trigonometric basis functions. Another useful combination is ('to_freq',1,'sqrt','dc_center') and ('from_freq',-1,'sqrt','dc_center').
Image (input_object) |
image(-array) -> object : any |
Input image. |
ImageFFT (output_object) |
image(-array) -> object : complex |
Fourier-transformed image. |
Direction (input_control) |
string -> string |
Calculate forward or reverse transform. | |
Default value: 'to_freq' | |
List of values: 'to_freq', 'from_freq' |
Exponent (input_control) |
integer -> integer |
Sign of the exponent. | |
Default value: 1 | |
List of values: -1, 1 |
Norm (input_control) |
string -> string |
Normalizing factor of the transform. | |
Default value: 'sqrt' | |
List of values: 'none', 'sqrt', 'n' |
Mode (input_control) |
string -> string |
Location of the DC term in the frequency domain. | |
Default value: 'dc_center' | |
List of values: 'dc_center', 'dc_edge' |
/* simulation of fft__ */ my_fft__(ObjType In, ObjType *Out) { fft_generic(In,Out,'to_freq',1,'sqrt','dc_center'); } /* simulation of fft_inv__ */ my_fft_inv__(ObjType In, ObjType *Out) { ObjType Tmp; fft_generic(In,&Tmp,'from_freq',1,'sqrt','dc_center'); convert_image_type__(Tmp,Out,"byte"); clear(Tmp); }
convol_gabor__ returns TRUE if the input image is of correct type, its width and height are a power of 2, and all parameters are correct. If the input is empty the behaviour can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.
convol_fft__, convol_gabor__, convert_image_type__, power_byte, power_real, power_ln, phase_deg, phase_rad, energy__