2. The JPEG Standard
• Developed by Joint Photographic Experts group
and accepted as international standard 1992
• Lossy image compression method which uses
Discrete cosine Transform.
• In 2D DCT applied on JPEG produce to yield a
frequency response which is a function F(u,v) in
the spatial frequency domain.
3. Observations
• Useful image contents change relatively slowly
across the image, ie information in an image is
repeated.
• Psychophysical experiments suggest that humans
less likely to notice of very high spatial frequency.
• Visual acuity is much greater for gray scale than
for color.
4. STEPS
• Transform RGB to YIQ or YUV
• Subsample Color
• Perform DCT on image blocks 8X8 blocks
• Quantization
• RLE on AC coefficients
• DPCM on DC coefficients
• Entropy Coding
Huffman coding of DC coefficients
Huffman coding of AC coefficients
6. Transform RGB to YIQ or YUV
From RGB to YIQ conversion Matrix
Sample Conversion
RGB (255, 255, 255)
YIQ = (1.000, 0.000, 0.000);
The Y component represents the luma information, and is
the only component used by black-and-white television
receivers. I and Q represent the chrominance information.
7. Subsample Color
• Chroma subsampling is the practice of encoding
images by implementing less resolution for
chroma information than for luma information,
taking advantage of the human visual system's
lower acuity for color differences than for
luminance.
• 4:2:0 is used in JPEG conversion
8. DCT on image blocks 8X8 blocks
• Each image f(i,j) is divided into 8X8 blocks
• Perform 2D DCT operation on 8X8 image blocks.
• In each block first value is DC components and rest
of the values is the AC components.
9. Quantization
• The quantization step in JPEG is aimed at reducing
the total number of bits needed for a compressed
image.
• It consists of simply dividing each entry in the
frequency space block by an integer, then
rounding. F(u, v) represents a DCT coefficient,
Q(u, v) is a quantization matrix entry.
10. • Different tables are used for luminance and
chrominance images, respectively.
• Y channel uses the luminance table and I,Q
channels uses the chrominance table as
denominator in quantization equation, i.e. Q(u, v).
• The quantization step is the main source for loss in
JPEG compression.
11. RLE on AC coefficients
• The Run Length Encoding done on the AC
coefficients using a Zigzag manners in image block
of 8X8 for achieving compression.
• For each run of zeros in the AC coefficients
(Run length of zero , Next non-zero value)
For examples let assume that values after quantization is
(50,8,0,0,3,5,6,0,0,1,0,0,0,-1…………)
50 is DC coefficient
After RLE on AC coefficients
((0,8) (2,3) (0,5) (0,6) (2,1) (3,-1)…….. (0,0))
(0,0) represents the end of the image block
12. DPCM on DC coefficients
• Only one DC coefficients for the different 8X8
image n blocks taken for the Differential Pulse
Code Modulation.
• The differential coding (difference from previous
value) method is done to compress DC coefficients
in the entire image.
For examples let assume n = 6 and sample values after quantization is
Block -1 (50,8,0,0,3,5,6,0,0,1,0,0,0,-1…………)
Block -2 (58,5,0,-2,3,0,6,0,0,1,0,0,0,-1…………)
Block -3 (54,7,0,0,3,5,6,0,0,1,0,0,0,-1…………)
Block -4 (59,5,-1,0,13,5,0,0,0,1,0,0,0,-1…………)
Block -5 (59,7,0,0,3,5,0,0,0,1,0,0,0,-1…………)
Block –6 (57,9,0,0,3,1,6,0,0,1,0,0,0,-1…………)
After DCPM on DC coefficients of 6 blocks of 8X8 images (50, 8, -4, 5, 0, -2)
13. Entropy Coding
• The DC and AC coefficients finally undergo an
entropy coding step.
Huffman coding of DC coefficients
• Each DPCM-coded DC coefficient is represented
by a pair of symbols (SIZE, AMPLITUDE), where
SIZE indicates how many bits are needed for
representing the coefficient and AMPLITUDE
contains the actual bits.
14. • DCPM on DC coefficients of 6 blocks of 8X8 images
values (50, 8, -4, 5, 0, -2) is coded.
• The one's complement scheme is used for negative
numbers in the AMPLITUDE.
(7, 0110010) (5, 01000) (4, 1011) (4, 0101)
(1,0) (3, 101)
• In the JPEG implementation, SIZE is Huffman
coded and is hence a variable-length code.
• On the other hand, AMPLITUDE is not Huffman
coded. Since its value can change widely, Huffman
coding has no appreciable benefit.
15. Huffman coding of AC coefficients
• The AC coefficients are run length coded and are
represented by pairs of numbers (RUN LENGTH,
VALUE).
• In an actual JPEG implementation, VALUE is
further represented by SIZE and AMPLITUDE ,as
for the DCs.
• To save bits, RUNLENGTH and SIZE are allocated
only 4 bits each and squeezed into a single byte
16. Symbol 1: (RUN LENGTH, SIZE)
Symbol 2: (AMPLITUDE)
• The 4-bit RUNLENGTH can represent only zero-
runs of length 0 to 15.
• Occasionally, the zero-run length exceeds 15; then a
special extension code, (15,0), is used for Symbol 1.
• In the worst case, three consecutive (15, 0)
extensions are needed before a normal terminating
Symbol 1, whose RUNLENGTH will then complete
the actual run length. As in DC, Symbol 1 is Huffman
coded, whereas Symbol 2 is not.
17. References
• ‘Fundamentals of Multimedia’ by Ze-Nian Li and Mark
S. Drew, Pearson Education International.
• ‘Data compression’ by David Salomon, Springer
• Official Joint Photographic Experts Group site
• JPEG Standard @ W3.org
Any comments, corrections and questions please mail to
manish.cs@adishankara.ac.in
manishti2004@gmail.com