Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

FFT Library in Java

Version 1.10, Feb 24 2005

Herbert H.H. Chang


emwave@ucla.edu

and

Daniel J. Valentino
dvalentino@mednet.ucla.edu

Laboratory of Neuro Imaging, Neurology, UCLA

I. Introduction
This library provides the fast Fourier transform (FFT) algorithm in Java for the
numerical computation of the discrete Fourier transform (DFT) in 1-D, 2-D, and 3-D.
This library can be useful for those programming in Java and need a FFT library for
image processing applications. You are free to modify the source code of this library
for your own. Note that you are not allowed to remove our names in this collection
and release the modified code to a public domain. Please feel free to let us know any
comments on this issue. Enjoy!

II. Usage
1. The FFT library is distributed in a jar file: fftlib.jar.
2. FastFourierTransform.html provides the documentation of the FFT functions.
3. demoFFT.java gives an example of using the FFT library to perform
computation.
4. Please include the fftlib.jar when compiling and running as given by the
following example:
javac -classpath .;fftlib.jar demoFFT.java
java -classpath .;fftlib.jar demoFFT
5. The source codes of the library are also provided in the src directory.
III. Experiments and Results
Some simple analytic functions were used to test the FFT library as provided in
demoFFT.java.

Experiment 1: Cosine function h(t ) = 100 cos(2π ⋅ 10 ⋅ t )

input function reconstructed function


100 100

50 50
h(t)

h(t)
0 0

-50 -50

-100 -100
0 200 400 600 800 1000 0 200 400 600 800 1000
time time

real part of the transformed function imaginary part of the transformed function
60 60

50 50

40 40
H(f)

H(f)

30 30

20 20

10 10

0 0
-15 -10 -5 0 5 10 15 0 200 400 600 800 1000
frequency frequency

Experiment 2: Sine function h(t ) = 100 sin( 2π ⋅ 10 ⋅ t )

input function reconstructed function


100 100

50 50
h(t)

h(t)

0 0

-50 -50

-100 -100
0 200 400 600 800 1000 0 200 400 600 800 1000
time time

real part of the transformed function imaginary part of the transformed function
60 60

40 40

20 20
H(f)

H(f)

0 0

-20 -20

-40 -40

-60 -60
0 200 400 600 800 1000 -15 -10 -5 0 5 10 15
frequency frequency
100, t < 256
Experiment 3: Box function h(t ) = 50, t = 256
0, t > 256

input function reconstructed function


100 100

80 80

60 60
h(t)

h(t)
40 40

20 20

0 0
0 200 400 600 800 1000 0 200 400 600 800 1000
time time

real part of the transformed function imaginary part of the transformed function
60 60

40 40

20 20
H(f)

H(f)

0 0

-20 -20

-40 -40
-50 0 50 0 200 400 600 800 1000
frequency frequency

IV. Computation Time


The computation time of using the FFT library has been tested on a Pentium M 1.6
GHz machine with a Windows XP operating system. The approximate processing
time of using a 2-D FFT is given in the following table.

Dimension Processing time (ms)


64 x 64 2
128 x 128 6
256 x 256 24
512 x 512 111
1024 x 1024 476
2048 x 2048 2091
4096 x 4096 12708

You might also like