Reputation: 854
I tried using Aforge.Math for doing FFT2 on 2D complex matrix and tried the same on matlab
On C#, for AForge:
Complex[,] array2D = new Complex[,] { { (Complex)1, (Complex)2 }, { (Complex)3, (Complex)4 }, { (Complex)5, (Complex) 6 }, { (Complex)7, (Complex)8 } };
FourierTransform.FFT2(array2D,FourierTransform.Direction.Forward);
On Mathlab:
x =[1 2; 3 4; 5 6; 7 8]
fft2(x)
but unfortunately the results are not the same for c#:
for mathlab:
36.0000 + 0.0000i -4.0000 + 0.0000i
-8.0000 + 8.0000i 0.0000 + 0.0000i
-8.0000 + 0.0000i 0.0000 + 0.0000i
-8.0000 - 8.0000i 0.0000 + 0.0000i
I have no clue why the results are different, btw I can just use tools , don't know details about FFT2. Update: AForge result is scaled according to the input matrix size!
Upvotes: 2
Views: 194
Reputation: 101453
To get the same result as in matlab, change direction to Backward
:
FourierTransform.FFT2(array2D,FourierTransform.Direction.Backward);
Upvotes: 1