Coconote
AI notes
AI voice & video notes
Export note
Try for free
JPEG Compression Algorithm
Jul 20, 2024
JPEG Compression Algorithm
Introduction
Uncompressed image: 46 MB
Compressed JPEG image: 4.1 MB
Main focus: Understand how JPEG can compress images significantly while maintaining high quality
Importance of JPEG
Majority of digital images from phones/cameras use JPEG format
86% of internet images are JPEGs
Video compression algorithms (e.g., h.264) are related
How JPEG Works
General Idea
: Analyzes image sections, removes elements not easily perceived by human eyes
Quality Scale
: Adjust compression amount (more compression = lower quality)
Artifacts
: Defects appearing with high compression
Steps of JPEG Compression
1.
Color Space Conversion
Convert each pixel's RGB (0-255) into luminance (Y) and chrominance (Cb and Cr)
No data removed during this step
2.
Chrominance Downsampling
Based on human eye's lower sensitivity to color (chrominance)
Downsamples Cb and Cr by averaging 2x2 pixel blocks, reducing chrominance resolution by 1/4
3.
Discrete Cosine Transform (DCT)
Divides image into 8x8 pixel blocks
Each block transformed from RGB to a combination of 64 base images
4.
Quantization
Dividing constants from DCT by values in a quantization table, rounding results to nearest integers
Discards high-frequency data (not perceived well by human eyes) resulting in many zeros
Separate quantization tables for luminance and chrominance
5.
Run-Length and Huffman Encoding
Lists values in a zigzag pattern to group zeros together
Uses run-length encoding to compress zero sequences
Huffman encoding further compresses data
Reconstruction of Images
Reverse steps: Decode run-length and Huffman, multiply by quantization values, assemble base images, reconvert to RGB
Performance and Shortcomings
Compression Level
: Adjustable, higher compression leads to visible artifacts
Precision Reduction
: More reduction in high-frequency areas; JPEG not suitable for vector graphics
Other Formats
: JPEG is common but other formats may offer better compression
H.264 Compression
More complex than JPEG, compresses video by exploiting inter-frame information
Conclusion
JPEG compression leverages nuances in human vision to reduce file size significantly
Widely used due to effectiveness and royalty-free status
Sponsored by Brilliant
Interactive courses on STEM topics
20% off an annual subscription for first 200 sign-ups via provided link
Final Notes
Emphasis on engineering education
Support and subscribe to Branch Education on YouTube/Patreon
📄
Full transcript