First year C project at Ensimag - Grenoble INP - 2017
Conversion of .jpg or .jpeg images into .ppm images. Works with all horizontal and vertical downsampling ratios.
See JPEG encoding to understand the different steps.
Note: To avoid architecture compatibility issues, the use of a linux virtual machine environment is recommended. (Vagrant)
make all
To test the program on a specific image:
./bin/jpeg2ppm ./images/image.jp[e]g
To test the program on all images of the ./images
directory:
make test
Cleaning (jpeg2ppm
, .ppm
, .pgm
, .o
)
make clean
// Creation of the image (Variable Length Decoding using the Huffman tables)
image * my_image = decompress(jdesc, stream);
// De-quantization using the Quantization tables
de_quantization (jdesc, my_image);
// Unraveling of the zigzag ordering
de_zig_zag(my_image);
// Reverse Discrete Cosine Transform
idct(my_image);
// Decoded image reassembled from blocks
image_to_pixels(my_image);
// Conversion of the image from YCbCr to RGB
rgb(my_image);
// Creation of the .ppm or .pgm file (depending on if its a B&W or RGB image)
ppm(filename, my_image);
┌───────────────────────────────────────────────────────────┐
│ image │
│ │
│ │
│ ┌ mcu_table ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ │ mcu │ │ │
│ │ │ │
│ │ │ ┌ ─block_table─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ │ │
│ │ ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │ │
│ │ │ │ │Block│Block│Block│Block│Block│Block│ ... │ │ │ │ │
│ │ │ Y │ Y │ Y │ Y │ Cb │ Cb │ │ │ │
│ │ │ │ └─────┴─────┴─────┴─────┴─────┴─────┴─────┘ │ │ │ │
│ │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ │
│ │ └─────────────────────────────────────────────────┘ │ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ │ mcu │ │ │
│ │ │ │
│ │ │ ┌ ─block_table─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ │ │
│ │ ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │ │
│ │ │ │ │Block│Block│Block│Block│Block│Block│ ... │ │ │ │ │
│ │ │ Y │ Y │ Y │ Y │ Cb │ Cb │ │ │ │
│ │ │ │ └─────┴─────┴─────┴─────┴─────┴─────┴─────┘ │ │ │ │
│ │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ │
│ │ └─────────────────────────────────────────────────┘ │ │
│ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
│ │
└───────────────────────────────────────────────────────────┘