Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- const unsigned int DCT1 = 8;
- const unsigned int DCT2 = 8;
- int V[DCT1][DCT2] =
- {
- {58,45,29,27,24,19,17,20},
- {62,52,42,41,38,30,22,18},
- {48,47,49,44,40,36,31,25},
- {59,78,49,32,28,31,31,31},
- {98,138,116,78,39,24,25,27},
- {115,160,143,97,48,27,24,21},
- {99,137,127,84,42,25,24,20},
- {74,95,82,67,40,25,25,19},
- };
- double sum(int i, int j){
- int N = 64;
- double sum = 0.0;
- for (int x=0; x<N; x++)
- {
- for (int y=0; y<N;y++)
- {
- sum+=V[y][x]*cos(((2*y+1)*i*M_PI)/(2*N))*cos(((2*x+1)*j*M_PI)/(2*N));
- }
- }
- return sum;
- }
- int main ()
- {
- int N=64;
- double c = 0.0;
- int T[DCT1][DCT2];
- for (int i=0; i<N-1; i++)
- {
- for (int j=0; j<N-1;j++)
- {
- if ((i!=0 )&&(j!=0))
- c=2/(double)N;
- else if ((i==0 )||(j==0))
- {
- c=1/(double)N;
- }
- T[i][j]=c*sum(i,j);
- }
- }
- cout<<T;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment