public static void Main()
double[,] f = new double[8, 8];
for (int i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
Console.WriteLine("f(x,y) = ");
Console.WriteLine(PrintMatriz(f));
double[,] F = new double[8, 8];
for (int u = 0; u < 8; u++)
for (int v = 0; v < 8; v++)
F[u, v] = 0.25d * C(u) * C(v) * Somatorio(f, u, v);
Console.WriteLine("... após realizar a DCT ...");
Console.WriteLine("F(x,y) = ");
Console.WriteLine(PrintMatriz(F));
private static double Somatorio(double[,] f, int u, int v)
for (int x = 0; x < 8; x++)
for (int y = 0; y < 8; y++)
double cos_u = Math.Cos( (((2 * x + 1) * u * Math.PI) / 16) );
double cos_v = (Math.Cos( (((2 * y + 1) * v * Math.PI) / 16) ));
soma += f[x, y] * cos_u * cos_v ;
private static double C(int i)
return (1 / Math.Sqrt(2));
private static string PrintMatriz(double[,] f)
for (int i = 0; i <= f.GetUpperBound(0); i++)
for (int j = 0; j <= f.GetUpperBound(1); j++)
matriz += (j == 0 ? "" : " | ") + f[i, j];