Image Compression and Recognition



Data Compression, Descriptors & Pattern Recognition

Need for Data Compression

Data compression is the process of reducing the size of data without losing important information (or with acceptable loss).

Image Compression and Recognition

Why Do We Need Compression?

ReasonExplanationReal‑Life Example
Storage savingLess memory requiredMore photos on phone
Faster transmissionLess data to sendFaster WhatsApp images
Cost reductionLower bandwidth costStreaming platforms
Efficient processingFaster loadingYouTube videos

Simple Analogy: Packing clothes by rolling instead of folding to save suitcase space.

Huffman Coding

Huffman coding is a lossless compression technique that assigns:

  • Short codes to frequently used symbols
  • Long codes to rare symbols

Key Idea: More frequency → shorter binary code

Steps (Simplified)

  • Count symbol frequencies
  • Build binary tree
  • Assign 0 and 1
  • Generate prefix codes

Real‑Life Example: Common words like “the” are shortened in texting.

Advantages & Limitations

AdvantageLimitation
LosslessNeeds frequency table
EfficientStatic for fixed data

Run Length Encoding (RLE)

RLE replaces repeated symbols with a count + symbol.

Example: AAAAABBB → (5A)(3B)

Real‑Life Analogy: "10 red shirts" instead of listing each shirt.

Usage

Best ForPoor For
Simple imagesComplex photos

Shift Codes

Uses shift characters to switch between different symbol sets.

Example: Switching keyboard modes: letters → numbers → symbols

Application

  • Text compression
  • Fax transmission

Arithmetic Coding

Encodes entire message as a single fractional number between 0 and 1.

How It Works (Simple)

Instead of encoding symbol‑by‑symbol, it encodes probability ranges.

Comparison with Huffman

AspectHuffmanArithmetic
PrecisionMediumVery high
ComplexitySimpleComplex

Real‑Life Example: Representing a long sentence as one GPS coordinate.

JPEG Standard

JPEG is a lossy image compression standard mainly for photographs.

Key Steps

  • Color space conversion (RGB → YCbCr)
  • Block division (8×8)
  • DCT transform
  • Quantization (lossy)
  • Entropy coding

Why JPEG is Popular?

Removes details human eye can’t notice.

JPEG Characteristics

FeatureDescription
CompressionLossy
Best forPhotos
Poor forText & line drawings

MPEG Standard

MPEG compresses video + audio.

Key Concept

Removes:

  • Spatial redundancy (within frame)
  • Temporal redundancy (between frames)

MPEG Types

StandardUse
MPEG‑1CDs
MPEG‑2DVD, TV
MPEG‑4Streaming

Analogy: Only recording changes between scenes, not entire scene again.

Shape & Region Representation

Boundary Representation

Represents object shape using only its boundary.

Example: Drawing outline of a leaf instead of coloring it.

Methods

  • Chain codes
  • Polygonal approximation

Boundary Description

Describes boundary using mathematical features.

Common Features

  • Length
  • Curvature
  • Direction

Use: Object recognition and matching.

Fourier Descriptor

Represents shape boundary in frequency domain.

Why Useful?

  • Rotation invariant
  • Scale invariant

Analogy: Recognizing a song by tune, not speed.

Regional Descriptors

Describe entire region, not just boundary.

Types

DescriptorMeaning
AreaNumber of pixels
CentroidCenter point
PerimeterBoundary length

Topological Features

Features that do not change with rotation or stretching.

Examples

FeatureMeaning
HolesLoops inside object
ConnectivityLinked parts

Example: Coffee mug vs plate (hole matters).

Texture

Texture describes surface patterns.

Texture Properties

PropertyExample
SmoothPaper
RoughSand
RegularTiles

Patterns & Pattern Classes

Pattern: A pattern is a set of features.
Pattern Class: Group of similar patterns.

Example

PatternClass
Handwritten 5Digit
FaceHuman

Recognition Based on Matching

Unknown pattern is compared with stored templates.

Steps

  • Feature extraction
  • Template matching
  • Decision

Real‑Life Example: Face unlock on smartphone.

Final Comparison Table

TopicKey IdeaUsed In
HuffmanFrequencyText
JPEGLossyImages
MPEGMotionVideo
FourierShapeRecognition
TextureSurfaceVision

Exam Memory Shortcuts

  • Huffman → Frequency
  • RLE → Repetition
  • JPEG → Photos
  • MPEG → Video
  • Boundary → Outline
  • Region → Area