public Double[,] iSDFT2(Complex[,] Spectrum)
{
Double[,] img = new Double[Spectrum.GetLength(0), Spectrum.GetLength(1)];
for (int i = 0; i < Spectrum.GetLength(0); i++)
{
for (int j = 0; j < Spectrum.GetLength(1); j++)
{
Double I = Convert.ToDouble(i);
Double J = Convert.ToDouble(j);
Complex im = new Complex(0, 1);
Complex sum = 0;
for (int k = 0; k < Spectrum.GetLength(0); k++)
{
for (int l = 0; l < Spectrum.GetLength(1); l++)
{
Double K = Convert.ToDouble(k);
Double L = Convert.ToDouble(l);
Double G = (K * I) / Convert.ToDouble(Spectrum.GetLength(0)) + (L * J) / Convert.ToDouble(Spectrum.GetLength(1));
Complex exp = Complex.Exp(im * 2 * Math.PI * G);
sum += Spectrum[k, l] * exp;
}
}
//int value = (int)sum.Magnitude;
//if (value > 255) value = 255;
img[i, j] = sum.Magnitude / Math.Sqrt(Convert.ToDouble(Spectrum.GetLength(0)) * Convert.ToDouble(Spectrum.GetLength(1)));
}
}
img = this.Shift(img);
return img;
}