code: public static void DFT2(ComplexNumber[][] data, Direction direction) {
  
          int n = data.length;
          int m = data[0].length;
          ComplexNumber[] row = new ComplexNumber[Math.max(m, n)];
  
          for (int i = 0; i < n; i++) {
              // copy row
              for (int j = 0; j < n; j++)
                  row[j] = data[i][j];
              // transform it
              FourierTransform.DFT(row, direction);
              // copy back
              for (int j = 0; j < n; j++)
                  data[i][j] = row[j];
          }
  
          // process columns
          ComplexNumber[] col = new ComplexNumber[n];
  
          for (int j = 0; j < n; j++) {
              // copy column
              for (int i = 0; i < n; i++)
                  col[i] = data[i][j];
              // transform it
              FourierTransform.DFT(col, direction);
              // copy back
              for (int i = 0; i < n; i++)
                  data[i][j] = col[i];
          }
      }
docs: 2-D Discrete Fourier Transform.
  
  @param data      Data to transform.
  @param direction Transformation direction.