1

我正在使用快速傅里叶变换进行指纹图像增强。我从这个网站得到了这个想法。

我已经FFT使用 32*32 窗口实现了该功能,然后按照推荐站点的建议,我想power spectrumFFT. 但我不明白,

如何计算图像的功率谱?或者 Power Spectrum 有什么理想的价值吗?

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;
}
4

1 回答 1

0

我认为功率谱是傅里叶变换输出的平方。

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

图像块中的总功率将是所有频率和空间的总和。

我不知道这是否有帮助。

于 2014-03-27T19:40:17.750 回答