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).
Why Do We Need Compression?
| Reason | Explanation | Real‑Life Example |
|---|---|---|
| Storage saving | Less memory required | More photos on phone |
| Faster transmission | Less data to send | Faster WhatsApp images |
| Cost reduction | Lower bandwidth cost | Streaming platforms |
| Efficient processing | Faster loading | YouTube 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
| Advantage | Limitation |
|---|---|
| Lossless | Needs frequency table |
| Efficient | Static 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 For | Poor For |
|---|---|
| Simple images | Complex 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
| Aspect | Huffman | Arithmetic |
|---|---|---|
| Precision | Medium | Very high |
| Complexity | Simple | Complex |
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
| Feature | Description |
|---|---|
| Compression | Lossy |
| Best for | Photos |
| Poor for | Text & line drawings |
MPEG Standard
MPEG compresses video + audio.
Key Concept
Removes:
- Spatial redundancy (within frame)
- Temporal redundancy (between frames)
MPEG Types
| Standard | Use |
|---|---|
| MPEG‑1 | CDs |
| MPEG‑2 | DVD, TV |
| MPEG‑4 | Streaming |
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
| Descriptor | Meaning |
|---|---|
| Area | Number of pixels |
| Centroid | Center point |
| Perimeter | Boundary length |
Topological Features
Features that do not change with rotation or stretching.
Examples
| Feature | Meaning |
|---|---|
| Holes | Loops inside object |
| Connectivity | Linked parts |
Example: Coffee mug vs plate (hole matters).
Texture
Texture describes surface patterns.
Texture Properties
| Property | Example |
|---|---|
| Smooth | Paper |
| Rough | Sand |
| Regular | Tiles |
Patterns & Pattern Classes
Pattern: A pattern is a set of features.
Pattern Class: Group of similar patterns.
Example
| Pattern | Class |
|---|---|
| Handwritten 5 | Digit |
| Face | Human |
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
| Topic | Key Idea | Used In |
|---|---|---|
| Huffman | Frequency | Text |
| JPEG | Lossy | Images |
| MPEG | Motion | Video |
| Fourier | Shape | Recognition |
| Texture | Surface | Vision |
Exam Memory Shortcuts
- Huffman → Frequency
- RLE → Repetition
- JPEG → Photos
- MPEG → Video
- Boundary → Outline
- Region → Area