Skip to content

fft_genericFftGenericFftGenericfft_genericfft_generic🔗

Short description🔗

fft_genericFftGenericFftGenericfft_genericfft_generic — Compute the fast Fourier transform of an image.

Signature🔗

fft_generic( image Image, out image ImageFFT, string Direction, integer Exponent, string Norm, string Mode, string ResultType )void FftGeneric( const HObject& Image, HObject* ImageFFT, const HTuple& Direction, const HTuple& Exponent, const HTuple& Norm, const HTuple& Mode, const HTuple& ResultType )static void HOperatorSet.FftGeneric( HObject image, out HObject imageFFT, HTuple direction, HTuple exponent, HTuple norm, HTuple mode, HTuple resultType )def fft_generic( image: HObject, direction: str, exponent: int, norm: str, mode: str, result_type: str ) -> HObject

Herror fft_generic( const Hobject Image, Hobject* ImageFFT, const char* Direction, const Hlong Exponent, const char* Norm, const char* Mode, const char* ResultType )

Herror T_fft_generic( const Hobject Image, Hobject* ImageFFT, const Htuple Direction, const Htuple Exponent, const Htuple Norm, const Htuple Mode, const Htuple ResultType )

HImage HImage::FftGeneric( const HString& Direction, Hlong Exponent, const HString& Norm, const HString& Mode, const HString& ResultType ) const

HImage HImage::FftGeneric( const char* Direction, Hlong Exponent, const char* Norm, const char* Mode, const char* ResultType ) const

HImage HImage::FftGeneric( const wchar_t* Direction, Hlong Exponent, const wchar_t* Norm, const wchar_t* Mode, const wchar_t* ResultType ) const (Windows only)

HImage HImage.FftGeneric( string direction, int exponent, string norm, string mode, string resultType )

Description🔗

fft_genericFftGeneric computes the fast Fourier transform of the input image Imageimageimage. 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:

\[\begin{eqnarray*} F(m,n) = \frac{1}{c} \sum_{k=0}^{M-1} \sum_{l=0}^{N-1} e^{s 2 \pi i (k m / M + l n / N)} f(k,l) \end{eqnarray*}\]

Opinions vary on whether the sign s in the exponent should be set to 1 or -1 for the forward transform, i.e., the transform 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{MN}\). Especially in image processing applications the DC term is shifted to the center of the image.

fft_genericFftGeneric allows to select these choices individually. The parameter Directiondirectiondirection 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'"to_freq" and 'from_freq'"from_freq". The parameter Exponentexponentexponent is used to determine the sign of the exponent. It can be set to 1 or -1. The normalizing factor can be set with Normnormnorm, and can take on the values 'none'"none", 'sqrt'"sqrt" and 'n'"n". The parameter Modemodemode determines the location of the DC term of the FFT. It can be set to 'dc_center'"dc_center" or 'dc_edge'"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 backward transform must yield M*N when multiplied, the exponents must be of opposite sign, and Modemodemode must be equal for both transforms.

A consistent combination is, for example '(to_freq,-1,n,dc_edge)'"(to_freq,-1,n,dc_edge)" for the forward transform and '(from_freq,1,none,dc_edge)'"(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 possible combination is '(to_freq,-1,sqrt,dc_center)'"(to_freq,-1,sqrt,dc_center)" and '(from_freq,1,sqrt,dc_center)'"(from_freq,1,sqrt,dc_center)".

The parameter ResultTyperesultTyperesult_type can be used to specify the result image type of the reverse transform (Directiondirectiondirection \(=\) 'from_freq'"from_freq"). In the forward transform (Directiondirectiondirection \(=\) 'to_freq'"to_freq"), ResultTyperesultTyperesult_type must be set to 'complex'"complex".

Attention🔗

The transformation is always performed for the entire image, i.e., the domain of the image is ignored.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on internal data level.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image(-array) → object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HImage (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)Hobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)

Input image.

ImageFFTimageFFTimage_fft (output_object) image(-array) → object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HImage (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)Hobject * (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex)

Fourier-transformed image.

Directiondirectiondirection (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Calculate forward or reverse transform.

Default: 'to_freq'"to_freq"
List of values: 'from_freq', 'to_freq'"from_freq", "to_freq"

Exponentexponentexponent (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Sign of the exponent.

Default: -1-1
List of values: -1, 1-1, 1

Normnormnorm (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Normalizing factor of the transform.

Default: 'sqrt'"sqrt"
List of values: 'n', 'none', 'sqrt'"n", "none", "sqrt"

Modemodemode (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Location of the DC term in the frequency domain.

Default: 'dc_center'"dc_center"
List of values: 'dc_center', 'dc_edge'"dc_center", "dc_edge"

ResultTyperesultTyperesult_type (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Image type of the output image.

Default: 'complex'"complex"
List of values: 'byte', 'complex', 'cyclic', 'direction', 'int1', 'int2', 'int4', 'real', 'uint2'"byte", "complex", "cyclic", "direction", "int1", "int2", "int4", "real", "uint2"

Example🔗

(C)

/* simulation of fft_image */
void my_fft(Hobject In, Hobject *Out)
{
  fft_generic(In,Out,"to_freq",-1,"sqrt","dc_center","complex")\;
}

/* simulation of fft_image_inv */
void my_fft_image_inv(Hobject In, Hobject *Out)
{
  fft_generic(In,Out,"from_freq",1,"sqrt","dc_center","byte")\;
}

Result🔗

fft_genericFftGeneric returns 2 (H_MSG_TRUE) if all parameters are correct. If the input is empty the behavior can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

optimize_fft_speedOptimizeFftSpeed, read_fft_optimization_dataReadFftOptimizationData

Possible successors

convol_fftConvolFft, correlation_fftCorrelationFft, phase_correlation_fftPhaseCorrelationFft, convol_gaborConvolGabor, convert_image_typeConvertImageType, power_bytePowerByte, power_realPowerReal, power_lnPowerLn, phase_degPhaseDeg, phase_radPhaseRad, energy_gaborEnergyGabor

Alternatives

fft_imageFftImage, fft_image_invFftImageInv, rft_genericRftGeneric

Module🔗

Foundation