public static Bitmap IFFT2D(Complex[][] data, Bitmap originalBitmap) { FourierHelper.Conjugate(data); for (int i = 0; i < data.Length; i++) { FFT1D(data[i]); } FourierHelper.Conjugate(data); CollectionHelper.ApplyOperation(data, c => c / data[0].Length); var swappedData = CollectionHelper.SwapRowColumn(data); FourierHelper.Conjugate(swappedData); for (int i = 0; i < swappedData.Length; i++) { FFT1D(swappedData[i]); } FourierHelper.Conjugate(swappedData); CollectionHelper.ApplyOperation(swappedData, c => c / swappedData[0].Length); using (var bitmapData = new SingleBitmapData(originalBitmap, PixelFormat.Format8bppIndexed)) { for (int y = 0; y < bitmapData.HeightInPixels; y++) { for (int x = 0; x < bitmapData.WidthInBytes; x += bitmapData.BytesPerPixel) { bitmapData.FirstPixelPtr[x + y * bitmapData.WidthInBytes] = (byte)ImageHelper.FixOverflow(swappedData[y][x].Real); } } return(bitmapData.Bitmap); } }