this.fft = new Fft1d(Math.max(nWidth, nHeight));
} else {
this.fft.setMaxWidth(Math.max(nWidth, nHeight));
}
// get access to the complex image
Complex32Image cxmIn = (Complex32Image) im;
Complex data[] = cxmIn.getData();
// create output
Complex32Image cxmResult = new Complex32Image(nWidth, nHeight);
// take inverse FFT of each row
Complex cxRow[] = new Complex[nWidth];
for (int i=0; i<nHeight; i++) {
System.arraycopy(data, i*nWidth, cxRow, 0, nWidth);
// compute inverse FFT
Complex cxResult[] = this.fft.ifft(cxRow);
// save result
System.arraycopy(cxResult, 0, cxmResult.getData(), i*nWidth, nWidth);
}
// take inverse FFT of each column
Complex cxCol[] = new Complex[nHeight];
for (int j=0; j<nWidth; j++) {
// copy column into a 1-D array
for (int i=0; i<nHeight; i++) {
cxCol[i] = cxmResult.getData()[i*nWidth+j];
}
// compute inverse FFT
Complex cxResult[] = this.fft.ifft(cxCol);
// save result back into column
for (int i=0; i<nHeight; i++) {
cxmResult.getData()[i*nWidth+j] = cxResult[i];
}
}
// convert back to a gray image
// first convert it to an integer image
Gray32Image imInteger = new Gray32Image(nWidth, nHeight);
Complex cxData[] = cxmResult.getData();
int nData[] = imInteger.getData();
int nMinVal = Integer.MAX_VALUE;
int nMaxVal = Integer.MIN_VALUE;
for (int i = 0; i < nWidth * nHeight; i++) {
// magnitude is always guaranteed to be >= 0 so we only have to clamp