# Playing with the Fourier Transform (II)

This post is an extension of a post I wrote many years ago called Playing with the Fourier Transform (I).

The Fourier Transform has become an often-used tool in my toolbox because:

- it provides a means to optimize (large) convolutions via the Convolution Theorem.
*i.e.,*image filtering, certain tonemapping operations, … - the FT corresponds to the Fraunhofer/far-field diffraction of light through an aperture, which is a key component in ArionFX and Maverick Render.

I will not be unveiling anything new here, but wanted to post visualizations I just made of some properties of the Fourier Transform that everyone in the field of Computer Graphics (or anyone dealing with the FT) should be familiar with. The videos below come straight out of Maverick’s Unit Testing system.

In the videos:

- The
*input signal*(top-left) is in white. - The
*real part*of the FT (bottom-left) is in red (-) and green (+). - The
*imaginary part*of the FT (bottom-right) is in red (-) and green (+). - The
*magnitude*of the FT (top-right) is in faux color.

## Changing the amplitude of the input signal

When the amplitude of the input signal is multiplied up or down, the magnitude of the FT is equally multiplied up or down.

## Shifting the input signal

Shifting the input signal causes changes in phase in the `(re,im)`

components of the FT, but the FT magnitude stays invariant.

Note that the small fluctuations in the FT magnitude below are due to anti-aliasing in the input signal and numerical drift in the computations. If sampling sizes and numerical precision were increased, the top-right quadrant would look completely frozen.

## Sampling in larger/smaller buffers

Sampling the input signal and then computing the FT in larger buffers (*e.g.,* twice as large as in the video below) produces exactly the same FT, occupying the central part of the buffer, leaving padding space towards the edges before wrapping-around.

The opposite happens if the buffers become smaller. The FT stays the same size (which will make it wrap-around earlier on all 4 edges).

Note that these videos may appear to be the same size in your browser, because this blog’s layout will dock media content to the width of the page.

## Rotating the input signal

When the input signal is rotated, the FT rotates in sync.

## Scaling the input signal

When the input signal is scaled up or down, the overall shape of the FT gets scaled inversely. The overall power also changes, proportionally to the scale.

## FT of a polygonal shape

The Fourier Transform of an `n`

-sided polygon casts `n`

streaks. Because the FT is periodic, when `n`

is even, only `n/2`

streaks are apparent due to overlapping pairs. When `n`

goes to infinity, the FT becomes the FT of a circle, which is called the Airy disk.

The periodicity of the FT is visible when the streaks wrap around the edges of the image.

## FT of a gaussian

While not strikingly obvious in the video below, the Fourier Transform of a 2D gaussian function is another 2D gaussian. Note how the transform has no imaginary component in this case.

**[EDIT]** All throughout this post I loosely used the term FT to actually mean DFT.