Skip to content

JPEG Encoding with Discrete Cosine Transform, Quantisation & Run-Length Compression

Notifications You must be signed in to change notification settings

WillKirkmanM/jpeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JPEG Encoder

JPEG Encoding with Discrete Cosine Transform, Quantisation & Run-Length Compression

JPEG Image Encoder

This repository contains a JPEG image encoder implemented in C. It takes a BMP image as input and encodes it using Discrete Cosine Transform (DCT), quantisation, and Run-Length Encoding (RLE), producing a compressed output file.

Functionality

The encoder performs the following steps:

  1. Image Loading: Loads a BMP image from the specified input file using the image_load function.
  2. Color Conversion: Converts the RGB color space to YCbCr.
  3. DCT: Applies the Discrete Cosine Transform (DCT) on 8x8 blocks of the image using the forward_dct function.
  4. Quantisation: Quantizes the DCT coefficients using predefined quantisation matrices and the quantize_block function.
  5. RLE: Encodes the quantized coefficients using Run-Length Encoding (RLE).
  6. File Output: Writes the encoded data to the specified output file, including a header, quantisation tables, and RLE encoded data.

Repository Structure

The repository has the following structure:

  • include/: Contains header files, including encoder.h, which defines the image and encoder structures and function prototypes.
  • src/: Contains the source code files.
    • jpeg_encoder.c: Implements the JPEG encoding logic, including color conversion, DCT, quantisation, and RLE. The main encoding function is jpeg_encode.
    • dct.c: Implements the Discrete Cosine Transform (DCT) and quantisation functions, including forward_dct, quantize_block, and related utility functions.
    • main.c: Contains the main function that parses command-line arguments, loads the image, performs the encoding, and saves the output.
    • utils/: Contains utility functions.
      • bitstream.c: Implements bitstream reading and writing functions (currently not used in this encoder).
      • image.c: Implements image loading and saving functions, including image_load and image_save.
  • Makefile: Defines the build process for the project.
  • README.md: This file, providing an overview of the project.

Building the Encoder

To build the encoder, you need a C compiler (e.g., GCC) and the make build tool.

  1. Clone the repository.
  2. Navigate to the repository's root directory.
  3. Run the make command.
make

About

JPEG Encoding with Discrete Cosine Transform, Quantisation & Run-Length Compression

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published