JPEG (Joint Photographic Experts Group) is a popular image compression standard that achieves high compression ratios by applying a series of mathematical transformations on the image data. The JPEG encoder in this project takes a color/grayscale image as input and applies the following steps:
-
Divide the image into blocks.
-
Apply a discrete cosine transform (DCT) on each block to convert it into a frequency domain representation.
-
Quantize the DCT coefficients by dividing by the quantization matrix.
-
Perform zigzag scanning for each block.
-
Truncate each encode block to the specified number of coefficient parameters and return the encoded image
The JPEG decoder reverses the above steps to reconstruct the original image from the compressed data.
-
Requires Python 3.10+
-
Install the required modules
pip3 install -r requirements.txt
-
Run the programs
JPEG Compression
python3 jpeg_compression.py
The algorithms were tested for a data set of color and grayscale images.
Sample output: