FFT implementation

2019-04-14 01:24发布

I am working on application to enhance an image using FFT.

I have implemented the code for FFT:

enter image description here

For the first formula in above picture i have implemented code as below :

  void fft(int x , int y , int size) {

    for(int i=x; i<x+32 ; i++){
        for(int j=y ; j<y+32 ; j++){
            double kth = -2 * Math.PI * (((i*x)/size)+((j*y)/size));
            ComplexNumber expo = new ComplexNumber(Math.cos(kth),Math.sin(kth));
            output.values[i][j] = ComplexNumber.cMult(input.values[x][y],expo) ;
            intermediate.values[i][j] = output.values[i][j];
            input.values[i][j] = output.values[i][j];
        }

    }

}

I have also implemented code for second and third formula but the result I am getting is not correct. What should I do ?

Is the code implemented for the first equation correct?

Edited

I have tried with suggested functions in Catalano framework on the fingerprint image. Input image and output image after applying the Catalano framework :

Input Image

enter image description here

Fourier Transform

enter image description here

Frequency Filter

enter image description here

Output

enter image description here

As I am applying it on fingerprint image the difference between input image and output image is not so effective.The contrast between ridges and valleys in the fingerprint image is not clearly differentiable even after applying the FFT.So is there any addition parameters needed to do operation on fingerprint image?

标签: java fft
2条回答
在下西门庆
2楼-- · 2019-04-14 02:10

You can use Catalano Framework.

See the code below and the results.

FastBitmap fb = new FastBitmap("c:\\files\\test.bmp");
fb.toGrayscale();
JOptionPane.showMessageDialog(null, fb.toIcon(), "Image", JOptionPane.PLAIN_MESSAGE); 

FourierTransform ft = new FourierTransform(fb);
ft.Forward();
fb = ft.toFastBitmap();
JOptionPane.showMessageDialog(null, fb.toIcon(), "Fourier Transform", JOptionPane.PLAIN_MESSAGE);

FrequencyFilter ff = new FrequencyFilter(0, 60);
ff.ApplyInPlace(ft);
fb = ft.toFastBitmap();
JOptionPane.showMessageDialog(null, fb.toIcon(), "Frequency Filter", JOptionPane.PLAIN_MESSAGE);

ft.Backward();
fb = ft.toFastBitmap();
JOptionPane.showMessageDialog(null, fb.toIcon(), "Result", JOptionPane.PLAIN_MESSAGE);

Original image

Fourier Transform

Frequency Filter

Result

查看更多
看我几分像从前
3楼-- · 2019-04-14 02:25

you can use FFT in java as follow:

This link is dead (http://blog.datasingularity.com/?p=53)

http://introcs.cs.princeton.edu/java/97data/FFT.java.html

and refer the info for FFTW is the 'fastest fourier transform in the west', and has some Java wrappers: from http://www.fftw.org/download.html

查看更多
登录 后发表回答