Skip to content

HBasma/dct-image-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

DCT Image Compression (JPEG Style)

Description

This project implements image compression using the Discrete Cosine Transform (DCT), inspired by JPEG compression techniques.

The image is divided into 8×8 blocks, transformed into the frequency domain using DCT, then reconstructed using inverse DCT (IDCT). The quality of reconstruction is evaluated using PSNR.


Features

  • DCT implementation using:
    • Mathematical formula
    • Matrix multiplication
  • Inverse DCT (IDCT)
  • Block-based processing (8×8)
  • Performance comparison (formula vs matrix)
  • PSNR (image quality evaluation)
  • Simple graphical interface using Tkinter

How it works

The image is first converted to grayscale and resized to ensure dimensions divisible by 8.

Then:

  • The image is divided into 8×8 blocks
  • Each block is transformed using DCT
  • Two methods are used:
    • Direct formula (slow)
    • Matrix multiplication (optimized)

After that:

  • IDCT is applied to reconstruct the image
  • PSNR is computed to evaluate reconstruction quality

Key concepts

  • Discrete Cosine Transform (DCT)
  • Inverse DCT (IDCT)
  • Block-based image compression
  • Frequency domain representation
  • PSNR (Peak Signal-to-Noise Ratio)

How to run

pip install numpy opencv-python pillow
python dct-image-compression.py

About

DCT-based image compression with block processing (8x8) formula vs matrix implementation nd PSNR evaluation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages