Sunday, November 04, 2007

OpenCV: DCT and IDCT

float data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };

CvMat a, b, c;
a = cvMat(2,4,CV_32FC1,data);
b = cvMat(2,4,CV_32FC1,data); // or initialize b,c
c = cvMat(2,4,CV_32FC1,data);

cvDCT(&a, &b, CV_DXT_FORWARD);
cvDCT(&b, &c, CV_DXT_INVERSE);


original matrix:
1 2 3 4
5 6 7 8

after DCT:
12.728 -3.154 0.000 -0.224
-5.657 0.000 0.000 0.000

after IDCT:
1 2 3 4
5 6 7 8

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. kenny4:15 AM

    hi, can u teach me how to extract the coefficients of the DCT using openCV?? thanks alot!

    ReplyDelete
  3. kenny4:16 AM

    my email is kentona7@yahoo.com

    Thanks!

    ReplyDelete
  4. Anonymous8:51 AM

    well, aren't these values DCT coefficients ?

    ReplyDelete
  5. Anonymous9:35 PM

    i'm new to opencv but how did you display the values of the dct and it's inverse?

    ReplyDelete