by cdavid · 6y ago · 0 comments
Assuming you understand that a Fourier transform is an operation to go from from time domain to the frequency domain, the problem solved by DCT, DST, etc. is related to the fact that digital signal processing are finite, and without any care, you introduce 'irregularities' if you use a 'normal' Fourier transform.
So the main idea of DCT/DST/etc. is to implicitly 'copy' and/or mirror the signal, to reduce the artefacts/irregularities introduced by Fourier Transform. Reducing irregularities intuitively leads to more regular signals, and the more regular your signal, the quicker the high frequencies decrease, which is the compression effect of DCT.
More mathematically, but still very informally: DCT/DST is about boundary conditions. Using DFT (the 'normal' Fourier transform for digital signals) will imply discontinuities at the boundaries. For continuous time signals, an intuitive way to define regularities is to measure the decay of successive derivative of a function f(t), by looking at convergence convergence of t^n f(t) as t -> inf for n. That implies that regular functions have bounded Fourier transforms, and the more regular, the faster the Fourier transform decays.
The DST/DCT, by mirroring/copying the signal, reduce irregularities, and hence their coefficients decrease faster.
And then you explain that for images, contours are fast changing, and you have the justification for Fourier coefficients truncation ~ compression.
Explaining how DCT helps instead of DFT is the harder part.
So if I want to find the DFT of the 4-sample sequence 1, 2, 3, 4, it is like finding the DFT of the sequence 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, ..., which has the discontinuity you mention between the 4s and 1s.
With the DCT, it's like the periodic sequence is 1, 2, 3, 4, 4, 3, 2, 1, 1, 2,..., which has less discontinuity. (There are different DCT variants on the exact offset of the reflection, but that can be ignored in this discussion.)
The problem gets amplified because in images (JPEG) or audio (mp3, etc.), the signal is divided by blocks (windows in audio) first, and those blocks introduce more discontinuities.
Ofc, it depends on what you mean exactly by compression. At least for audio, it relates well to keeping the main signal quality because in a sense, the earing system does a frequency decomposition (see e.g. https://www.ncbi.nlm.nih.gov/books/NBK10946/figure/A896/?rep...), and the higher the frequency, the less sensitive to it we tend to be.
This is what the DCT is exploiting -- that we can adjust the high-frequency terms and it will still look OK to our eyes.