The Discrete Cosine Transform (DCT) algorithm constitutes an integral component of contemporary image/video processing applications.
The formal definition of DCT is:
\(X_k = \sum\limits_{n=0}^{N1}{x_n}\cos{\left[\dfrac{\pi}{N}\left(n+\dfrac12\right)k\right]}\quad k=0,\ldots,N1.\)
In JPEG standard, DCT algorithm is used to transform images to a set of independent parts (to reduce the entropy), and only after that can the image be quantized to decrease the number of bits to represent the image.
Note that DCT is a lossless transformation, and only the quantization remove some less important data.
The following demo, which is written in Matlab, demonstrates that DCT is lossless, because data is transformed and then restored to original data.
1 2 3 4 5 6 7 8 9 10 11 12 

The result is:
1 2 3 

As you can see, gx=fx
, therefore DCT is lossless.
If you want to learn DCT, this is best tutorial book: The Discrete Cosine Transform (DCT): Theory and Application