Fourier Transform

Basics

The Fourier transform consists in representing an image by its frequential components. You can then process the frequential components image (also called the Fourier image) to perform specific filtering.

Left: the image of a PCB, oriented at 45°
Right: the corresponding Fourier Image (scaled for visualization)
with the frequential structures that are scaled as well

The Fourier images contain complex numbers and are represented by a floating point image (EFourierImage).
In Open eVision, use an object In a general content, the term object should be understood with the meaning of a class instance. In EasyObject, an object is a maximally-sized area of adjacent connected pixels belonging to the layer foreground. EFourierTransformer to perform the conversion between spatial and Fourier images.
Use the method DirectTransform to convert a spatial image EImageBW8, EImageBW16 or EImageBW32f to an image EFourierImage.
Use the method InverseTransform to convert images the other way around.
When converting to a Fourier image and back to a spatial image, this scaling factor must be applied to preserve the initial scale: 1 / (height × width).

How to split the scaling between direct and inverse transform depends on the library implementation. In Open eVision:

The method DirectTransform does not apply any scale factor.
The method InverseTransform applies a scale factor of 1 / (height × width).
The EFourierImage shares the same methods as the EImageBW32f.
An EFourierImage may contain high values due to the nature of the applied transformation and this may be difficult to display on a screen. For an easier visualization, use ComputeMagnitude(EImageBW8&) and ComputePhase(EImageBW8&) to generate an image that can be drawn or saved.

Frequential format

As the Fourier images contain redundant data, there are different possible representations.

Open eVision supports the Packed and Complex Extended formats.
Use the method FrequentialDomainFormat on a EFourierImage to select a format. This format is used when calling the methods of EFourierTransformer.

Calling this method does not trigger a conversion.

The Complex Extended format

The Complex Extended is the simplest of these two formats.

The only subtlety is that the complex numbers are stored in a floating point array, so the complex extended image is twice larger than the spatial image.
Each odd column contains the imaginary part of a complex number.
The following table is an illustration of an image in Complex Extended format, where the complex pixel at row i and column j is:

Re(i,j) + i × Im(i,j)

Re(0,0) Im(0,0) Im(0,w-1)
Re(1,0) Im(1,0) Im(1,w-1)
Re(h-1,0) Im(h-1,0) Im(h-1,w-1)

A Fourier image in the Complex Extended format

The Packed format

The Packed format is also called Complex Conjugate Symmetrical.

It takes benefit of the conjugate symmetric properties of the Fourier transform of a real image to reduce the Fourier image size and to be the same as the spatial image size.
The following table is an illustration of an image in Packed format, where the complex pixel at row i and column j is:

Re(i,j) + i × Im(i,j)

There is a difference between images of odd and even height:

Re(0,0)

Re(0,1)

Im(0,1)

Re(0,(w-1)/2)

Im(0,(w-1)/2)

Re(0,w/2)

Re(1,0)

Re(1,1)

Im(1,1)

Re(1,(w-1)/2)

Im(1,(w-1)/2)

Re(1,w/2)

Im(1,0)

Re(2,1)

Im(2,1)

Re(2,(w-1)/2)

Im(2,(w-1)/2)

Im(1,w/2)

Re(h/2,0)

Re(h-2,1)

Im(h-2,1)

Re(h-2,(w-1)/2)

Im(h-2,(w-1)/2)

Re(h/2,w/2)

Im(h/2,0)

Re(h-1,1)

Im(h-1,1)

Re(h-1,(w-1))/2

Im(h-1,(w-1)/2)

Im(h/2,w/2)

A Fourier image in packed format, odd height

Re(0,0)

Re(0,1)

Im(0,1)

Re(0,(w-1)/2)

Im(0,(w-1)/2)

Re(0,w/2)

Re(1,0)

Re(1,1)

Im(1,1)

Re(1,(w-1)/2)

Im(1,(w-1)/2)

Re(1,w/2)

Im(1,0)

Re(2,1)

Im(2,1)

Re(2,(w-1)/2)

Im(2,(w-1)/2)

Im(1,w/2)

Re(h/2-1,0)

Re(h-3,1)

Im(h-3,1)

Re(h-3,(w-1)/2)

Im(h-3,(w-1)/2)

Re(h/2-1,w/2)

Im(h/2-1,0)

Re(h-2,1)

Im(h-2,1)

Re(h-2,(w-1)/2)

Im(h-2,(w-1)/2)

Im(h/2-1,w/2)

Re(h/2,0)

Re(h-1,1)

Im(h-1,1)

Re(h-1,(w-1)/2)

Im(h-1,(w-1)/2)

Re(h/2,w/2)

A Fourier image in packed format, even height

The other coefficients are obtained by using the following properties:
For i = 1,…,h-1 and j = 1,…,w-1:
Re(i,j) = Re(h-i,w-j) and Im(i,j) = -Im(h-i,w-j)
For j = 1,…,w-1:
Re(0,j) = Re(0,w-j) and Im(0,j) = -Im(0,w-j)
For i = 1,…,h-1:
Re(i,0) = Re(h-i,0) and Im(i,0) = -Im(h-i,0)