private void dct_direct(double f[][], double F[][]) {
        double a[] = new double[N];
        a[0] = sqrt(1. / N);
        for (int i = 1; i < N; i++) {
            a[i] = sqrt(2. / N);
        }

        double summ = 0;
        double koeff = 0;
        for (int u = 0; u < N; u++) {
            for (int v = 0; v < N; v++) {
                summ = 0.;
                for (int i = 0; i < N; i++) {
                    for (int j = 0; j < N; j++) {
                        koeff = cos((2 * i + 1) * u * PI / (2 * N)) *
                                cos((2 * j + 1) * v * PI / (2 * N));
                        summ += f[i][j] * koeff;
                    }
                    F[u][v] = a[u] * a[v] * summ;
                }
            }
        }
    }