1

I am working on fingerprint image enhancement with Fast Fourier Transformation. I got the idea from this site.

I have implemented the FFT function using 32*32 window, and after that as the referral site suggested, I want to multiply power spectrum with the FFT. But I do not get,

How do I calculate Power Spectrum for an image? Or is there any ideal value for Power Spectrum ?

Code for FFT:

public FFT(int[] pixels, int w, int h) {
    // progress = 0;
    input = new TwoDArray(pixels, w, h);
    intermediate = new TwoDArray(pixels, w, h);
    output = new TwoDArray(pixels, w, h);
    transform();
}

  void transform() {
    for (int i = 0; i < input.size; i+=32) {
        for(int j = 0; j < input.size; j+=32){

            ComplexNumber[] cn = recursiveFFT(input.getWindow(i,j));
            output.putWindow(i,j, cn);
        }
    }
    for (int j = 0; j < output.values.length; ++j) {
        for (int i = 0; i < output.values[0].length; ++i) {
            intermediate.values[i][j] = output.values[i][j];
            input.values[i][j] = output.values[i][j];
        }
    }
}

static ComplexNumber[] recursiveFFT(ComplexNumber[] x) {
 int N = x.length;
    // base case
    if (N == 1) return new ComplexNumber[] { x[0] };

    // radix 2 Cooley-Tukey FFT
    if (N % 2 != 0) { throw new RuntimeException("N is not a power of 2"); }

    // fft of even terms
    ComplexNumber[] even = new ComplexNumber[N/2];
    for (int k = 0; k < N/2; k++) {
        even[k] = x[2*k];
    }
    ComplexNumber[] q = recursiveFFT(even);

    // fft of odd terms
    ComplexNumber[] odd  = even;  // reuse the array
    for (int k = 0; k < N/2; k++) {
        odd[k] = x[2*k + 1];
    }
    ComplexNumber[] r = recursiveFFT(odd);

    // combine
    ComplexNumber[] y = new ComplexNumber[N];
    for (int k = 0; k < N/2; k++) {
        double kth = -2 * k * Math.PI / N;
        ComplexNumber wk = new ComplexNumber(Math.cos(kth), Math.sin(kth));
        ComplexNumber tmp = ComplexNumber.cMult(wk, r[k]);
        y[k] = ComplexNumber.cSum(q[k], tmp);

        ComplexNumber temp = ComplexNumber.cMult(wk, r[k]);
        y[k + N/2] = ComplexNumber.cDif(q[k], temp);
    }
    return y;
}
rachana
  • 3,344
  • 7
  • 30
  • 49

1 Answers1

0

I'm thinking that the power spectrum is the square of the output of the Fourier transform.

power@givenFrequency = x(x*) where x* is the complex conjugate

The total power in the image block would then be the sum over all frequency and space.

I have no idea if this helps.

Prichmp
  • 2,112
  • 4
  • 16
  • 17