Skip to main content
. 2020 Jan 7;20(2):342. doi: 10.3390/s20020342
Algorithm 1. DCT Algorithm
  • 1. 

    The input image is N by M;

  • 2. 

    f(i,j) is the intensity of the pixel in row i and column j;

  • 3. 
    F(u,v) is the DCT coefficient in row u and column v of the DCT matrix:
    F(u,v)=2C(u)C(v)Ni=1Nj=1Nf(i,j)cos((2i1)(u1)π2N)cos((2j1)(v1)π2N)
    =2C(u)C(v)Ni=0N1j=0N1f(i,j)cos((2i+1)uπ2N)cos((2j+1)vπ2N)
    where0i, vN1andC(n)={12(n=0)1(n0)
  • 4. 

    For most images, much of the signal energy lies at low frequencies; these appear in the upper left corner of the DCT.

  • 5. 

    Compression is achieved since the lower right values represent higher frequencies, and are often small - small enough to be neglected with little visible distortion.

  • 6. 

    The DCT input is an 8 by 8 array of integers. This array contains each pixel’s grayscale level;

  • 7. 

    8-bit pixels have levels from 0 to 255.