var desc = new IntPtr(); int precision = DFTI.DOUBLE; int forward_domain = DFTI.REAL; // DFTI.COMPLEX; int dimension = 2; int[] len = { rows, columns }; // Create the new DTFI descriptor. Got an unhandled exception here once (16-Sep-2013). try { int ret = DFTI.DftiCreateDescriptor(ref desc, precision, forward_domain, dimension, len); } catch (Exception) { // If the reset noise filter fails, just log it and ignore it. Better to have one frame without correction // than to abort data collection. string msg = string.Format("ResetNoise exception: {0} {1} {2} {3} {4}", precision, forward_domain, dimension, len[0], len[1]); XLogger.WriteLog(XLogger.Level.Standard, TraceEventType.Warning, msg, null); return frameImageData; // throw; } // Setup the scale factor long transform_size = rows * columns; double scale_factor = 1.0 / transform_size; DFTI.DftiSetValue(desc, DFTI.BACKWARD_SCALE, scale_factor); // Setup the transform parameters DFTI.DftiSetValue(desc, DFTI.PLACEMENT, DFTI.NOT_INPLACE); DFTI.DftiSetValue(desc, DFTI.PACKED_FORMAT, DFTI.PACK_FORMAT); // Commit the descriptor DFTI.DftiCommitDescriptor(desc); // The data to be transformed var x_normal = new double[rows * columns]; var x_transformed = new double[rows * columns]; // Initialize the data array for (int y = 0; y < rows; y++) // actually v for (int x = 0; x < columns; x++) // actually u x_normal[y * columns + x] = ((frameImageData[y, x] > 100.0) ? 100.0 : frameImageData[y, x]) + baseline; // Forward transform DFTI.DftiComputeForward(desc, x_normal, x_transformed); // Gaussian filter int h = len[0]; int w = len[1]; for (int y = 0; y < rows; y++) // actually v for (int x = 0; x < columns; x++) // actually u { double value = gaussianFilter(y, x, h, w); x_transformed[y * columns + x] *= value; //x_transformed_real[y*rows+x] *= value; //x_transformed_imaginary[y * rows + x] *= value; } // Backward transform DFTI.DftiComputeBackward(desc, x_transformed, x_normal); DFTI.DftiFreeDescriptor(ref desc);