![Page 1: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/1.jpg)
JPEG: An Image Compression System
ISO/IEC DIS 10918-1ITU-T Recommendation T.81http://www.jpeg.org/
Nimrod Peleg
update: Sept. 2005
![Page 2: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/2.jpg)
Basic Structure
Source Image Data
Reconstructed Image Data
Encoder DecoderCompressed Data
![Page 3: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/3.jpg)
Encoder StructureSource Image Data
EncoderModel
StatisticalModel
EntropyEncoding
CompressedData
Model Parameters Entropy Coding Tables
“Descriptors”
![Page 4: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/4.jpg)
Decoder StructureCompressedData
StatisticalModel
EntropyDecoder
DecoderModel
Model ParametersEntropy Coding Tables
Descriptors
ReconstructedImage Data
![Page 5: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/5.jpg)
Image Compression Models
• A Unit that generates a set of “descriptors”• The simplest model:send the data itself to the entropy encoder:
PCMThe set of descriptors is all possible values of
the samples
![Page 6: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/6.jpg)
Compression Models: DPCM
A simple predictor:We assume the former sample to
predict the current one, and send (to the entropy encoder) the difference between the predicted and real value.
![Page 7: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/7.jpg)
Lena: The original
![Page 8: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/8.jpg)
Histogram of Lena
0 50 100 150 200 250
0
500
1000
1500
2000
2500
3000
Matlab: imhist
![Page 9: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/9.jpg)
Sample Position
SampleIntensity
Difference Sample Position
Intensity ofdifference
1 Line Histogram
![Page 10: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/10.jpg)
DPCM (Cont’d)The better
performance of DPCM relative to PCM is due to the high degree of correlation found in most images
Note that this model is lossless !
Histogram of differences (Lena, one neighbor to the left predictor)
0 50 100 150 200 250
0
5
10
15
20
25
30
35
40
![Page 11: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/11.jpg)
DCT Encoder Model• Used in Lossy JPEG modes• Output is fed to Entropy encoder
Source Image
DCT Q
DPCMDC
AC Coefficients
DCCoefficients
To EntropyCoding
![Page 12: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/12.jpg)
DCT Decoder Model
DCCoefficients
IDCTIQ
DPCM DC
AC Coefficients
Reconstructed Image
• Quantization is the principal source of distortion to the reconstructed image.
• Q is done to each coeff. independently, so it can match the HVS response.
![Page 13: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/13.jpg)
Block Oriented DCT Reconstruction(A too strong quantization effect)
32x32 block A strong quantization
![Page 14: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/14.jpg)
The “DCT” Image
![Page 15: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/15.jpg)
Quantization – Color Example
Fine quantization Coarse quantization
![Page 16: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/16.jpg)
Reconstruction from Fourier Magnitude or Phase
DFT
Magnitude Phase
IDFT with constant Magnitude
IDFT with constant Phase
Original
+
![Page 17: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/17.jpg)
Transform Coding - Example16×16 block
of pixelsDCT
coefficients
![Page 18: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/18.jpg)
Other Compression Models• Other models were candidates for JPEG:
– Block Truncation Coding (BTC)– Vector quantization (VQ)– Other Transform Coding (TC) schemes– Sub-band coding (SBC)– Other predictive coding models
• The DCT model provided (Jan.1988) best average image quality for a given bit-rate
![Page 19: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/19.jpg)
Coding Model
Zig-Zag scan (instead of Raster scan) achieves longer “zero coefficients sequences”, after quantization.
HorizontalFrequency
VerticalFrequency
DC
![Page 20: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/20.jpg)
Zig-Zag example
DC
![Page 21: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/21.jpg)
Entropy Encoding/Decoding
2 entropy coding structures used in JPEG:• Huffman coding:
– More than 50 years old (1952)– Computationally simpler– Implementation simpler– Requires known / calculated code tables
• Arithmetic Coding– About 10% higher performance– Code book adapts dynamically to coded data– IBM Patented...
David A. Huffman1925-1999
![Page 22: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/22.jpg)
Huffman Entropy Encoder• Statistical model: converts descriptors into
symbols, each assigned to particular code word• Adapter: responsible for the assignments of
code words needed by the encoder• Code Tables: can be fixed or adapted to data
to improve efficiency by a few percent
• Note that 1 pass (fixed tables) or 2 passes (adaptive table) are options
![Page 23: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/23.jpg)
Huffman Encoder Scheme
Huffman entropy coding table
a
b
a
b
Descriptors Symbols
Code words
EncodedDataHuffman
StatisticalModel
HuffmanAdapter
HuffmanEncoder
HuffmanCode Table
S1
S2
![Page 24: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/24.jpg)
Huffman Decoder Scheme
HuffmanStatistical Model
HuffmanDecoder
HuffmanCode Table
Encoded data
Symbols
Code words
Huffman entropycode table
Descriptors
![Page 25: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/25.jpg)
Arithmetic Coding
• One pass adaptive binary coder.• Achieves about 10% better compression.• More complicated then Huffman.• Option to transcoding between the two.• Almost not in use in JPEG (used in JBIG)• IBM Patent.
![Page 26: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/26.jpg)
Lossless Mode
• Based on DPCM only (without DCT and Q)• Poor compression relative to Lossy mode
(2:1 Vs. 20:1 for color average image)• (Almost) Not in use
Changed Since1997: JPEG-LS
![Page 27: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/27.jpg)
Progressive Mode• Allows the user to preview a rough version
of the image• Two or more passes through data• Approximation of entire image coded first• Finer details are coded with each
succeeding scan • Decoder follows same order in decoding• Identical compression and quality
(sometimes even better)
![Page 28: JPEG: An Image Compression System - University of Haifacs.haifa.ac.il/~nimrod/Compression/JPEG/J3sys2005.pdf · of the image • Two or more passes through data • Approximation](https://reader030.vdocument.in/reader030/viewer/2022041100/5ed69774843ed9152066ab9c/html5/thumbnails/28.jpg)
The complete Scheme (Lossy)
JPEG Base line