Answer the question
In order to leave comments, you need to log in
How to implement the Discrete Cosine Transform image in Python yourself without resorting to a library?
Good afternoon, there was such a problem. I just can not implement the image DCT. There is no good material on the Internet explaining this moment. It is also not clear to take an 8x8 matrix from the original NxN image and perform operations on the entire matrix or on each pixel. Below is an explanation of the conversion algorithm
Answer the question
In order to leave comments, you need to log in
The transformation is defined over an NxN matrix. In the formulas in the tutorial, f(u,v) is the value of the pixel in the cell with indices u, v. You need to stupidly implement the formulas from the textbook (4 nested loops).
Whether you need to apply the transformation separately to each block of 8x8 pixels or not - this should be written in the task. In some jpeg, the transformation is applied separately to each piece of 8x8 pixels, and not to the entire image, because on a large scale the image is too irregular. And for regular patterns, the result of the discrete cosine transform compresses well (many zeros and small coefficients). Also, applying the transformation to the entire image will be slower.
But this does not apply to the transformation itself. This is a subtlety of the jpeg algorithm.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question