GithubHelp home page GithubHelp logo

tambapps / fourier-transform-library Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 1.0 230 KB

A FFT library written in Java

License: MIT License

Java 100.00%
fft fourier-transform-library java fourier-transform

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

dependabot[bot] avatar nelson888 avatar tambapps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

r73psv

fourier-transform-library's Issues

FFT size

Hello! I am conducting an experiment in which I take the frequency contents out of songs and then cluster them. For that, I need the FFT size, but I cannot seem to find it or be able to calculate it.

Could you tell me the size of the FFT from this repository? I am using the Basic Fourier Transform class.

Thank you very much

build process failed in jdk11 and maven3

i get error message

[ERROR] D:\ebook\python_dsp\fourier-transform-library-master\src\main\java\com\tambapps\fft4j\fourier\fft_1d\CooleyTukeyRecursiveFFT.java:11: error: incorrect use of inline tag
[ERROR] * @link from https://rosettacode.org/wiki/Fast_Fourier_transform
[ERROR] ^
[ERROR] D:\ebook\python_dsp\fourier-transform-library-master\src\main\java\com\tambapps\fft4j\fourier\util\Padding.java:5: error: bad use of '>'
[ERROR] * zero-padding => raise resolution
[ERROR] ^
[ERROR]
[ERROR] Command line was: C:\Java\jdk-11.0.11\bin\javadoc.exe @options @packages
[ERROR]
[ERROR] Refer to the generated Javadoc files in 'D:\ebook\python_dsp\fourier-transform-library-master\target\apidocs' dir.

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.