Coder Social home page Coder Social logo

fourier-transform-library's Introduction

Java Fourier Transform Library

This is a library for computing 1-2 dimensional Fourier Transform. It was written with Java 8, and should be Android-compatible (you can use it in an Android project). This library was written without any compile dependencies.

You can import it with maven.

If you are more familiar with the old implementation (version 1.0), consult the legacy branch

<dependency>
  <groupId>com.tambapps.fft4j</groupId>
  <artifactId>fft4j</artifactId>
  <version>2.0</version>
</dependency>

Fast Fourier Transform

Here is an example of a 1D fast fourier transform. There are several algorithms to perform FFT You can see all of them on the FastFouriers class.

double[] inputRe = getInputDataRe();
double[] inputIm = getInputDataIm();

double[] outputRe = new double[inputRe.length];
double[] outputIm = new double[inputRe.length];

FastFouriers.BASIC.transform(inputRe, inputIm, outputRe, outputIm);

// consult result in outputRe and outputIm

You can also use a Signal which encapsulates a real and imaginary double arrays.

Signal input = inputData();
Signal output = FastFouriers.BASIC.transform(input);

3 different Fast Fourier Algorithms were implemented

Basic

This is a trivial implementation of a Fourier Transform using the basic Fourier Transform formula

Recursive Cooley–Tukey

A recursive implementation of the Cooley–Tukey FFT algorithm. Note that this algorithm requires the input length to be a power of 2.

Iterative Cooley–Tukey

An iterative implementation of the Cooley–Tukey FFT algorithm Note that this algorithm requires the input length to be a power of 2.

2D Fast Fourier Transform

You can apply 2D FFT with a FastFourierTransformer2D. You can change the algorithm used by the transformer to compute fft by setting the AlgorithmChooser.

Signal2d signal2d = new Signal2d(M, N);
fill(signal2d);

FastFourier2d transformer2D = new FastFourier2d();
transformer2D.transform(signal2d);
// do some things with the fourier transform
transformer2D.inverse(signal2d);

// don't forget to shut it down as it uses an executor service
transformer2D.shutdown();

Example use case

You can consult the fft-image-processing repo, an app that transforms images using FFT fft-image-processing-screenshot-1

fft-image-processing-screenshot-2

fourier-transform-library's People

Contributors

nelson888 avatar tambapps avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.