2D FFT scaling Issue

I attempting an app in swift which will use 2D FFTs to process images. The app creates a 2 D FFT of one image and then performs a complex multiply of a second 2D FFT of a second image. The resulting 2D FFT is then inverted. My problem has to do with scaling the resulting reverse FFT.


The initial input array are all scaled to be less than 1.0.


.
var cplxtfData = DSPSplitComplex(realp: &arrayR, imagp: &arrayZ)
vDSP_fft2d_zip ( setup, &cplxtfData, rowStride, columnStride, UInt(log2nr), UInt(log2nc), FFTDirection(kFFTDirection_Forward) );
.
var imag_cplxData = DSPSplitComplex(realp: &imag_arrayR, imagp: &imag_arrayZ)
vDSP_fft2d_zip ( setup, &imag_cplxData, rowStride, columnStride, UInt(log2nr), UInt(log2nc), FFTDirection(kFFTDirection_Forward) );
.
.
//multiply the 2 FFTs
vDSP_zvmul(&cplxtfData, 1, &imag_cplxData, 1, &final_cplxData, 1, UInt(numElements), 1)
.
vDSP_fft2d_zip ( setup, &final_cplxData, rowStride, columnStride, UInt(log2nr), UInt(log2nc), FFTDirection(kFFTDirection_Inverse) );
//scale the inverse FFT
vDSP_vsmul( final_cplxData.realp, 1, [SCALE], final_cplxData.realp, 1, UInt(numElements));
vDSP_vsmul( final_cplxData.imagp, 1, [SCALE], final_cplxData.imagp, 1, UInt(numElements));
.
//find the max value of the REAL data
var maxValReal: Float = 0.0
vDSP_maxv(final_cplxData.realp, 1, &maxValReal, UInt(numElements))


According to the documentation, the value of the parameter SCALE should be 1.0/numElements. If I use that value, the value of maxValReal is 7.3, but I need it to be less than 1.0.


Am I missing something?


Thanks for your time.


Imagemaster

2D FFT scaling Issue
 
 
Q