Contirbuted by < Brian Cheng >
In this project I want to implement DCT into RV32IM.I chose the project jpeg-encoder from Michael Schier's github.
The Discrete Cosine Transform (DCT) stands as a fundamental mathematical transformation extensively employed in the realms of signal processing and data compression applications. Its pivotal application lies in the domain of jpeg standard image compression, where it serves as a cornerstone for efficiently representing image data.
Given the limitations of the human visual system, particularly its reduced sensitivity to high-frequency signals, the DCT is instrumental in capturing and representing essential image features while minimizing the impact of components that might be less perceptible to the human eye. This attribute contributes significantly to the effectiveness of image compression algorithms, as it allows for the removal or quantization of high-frequency components without significantly compromising the perceived visual quality of the compressed image. Therefore, the integration of the DCT in JPEG compression plays a crucial role in achieving a balance between compression efficiency and perceptual quality.
This transform is applied to an 8x8 block of image data. The indices (x, y) in the formula represent the spatial frequencies, and (i, j) represent the pixel coordinates within the block.
The result of applying the 2D-DCT to an 8x8 block leads to coefficients that represent different frequency components. The position (i, j) in the resulting image corresponds to the spatial location of these coefficients. This is often visualized in a plot like the one you provided:
Each position (i, j) in the resulting image corresponds to a specific frequency component, and the brightness or color intensity at that position indicates the magnitude of the corresponding DCT coefficient.
From Discrete Cosine Transform (DCT) of Images and Image Compression we learn
when the block is
At this time I want to implement formula above to complete my dct function.
I found that matlab have the function to generate Matrix.
And the result is
But if I want to implement this function into my code I should write my own function, and as below:
And the result is
We can see the , so the logic for the function I wrote is correct.
Work
The following C code is The follow