0% found this document useful (0 votes)
43 views36 pages

Image Compression Standards

The document discusses the JPEG image compression standard. It was developed by the Joint Photographic Experts Group and formally accepted in 1992. JPEG uses lossy compression and chroma subsampling. The major steps in JPEG compression are discrete cosine transform, quantization, differential pulse code modulation, run-length coding, and entropy coding. These steps transform the image into frequency coefficients, quantize values, and encode data to reduce file size.

Uploaded by

Farzana Khanam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views36 pages

Image Compression Standards

The document discusses the JPEG image compression standard. It was developed by the Joint Photographic Experts Group and formally accepted in 1992. JPEG uses lossy compression and chroma subsampling. The major steps in JPEG compression are discrete cosine transform, quantization, differential pulse code modulation, run-length coding, and entropy coding. These steps transform the image into frequency coefficients, quantize values, and encode data to reduce file size.

Uploaded by

Farzana Khanam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Image Compression

Standards

CS4185/5185; Semester A, 2009/2010; Leung


Outline
• JPEG
– Chroma Subsampling
– Major Steps in JPEG Image Compression
• Discrete Cosine Transform (DCT) / IDCT
• Quantization / Dequantization
• Differential Pulse Code Modulation (DPCM)
• Entropy Coding of DC Coefficients
• Run-Length Coding (RLC)
• Entropy Coding of AC Coefficients

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 2


JPEG
• Developed by Joint Photographic Experts Group
• Formally accepted as an international standard in 1992
• Lossy compression
• Chroma subsampling is used in JPEG: The luminance
has larger spatial resolution than each of the
chrominance components. For example, U and V are
each 128128 when Y is 256256.

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 3


Chroma Subsampling
• Before chroma subsampling

Y’ Cb Cr
• After chroma subsampling

Y’ Cb Cr
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 4
Chroma Subsampling (2)
• Since humans see color with much less spatial resolution
than they see black and white, it makes sense to
“decimate” the chrominance signal.

Pixel with only Y value


Pixel with only Cb and Cr values
Pixel with Y, Cb, and Cr values

Scheme 4:2:0 along with other schemes is


commonly used in JPEG and MPEG
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 5
Major Steps in JPEG Image
Compression
1. Discrete Cosine Transform (DCT) / IDCT
2. Quantization / Dequantization
3. Differential Pulse Code Modulation
(DPCM)
4. Entropy Coding of DC Coefficients
5. Run-Length Coding (RLC)
6. Entropy Coding of AC Coefficients

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 6


JPEG Encoder

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 7


JPEG Decoder
~ ~ ~

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 8


2D Discrete Cosine Transform
• 2D Discrete Cosine Transform
C (u )C (v) 7 7 (2i  1)u (2 j  1)v  22 if   0
F (u , v)   cos cos f (i, j ) C ( )  
4 i 0 j 0 16 16  1 otherwise

• 2D Inverse Discrete Cosine Transform


~ 7 7
C (u )C (v) (2i  1)u (2 j  1)v  22 if   0
f (i, j )   cos cos F (u , v) C ( )  
u 0 v 0 4 16 16  1 otherwise
~ ~
f (0,0)    f (7,0) F(0,0)    F(7,0) f (0,0)    f (7,0)
        
         
    ~  ~
f   f (i, j)   F  F(u,v)   f   f (i, j)  
     
                 
f (0,7)    f (7,7) F(0,7)    F(7,7) ~
f (0,7)
~
   f (7,7)
DCT IDCT
Spatial domain (Spatial) Frequency domain Spatial domain
F(0,0): DC Component
F(u,v), u0 or v0: AC Components
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 9
2D Discrete Cosine Transform:
Getting the transform coefficients

1594 67 127 2 59  15  55  6
 136  6  95 6 10 8 1 1
 
 97  32 103  27  48 4 76 8
 
  43 8 7 8 16  3  14  3
=  42

7 11 2 12 7  94 10 

  82  3 73 4 23  10  32 3 
 11 5  47 18  26 16  67 11 
 
88  79 1  37 6  100  2 153 0 

image Transform coefficients


block
Each basis function is
an 88 matrix.

Altogether there are


DCT basis functions 88 basis functions
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 10
2D Discrete Cosine Transform:
Separable Basis    
    T
 
  0
T
    1
T
    2
T
    3
T
    4
T
    5
T
    6
T
    7
T
  =  2 
4
  
  
 
 0 
  

 
 

 1 
  

  

=   
 
  
 = -48
T
 2  2
 4 
    
  

  
 
 3 
1594 67 127 2 59 15 55 6
136 6 95 6 10 8 1 1
   
 97 32 103 27 48 4 76 8 

43 8 

  

 42 7

82 3
7 8
11
73 4
2
16 3 14 3
12 7 94 10

23 10 32 3 
=
   11 5 47 18 26 16 67 11
 4  
 79 1 37 6

100 2 153 0 
  

   
T
  
        
    
0

   1
T
     
     | | | | | | | | 
 5        
T
2
 | | | | | | | | 
   
              
T

 3

   
T
    0 1 2 3 4 5 6 7

4
  | | | | | | | | 
           | | | | | | | | 
T
5
      
    
T


         
 6 
6

    
   
T

  
7

   With this property, number


 
 7  of multiplications is reduced
  
from 8888 to 88(8+8)
CS4185/5185; Semester A, 2009/2010; Leung DCT basis functionsImage Compression Standards 11
Why DCT ?
• Useful image contents change relatively slowly across
the image, i.e., it is unusual for intensity values to vary
widely several times in a small area, for example,
within an 88 image block.
– much of the information in an image is repeated, hence
“spatial redundancy”.
• Psychophysical experiments suggest that humans are
much less likely to notice the loss of very high spatial
frequency components than the loss of lower
frequency components.
– the spatial redundancy can be reduced by largely reducing the
high spatial frequency contents.

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 12


DCT on image blocks
• Each image is divided into 88 blocks. The 2D DCT is applied to
each image block f(i, j) after subtracting each element by 128. The
output corresponds to the DCT coefficients F(u,v) for each block.

f (0,0)    f (7,0) F(0,0)    F(7,0)


      
     
 
f   f (i, j)   F  F(u,v)  
F(0,0): DC Component
    F(u,v), u0 or v0: AC Components
     
     
f (0,7)    f (7,7) F(0,7)    F(7,7)
Spatial domain (Spatial) Frequency domain

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 13


DCT on image blocks (2)

• Using blocks, however,


has the effect of isolating
each block from its
neighboring context. This
is why JPEG images look
choppy (“blocky") when a
high compression ratio is
specified by the user.

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 14


Quantization

• F(u,v) represents a DCT coefficient, Q(u,v) is a


^
“quantization matrix” entry, and F(u,v) represents the
quantized DCT coefficients which JPEG will use in the
succeeding entropy coding.
– The quantization step is the main source for loss in JPEG
compression.
– The entries of Q(u,v) tend to have larger values towards the
lower right corner. This aims to introduce more loss at the higher
spatial frequencies

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 15


Quantization (2)
• The following tables show the default Q(u,v) values
obtained from psychophysical studies with the goal of
maximizing the compression ratio while minimizing
perceptual losses in JPEG images.

Luminance Quantization Table Chrominance Quantization Table


• Visual acuity (accuracy in distinguishing closely spaced
lines) is much greater for gray (“black and white”) than for
color.
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 16
DCT and Quantization
JPEG Encoder

• In the next few slides,


we will show examples
to study the DCT,
Quantization, IDCT
and Dequantization
~ ~ ~
JPEG Decoder

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 17


Example 1: DCT, Quantization, Dequantization, IDCT
Error

Smooth block

DCT Quantization

Note that each element in the block is first subtracted by 128 The value 128 is added back to
before taking the 2D DCT. The idea is to make it zero-mean. each element after the 2D IDCT

IDCT
Dequantization
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 18
Example 2: DCT, Quantization, Dequantization, IDCT
Error

Textured block

DCT Quantization

IDCT
Dequantization

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 19


Comparison of the two examples
• The error is larger for the textured block so more loss is introduced if the
image has quickly changing details
Smooth block Textured block

DCT DCT
Error Error

Quantization Quantization

Dequantization Dequantization

IDCT IDCT
- + + -
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 20
Coding of DC Coefficients

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 21


DPCM-coded DC coefficients
• DPCM: Differential Pulse Code Modulation
^
• Used to code DC coefficients, .i.e., the value F(0,0) for
each block

block block block block
1 2 3 4
block
5 Image

Quantized Quantized Quantized Quantized Quantized


DCT DCT DCT DCT DCT
coefficients coefficients coefficients coefficients coefficients
of block 1 of block 2 of block 3 of block 4 of block 5
• DC coefficient is unlikely to

150 155 149 152 144  change drastically within a


short distance so we expect
DPCM codes to have small
DC coefficients magnitude and variance
DPCM 150 5 -6 3 -8 
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 22
Entropy Coding of DPCM-coded
DC Coefficients
• The baseline entropy coding method uses Huffman
coding to encode DPCM-coded DC coefficients
• The idea is to replace a number by a pair of symbols
(SIZE,AMPLITUDE) where SIZE specifies how many bits are
needed for representing the number and AMPLITUDE
contains the actual bits SIZE AMPLITUDE

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 23


Entropy Coding of DPCM-coded
DC Coefficients (2)
• Represent a number by a pair (SIZE,AMPLITUDE):
– convert the absolute value of the number into binary
representation to determine SIZE.
– AMPLITUDE is equivalent to the binary representation for positive
numbers. For negative numbers, it is the one’s complement of
the binary representation.
– SIZE is Huffman coded but AMPLITUDE is not Huffman coded
because value can change widely
• For DPCM-coded DC coefficients: 150 5 -6 3 -8
150(10)=10010110(2) 5(10)=101(2) 6(10)=110(2) 3(10)=11(2) 8(10)=1000(2)
150(8,10010110) 5(3,101) -6(3,001) 3(2,11) -8(4,0111)

(SIZE,AMPLITUDE): (8,10010110) (3,101) (3,001) (2,11) (4,0111)

Huffman coded
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 24
Entropy Coding of DPCM-coded
DC Coefficients (3)
(SIZE,AMPLITUDE): (8,10010110) (3,101) (3,001) (2,11) (4,0111)

SIZE

150(8,10010110) 5(3,101) -6(3,001) 3(2,11) -8(4,0111)


(111110,10010110) (100,101) (100,001) (011,11) (101,0111)
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 25
Coding of AC Coefficients

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 26


Zig Zag Scan
• To make it most likely to hit a long run of zeros: a zig-zag
^
scan is used to turn the 88 matrix F(u,v) into a vector
with 64 elements

Quantized DCT coefficients

Zig Zag Scan


32 6 -1 -1 0 -1 0 0 0 -1 0 0 1 0 0 0 
Vector with 64 elements

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 27


RLC
• RLC: Run-Length Coding
• Used to code AC coefficients, .i.e., the values F(u,v)
^

where u≠0 or v≠0


• RLC is effective if the information source has the
property that symbols tend to form continuous groups. In
this case, the quantized DCT coefficients tend to form
continuous groups of 0s
Quantized DCT coefficients

Zig Zag Scan


32 6 -1 -1 0 -1 0 0 0 -1 0 0 1 0 0 0 
Vector with 64 elements

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 28


Entropy Coding of RLC-Coded
AC Coefficients
• Actual RLC step: Replace the 64-element vector with
several pairs of numbers
(RUNLENGTH1,VALUE1)(RUNLENGTH2,VALUE2)(RUNLENGTH3,VALUE3) 
• where RUNLENGTH is the number of zeros to skip and VALUE is
the next non-zero value.
• For example,

32 6 -1 -1 0 -1 0 0 0 -1 0 0 1 0 0 0 
No need to consider RLC
the DC coefficient

(0,6) (0,-1) (0,-1) (1,-1) (3,-1) (2,1) (0,0) (RUNLENGTH,VALUE)


End of block
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 29
Entropy Coding of RLC-Coded
AC Coefficients (2)
• Now we replace VALUE by a pair of symbols
(SIZE,AMPLITUDE) where SIZE specifies how many bits
are needed for representing the number and AMPLITUDE
contains the actual bits (similar to the case for entropy
coding of DC coefficients)
SIZE AMPLITUDE
VALUE  SIZE,AMPLITUDE

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 30


Entropy Coding of RLC-Coded
AC Coefficients (3)
• Recap of the steps for coding AC coefficients:
1. Replace the 64-element vector with several pairs of numbers
(RUNLENGTH1,VALUE1)(RUNLENGTH2,VALUE2)(RUNLENGTH3,VALUE3)
2. Replace VALUE by a pair of symbols (SIZE,AMPLITUDE)
(RUNLENGTH,VALUE)  (RUNLENGTH,SIZE,AMPLITUDE)

Huffman coded Not Huffman coded

(0,6) (0,-1) (0,-1) (1,-1) (3,-1) (2,1) (0,0)

 (0,3,110) (0,1,0) (0,1,0) (1,1,0) (3,1,0) (2,1,1) (0,0)

Huffman coded

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 31


Entropy Coding of RLC-Coded
AC Coefficients (4) (0,6)
 (0,3,110)
 (100,110)

(0,-1)
 (0,1,0)
 (00,0)

(0,-1)
 (0,1,0)
 (00,0)

(1,-1)
 (1,1,0)
 (1100,0)

(3,-1)
 (3,1,0)
 (111010,0)

(2,1)
 (2,1,1)
 (11100,1)

(0,0)
 1010
CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 32
Entropy Coding of RLC-Coded
AC Coefficients (5)

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 33


The Whole Picture

JPEG Encoder

~ ~ ~
JPEG
bitstream

JPEG Decoder

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 34


Summary
• JPEG
– Chroma Subsampling
– Major Steps in JPEG Image Compression
• Discrete Cosine Transform (DCT) / IDCT
• Quantization / Dequantization
• Differential Pulse Code Modulation (DPCM)
• Entropy Coding of DC Coefficients
• Run-Length Coding (RLC)
• Entropy Coding of AC Coefficients

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 35


References
1. Ze-Nian Li and Mark S. Drew : Fundamentals
of Multimedia, (Prentice Hall, 2004, ISBN:
0130618721)
2. K.R. Rao and J.J. Hwang : Techniques &
Standards for Image, Video & Audio Coding
(Prentice Hall, 1996, ISBN: 0133099075)

CS4185/5185; Semester A, 2009/2010; Leung Image Compression Standards 36

You might also like