Guest User

Untitled

a guest
May 11th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. const unsigned int DCT1 = 8;
  9. const unsigned int DCT2 = 8;
  10.  
  11. int V[DCT1][DCT2] =
  12. {
  13.     {58,45,29,27,24,19,17,20},
  14.     {62,52,42,41,38,30,22,18},
  15.     {48,47,49,44,40,36,31,25},
  16.     {59,78,49,32,28,31,31,31},
  17.     {98,138,116,78,39,24,25,27},
  18.     {115,160,143,97,48,27,24,21},
  19.     {99,137,127,84,42,25,24,20},
  20.     {74,95,82,67,40,25,25,19},
  21. };
  22.  
  23. double sum(int i, int j){
  24.     int N = 64;
  25.     double sum = 0.0;
  26.     for (int x=0; x<N; x++)
  27.     {
  28.        
  29.         for (int y=0; y<N;y++)
  30.         {
  31.            
  32.             sum+=V[y][x]*cos(((2*y+1)*i*M_PI)/(2*N))*cos(((2*x+1)*j*M_PI)/(2*N));
  33.         }
  34.     }
  35.     return sum;
  36. }
  37.  
  38.  
  39. int main ()
  40. {
  41.     int N=64;
  42.     double c = 0.0;
  43.     int T[DCT1][DCT2];
  44.     for (int i=0; i<N-1; i++)
  45.     {
  46.        
  47.         for (int j=0; j<N-1;j++)
  48.         {
  49.             if ((i!=0 )&&(j!=0))
  50.                 c=2/(double)N;
  51.             else if ((i==0 )||(j==0))
  52.             {
  53.                 c=1/(double)N;
  54.             }
  55.            
  56.             T[i][j]=c*sum(i,j);
  57.         }
  58.     }
  59.     cout<<T;
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment