Problems with DCT and IDCT algorithm in java

前端 未结 1 1475
萌比男神i
萌比男神i 2021-02-06 11:40

Here I have my DCT algorithm class with \"applyDCT\" and \"applyIDCT\" methods. Technically after doing a forward DCT (discrete cosine transform) on a 2x2 table of random intege

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 11:58

    I have resolved this problem, I am sorry if my question was unclear but here is what was not right: The IDCT method had to have the coefficient inside the i and j for loops :

    public double[][] applyIDCT(double[][] F) {
            double[][] f = new double[N][N];
            for (int i=0;i

    This only works for a 8x8 bloc of data, or else you would have to change this:

    (c[u]*c[v])/4.0)
    

    into something like this:

    (2*c[u]*c[v])/Math.sqrt(M*N)
    

    Where M and N are the dimentions of the table...

    Here are the results with a 2x2 block of data:

    Original values
    ---------------
    54.0 => f[0][0]
    35.0 => f[0][1]
    128.0 => f[1][0]
    185.0 => f[1][1]
    
    From f to F
    -----------
    200.99999999999994 => F[0][0]
    -18.99999999999997 => F[0][1]
    -111.99999999999997 => F[1][0]
    37.99999999999999 => F[1][1]
    
    Back to f
    ---------
    54.0 => f[0][0]
    35.0 => f[0][1]
    128.0 => f[1][0]
    185.0 => f[1][1]
    

    0 讨论(0)
提交回复
热议问题