Skip to content
/ JPEG Public

Implementation of the JPEG compression algorithm with python, managing RGB and YUV color space, different sub-sampling options and a custom Huffman encoding.

License

Notifications You must be signed in to change notification settings

LAVS-TM/JPEG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JPEG Profile

This repository contains a simple reimplementation of the JPEG algorithm.

Objectives

The main goal was to recode JPEG for color images. In particular, our code is supposed to :

  • Manage the color, leaving the user the choice of compression in the RGB or YUV space, as well as the different sub-sampling options (4:4:4, 4:2:2 and 4: 2:0) of chroma.
  • Handle the case of images whose dimensions are not necessarily multiples of 8.
  • Allow the user to choose the quality index q for the luminance quantization matrix.
  • Encode via Huffman's JPEG tables the different macro-blocks, to be able to calculate the (true) compression rate of each macro-block (and therefore of the image in total).

Implementation

The compression and the decompression process are both implemented in four different steps.

For the compression :

First, the input image is divided into non-overlapping 8 x 8 macro-blocks.

Macro-Blocks

Then, the DCT of each (8 x 8 block) - 128 is computed. This DCT is then quantized by some quantification matrix Q.

Finally, the algorithm arrange the quantized values in sequence following the zigzag order and use Huffman encoding with pre-determined conversion tables.

JPEG decompression process is the exact inverse of the compression scheme.

Jpeg

Usage

A test of our JPEG compression algorithm is simply available by executing the jpeg.py python file as follow :

python jpeg.py

About

Implementation of the JPEG compression algorithm with python, managing RGB and YUV color space, different sub-sampling options and a custom Huffman encoding.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages