Accord.Math.Transforms.FourierTransform2.DFT2 C# (CSharp) Method

DFT2() public static method

2-D Discrete Fourier Transform.
public static DFT2 ( Complex data, FourierTransform direction ) : void
data Complex The data to transform.
direction AForge.Math.FourierTransform The transformation direction.
return void
        public static void DFT2(Complex[][] data, FourierTransform.Direction direction)
        {
            int n = data.Length;
            int m = data[0].Length;

            // process rows
            var row = new Complex[m];
            for (int i = 0; i < n; i++)
            {
                // copy row
                for (int j = 0; j < row.Length; j++)
                    row[j] = data[i][j];

                // transform it
                DFT(row, direction);

                // copy back
                for (int j = 0; j < row.Length; j++)
                    data[i][j] = row[j];
            }

            // process columns
            var col = new Complex[n];
            for (int j = 0; j < n; j++)
            {
                // copy column
                for (int i = 0; i < col.Length; i++)
                    col[i] = data[i][j];

                // transform it
                DFT(col, direction);

                // copy back
                for (int i = 0; i < col.Length; i++)
                    data[i][j] = col[i];
            }
        }