Image processing uses processes called "Transforms" to manipulate and compress images. These "transformations" include the Fourier Transform (FT), Walsh Transform, Hadamard Transform, Discrete Cosine Transform (DCT), Haar Transform, and Slant Transform. Of all these transforms, the best known is the Fourier Transform. Deriving the other transforms is usually analogous to the derivation of the FT.
Essentially, the Fourier Transform maps a given function f(x) from the Spatial Domain (of x) into the Frequency Domain (u) using the Fourier Function F(u). This is useful for implementing frequency filters and other processing techniques. For this transformation to work, f(x) must be integratable and continuous over the range (+infinity,-infinity).
The Fourier Transform of f(x) (in one dimension) is given by:
F(u) = ∫ f(x)e-i2*π*ux ∂x
where e represents the natural log and i is the square root of (-1) and thus F(u) is usually a complex function.
When given the Fourier Transform, the original function can be derived using the formula:
When graphed, the spectrum of F(u) is usually graphed. The spectrum is defined as (here with "|" being used in the sense of "absolute value" notation):
or the absolute value or magnitude of F(u) using the length of the hypotenuse of the complex number when graphed on the Argand plane. In the same way as the one dimensional Fourier Transform, a two dimensional function can also be derived using:
F(u,v) = ∫∫ f(x,y)e-i2*π*(ux+vy) ∂x∂y
and its inverse Fourier Transform:
f(x,y) = ∫∫ F(u,v)ei2π(ux+vy) ∂u∂y
Resolution of Complex numbers in a form suitable for computer manipulation involves invoking Euler's Formula of the form:
e-i2π*ux = cos(2π*ux) - i*sin(2π*ux)
Because computers cannot handle continuous functions, the Fourier Transform is "discretized" over some arbitrary range using the formula:
where (1/N) becomes a scaling factor for the total of N points in the set. The two dimensional Discrete Fourier Transform (DFT) is derived analogously.
One problem with Discrete Fourier Transforms is their computation cost. A one dimensional transform takes n2 cycles to compute: one cycle for each value of x and one for each value of u (since u=x). This cost is even more excessive for two dimensional transforms where we need to cycle through each value of x,y,u and v for a O(n)=n4. These costs make Fourier Transforms difficult to compute for all but very small images (where x is very small).
Fortunately, this computation cost can be reduced using a technique called the Fast Fourier Transform (FFT). Information, discussions, and algorithms for the FFT are available throughout the internet and a selection of links is provided below. Using FFT, the computational effort required to derive the one dimensional FT is now n*log2n and for the two dimensional FT, O(n)=n2log2n--a very dramatic improvement.
To illustrate what Fourier Transforms look like, the left hand image is the image of f(x), and the image on the right its respective Fourier Transform. The 32 and 64 bit images were created using the Discrete Fourier Transform using the code supplied. The 256 bit images were created using the Fast Fourier Transform algorithm. In all cases, the Fourier Transforms were rotated 90 degrees around the origin to shift the image to the center of the display. Note: All the images have been scaled to the same size for consistency of appearance.
Spatial Images | Fourier Transforms |
---|---|
A square in a 32x32 pixel image and its associated Fourier Transform. (Any ghosted images in the white square was caused by JPEG compression. The square should be completely white.) |
|
A square in a 64x64 pixel image and its associated Fourier Transform. |
|
A square in a 256x256 pixel image and its associated Fourier Transform. |
|
A photograph in a 256x256 pixel image and its associated Fourier Transform. |
|
As can be seen from the transforms, the image is a sparsely populated set of data points. Compression is possible by measuring a radius from the middle and then truncating all points outside of the resulting circle. This compression will also lose some higher frequency detail. Alternatively, truncating data points within the middle of the image will result in a loss of low frequency components of the image.
The accompanying source code is copyright the author and all rights are reserved. Please do not reproduce this code for any projects, publications, or assignments without the express permission of the author.
My code (in C) for Fourier Transforms is available.
Main procedure for the Fast Fourier Transform algorithm
This file is courtesy of Dr. Xue Dong Yang
Links
[1] http://en.wikipedia.org/wiki/Fast_Fourier_transform
[2] https://niedermayer.ca/user/login?destination=node/238%23comment-form
[3] https://niedermayer.ca/sites/default/files/fft.zip
[4] http://www.niedermayer.ca/code/fft
[5] https://niedermayer.ca/user/login?destination=node/246%23comment-form
[6] https://niedermayer.ca/user/login?destination=node/247%23comment-form
[7] https://niedermayer.ca/user/login?destination=node/248%23comment-form
[8] https://niedermayer.ca/user/login?destination=node/249%23comment-form