PPM Compression Program
A machine-level lossy image compressor in C achieving 3:1 compression ratios with ~95% fidelity retention.
This was my midterm project for my sophomore year fall semester CS course (CS40: Machine Structures). This C program compresses .ppm images using a discrete cosine transformation, linear quantization, and bitpacking of 32-bit integers. Compressed image file sizes are around 1/3 of the original, and upon decompression an image differs from the original image by only around 5%.
Original .ppm Image
The raw image format before transformation and bitpacking. Each pixel contains uncompressed 24-bit RGB values.
Decompressed Output Result
Compressed image file size: 20 KB.
Decompressed image to original image match: 93.4%. The match percentage was verified using a companion program I created that computes the root-mean-square difference of pixel values across both images.
Key Computer Science Concepts
-
Bitpacking: Direct manipulation with bitwise operators to pack quantized luminance/chrominance coefficients into single 32-bit machine words for minimal footprint.
-
Data Representation & DCT: Transforming from RGB color space to Component Video (Y/Pb/Pr), mapping 2x2 blocks with Discrete Cosine Transforms to separate baseline intensity from fine spatial variation.
-
Binary File I/O: Streaming and parsing raw byte formats across custom binary file layouts.