PPM Compression Program

Details about and an example input/output from this program

This was my midterm project for my sophomore year fall semester CS course (CS40: Data Structures). This C program compressess .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%.

an example input image

Example Input

Original Image File Size: 57 KB

Example Output

Example Output

Compressed Image File Size: 20 KB

Decompressed Image to Original Image Match: 93.4%. Match % found using a program I created that computes the root mean square difference of pixel values across two images.

Key CS Concepts

  • Bitpacking: Working directly with bit operators in order to optimize storage of data
  • Data Representation: Converting from RGB to Component Video and back, and using 2D arrays to store 2x2 blocks of pixels encoded with Discrete Cosine Transformations that are then packed into a 32 bit integer
  • File I/O: Reading and writing .ppm files