FFT implementation

邮差的信 提交于 2019-12-22 01:15:55

问题


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

I have implemented the code for FFT:

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

Fourier Transform

Frequency Filter

Output

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?


回答1:


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);




回答2:


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



来源:https://stackoverflow.com/questions/19423264/fft-implementation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!