Total Pageviews

Thursday, September 10, 2026

๐Ÿ–ผ️ Image Compression Techniques

๐Ÿ–ผ️ Image Compression Techniques

Learn how digital images are compressed using mathematical and information-theoretic techniques such as RLE, Huffman Coding, DCT, Quantization and JPEG.

1️⃣ Upload Your Image

No image selected.

2️⃣ Image for Compression Study

๐Ÿ–ผ️ Original Image

Uploaded image

Upload an image to begin.

⚫ Grayscale Version

3️⃣ What is Image Compression?

Image compression reduces the number of bits required to represent an image while attempting to preserve the important visual information.

๐ŸŸข Lossless Compression

The reconstructed image is exactly identical to the original image. No information is permanently lost.

Examples: RLE, Huffman, LZW, PNG.

๐ŸŸ  Lossy Compression

Some information is discarded to obtain a much smaller file. The reconstructed image is usually an approximation.

Example: JPEG.

๐Ÿ”ต Redundancy

Compression removes different forms of redundancy:

  • Spatial redundancy
  • Statistical redundancy
  • Psychovisual redundancy

๐ŸŸฃ Main Goal

Reduce storage and transmission requirements while maintaining acceptable image quality.

4️⃣ Major Compression Techniques

Technique Type Main Idea Typical Use
RLE Lossless Encode repeated values Simple images
Huffman Lossless Short codes for frequent symbols JPEG / general coding
LZW Lossless Dictionary-based coding GIF / TIFF
DPCM Predictive Encode prediction error Image signals
DCT Transform Convert spatial data to frequency coefficients JPEG
DWT Transform Wavelet decomposition JPEG 2000
Quantization Lossy Reduce coefficient precision JPEG

5️⃣ Compression Ratio

Compression ratio compares the original size with the compressed size.

CR = Original Size / Compressed Size

Percentage reduction:

Reduction = [(Original − Compressed) / Original] × 100%
Click Calculate Ratio.

6️⃣ Run-Length Encoding (RLE)

RLE is a simple lossless compression technique. Instead of storing every repeated pixel separately, it stores the value and the number of consecutive repetitions.

AAAAABBBCCAAAA
becomes:
A5 B3 C2 A4

๐Ÿ”ฌ Interactive RLE Demonstration

Enter a sequence and click Compress.

7️⃣ Entropy and Image Compression

Entropy measures the average information contained in the image intensity distribution.

H = −ฮฃ pแตข log₂(pแตข)

For an 8-bit grayscale image:

0 ≤ H ≤ 8 bits/pixel
Important: Lower statistical redundancy generally provides less opportunity for lossless compression, while predictable/repetitive data is often more compressible. Entropy provides a theoretical lower bound for average lossless coding length under the appropriate source model.

8️⃣ DCT — Discrete Cosine Transform

JPEG divides an image into 8×8 blocks and applies the Discrete Cosine Transform to represent spatial intensity variations as frequency coefficients.

F(u,v) = (1/4) C(u)C(v) ฮฃฮฃ f(x,y) cos[(2x+1)uฯ€/16] cos[(2y+1)vฯ€/16]
where:
f(x,y)

Original 8×8 image block.

F(u,v)

DCT frequency coefficient.

u,v

Frequency coordinates.

C(u), C(v)

Normalization factors.

8×8 Image Block

The upper-left coefficient is called the DC coefficient. Other coefficients represent increasing spatial frequencies.

9️⃣ Quantization

Quantization reduces the precision of DCT coefficients. This is the major stage responsible for information loss in typical JPEG compression.

Q(u,v) = round[F(u,v) / Qtable(u,v)]

Larger quantization values produce stronger compression but usually lower image quality.

Small Quantization

More coefficients are retained.

Higher quality → Larger file

Large Quantization

More coefficients become zero or smaller.

Lower quality → Smaller file

๐Ÿ”Ÿ JPEG Compression Pipeline

๐Ÿ–ผ️
Image
๐ŸŒˆ
RGB → YCbCr

8×8 Blocks
๐Ÿ“
DCT

Quantization
↗️
Zig-Zag
๐Ÿ”ข
RLE
๐ŸŒณ
Huffman
๐Ÿ“ฆ
Compressed
Click Start JPEG Animation.

1️⃣1️⃣ Measuring Compression Quality

Mean Squared Error — MSE

MSE = (1/MN) ฮฃฮฃ [I(i,j) − K(i,j)]²

where I is the original image and K is the reconstructed image.

Peak Signal-to-Noise Ratio — PSNR

PSNR = 10 log₁₀(MAX²/MSE)

For an 8-bit image:

MAX = 255
Generally: Lower MSE means less pixel-wise error. Higher PSNR generally indicates better reconstruction quality.

1️⃣2️⃣ Lossless vs Lossy Compression

Feature Lossless Lossy
Information loss No Yes
Reconstruction Exactly original Approximation
Compression ratio Usually lower Usually higher
Quality degradation None Possible
Examples PNG, RLE, Huffman, LZW JPEG
Best suited for Medical/technical graphics, text-like images Photographs and natural scenes

1️⃣3️⃣ Three Types of Redundancy

1. Statistical Redundancy

Some symbols occur much more frequently than others. Huffman coding can exploit this redundancy.

2. Spatial Redundancy

Neighboring pixels often have similar values. Predictive and transform techniques can exploit this property.

3. Psychovisual Redundancy

Human vision does not perceive all image information equally. Lossy techniques can discard some less perceptually important information.

1️⃣4️⃣ Applications

๐Ÿ“ฑ Mobile Applications

Reducing image size saves storage and network bandwidth.

๐ŸŒ Web Images

Compressed images improve page loading and reduce bandwidth usage.

๐Ÿ›ฐ️ Satellite Images

Compression reduces the amount of data that must be transmitted.

๐Ÿฅ Medical Imaging

Lossless methods are particularly important when exact pixel information must be preserved.

๐Ÿ“น Video Processing

Image compression principles form an important foundation for video compression systems.

☁️ Cloud Storage

Compression can reduce storage requirements for large image collections.

๐ŸŽฏ Complete Compression Flow

Image → Remove Redundancy → Transform / Predict → Quantize → Entropy Coding → Compressed Image

Important Formulas

Compression Ratio = Original Size / Compressed Size
H = −ฮฃpแตขlog₂(pแตข)
MSE = (1/MN)ฮฃฮฃ[I(i,j)−K(i,j)]²
PSNR = 10log₁₀(255²/MSE)

No comments:

Post a Comment