0% found this document useful (0 votes)
31 views

Jpeg

JPEG is a lossy image compression standard that uses discrete cosine transform (DCT) to transform image blocks into frequency domains. It quantizes and encodes the DCT coefficients. The image is divided into 8x8 blocks and each block is transformed using 2D DCT. The DCT coefficients are then quantized and entropy encoded. During decoding, the quantized DCT coefficients are dequantized and inverse DCT is applied to reconstruct the image blocks. JPEG uses chrominance subsampling and different quantization tables for luminance and chrominance to achieve higher compression for color images.

Uploaded by

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

Jpeg

JPEG is a lossy image compression standard that uses discrete cosine transform (DCT) to transform image blocks into frequency domains. It quantizes and encodes the DCT coefficients. The image is divided into 8x8 blocks and each block is transformed using 2D DCT. The DCT coefficients are then quantized and entropy encoded. During decoding, the quantized DCT coefficients are dequantized and inverse DCT is applied to reconstruct the image blocks. JPEG uses chrominance subsampling and different quantization tables for luminance and chrominance to achieve higher compression for color images.

Uploaded by

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

Image Compression

JPEG
JPEG
• JPEG = Joint Photographic Experts Group

• Lossy coding of continuous tone still images (color and


grayscale)
• Based on Discrete Cosine Transform (DCT):
0) Image is divided into block NN
1) The blocks are transformed with 2-D DCT
2) DCT coefficients are quantized
3) The quantized coefficients are encoded
JPEG: Encoding and Decoding
Source FDCT Q u an tizer E n tro p y Compressed
Image Data E n co d er Image Data

8x8 blocks
Table Table
Specifications Specifications

Compressed Entropy
D equantizer IDCT Reconstructed
Image Data Decoder Image Data

Table Table
Specifications Specifications
Divide image into NN blocks

Input image 8x8 block


2-D DCT basis functions: N=8
Low High
Low Low

8x8 block

High High
Low High
2-D Transform Coding

y00 + y23
y01 y10 y12

...
1-D DCT basis functions: N=8
u=0 u=1 u=2 u=3
1.0 1.0 1.0 1.0

0.5 0.5 0.5 0.5

0 0 0 0

-0.5 -0.5 -0.5 -0.5

-1.0 -1.0 -1.0 -1.0

u=4 u=5 u=6 u=7


1.0 1.0 1.0 1.0

0.5 0.5 0.5 0.5

0 0 0 0

-0.5 -0.5 -0.5 -0.5

-1.0 -1.0 -1.0 -1.0

 1
N 1
 2 j  1k   N
for k  0
x j    k C k  cos  
 k   
k 0  2 N   2
 N
for k  1,2,..., N  1
Zig-zag ordering of DCT coefficients

DC: Direct current

AC: Alternating current

Converting a 2-D matrix into a 1-D array, so that the


frequency (horizontal and vertical) increases in this order
and the coefficents variance are decreasing in this order.
Example of DCT for image block

Matlab: y=dct(x)
Distribution of DCT coefficients

DC coefficient AC coefficient

DC: uniformly distributed


AC: distribution resembles Laplacian pdf
Bit allocation for DCT coefficients
• Lossy operation to reduce bit-rate
• Vector or Scalar Quantizer?
• Set of optimal scalar quantizers?
• Set of scalar quantizers with fixed quantization tables
Bit allocation for DCT coefficients
Minimize the total distortition D
N 2  2 bi 
D  min  hi i 2 
{bi }
 i 1 
See Lecture 10
N
subject to b
i 1
i B

here bi is number of bits for coefficient yi,


B is a given total number of bits,

hi 
1
12
 p ( x) dx
i
13 3
Optimal bit allocation for DCT coefficients
Solution of the optimization task with Lagrange multiplier
method:
B 1 i 1 2
hi
Bitrate: bi   log 2 2  log 2
N 2  2 H
Distortion: D  NH 2 2  B N
1N 1N
 N 1
2 N 1

where      k 
2
; H    hk 
 k 0   k 0 
Minimal distortion
Distortion: D  NH 2 2  B N
1N
 N 1
2
where      k 
2

 k 0 

Distortion D is minimal, if 2 is minimal.


Product of diagonal elements is greater than or equal
to the determinant of the (positive semidefinite) matrix.
Equality is attained iff the matrix is diagonal.
KLT provides minimum of 2 (and minimum of distortion D)
among other transforms!
Default quantization matrix Q

yyqq(k,l)=round[y(k,l)/Q(k,l)]
(k,l)=round[y(k,l)/Q(k,l)]

Examples: 236/16  15 Matlab: Qy=quant (y)


-22/11  -2
Quantization of DCT coefficients: Example

Ordered DCT coefficients: 15,0,-2,-1,-1,-1,0,0,-1,-1, 54{’0’}.


Dequantization

zz(k,l)=y
(k,l)=yqq(k,l)·Q(k,l)
(k,l)·Q(k,l)
Examples: 236/16  15
-22/11  -2

Matlab: z=dequant (Qy)


Original DCT block
Inverse DCT

See: x=idct(y)

Original block
Encoding of quantized DCT coefficients

• Ordered data: 15,0,-2,-1,-1,-1,0,0,-1,-1, 54{’0’}.


• Encoding:

DC: ?

AC: ?
Encoding of quantized DCT coefficients
• DC coefficient for the current block is predicted of
that of the previous block, and error is coded using
Huffman coding
• AC coefficients:
(a) Huffman code, arithmetic code for non-zeroes
(b) run-length encoding: (number of ’0’s, non-’0’-symbol)
Performance of JPEG algorithm

8 bpp 0.6 bpp

0.37 bpp 0.22 bpp


Compression of color images
RGB vs YCbCr
• 24 bits RGB representation: apply DCT for each
component separately
- does not make use of the correlation between color
components
- does not make use of lowe sensitivity of the human eyes
to chrominance component
• Convert RGB into a YCbCr representation: Y is luminance,
and Yb, Yc are chrominance
- Downsample the two chrominance components
RGB  YCbCr conversion

Luminance Y and two chrominances Cb and Cr


Chrominance subsampling

4:4:4 4:2:2 4:1:1 4:2:0


1:1 2:1 Hor 4:1 Hor 2:1 Hor&Vert

Y pixel Cb and Cr pixel


Quantization of DCT coefficients
For illuminance For chrominance
Performance of JPEG algorithm
• Grayscale 8 bits images:
- 0.5 bpp: excellent quality

• Color 24 bits images:


- 0.25-0.50 bpp: moderate to good
- 0.50-0.75 bpp: good to very good
- 0.75-1.00 bpp: excellent, sufficient for most applications
- 1.00-2.00 bpp: indistiniguishable from original
JPEG JPEG2000
For illuminance

JPEG: 0.25 bpp JPEG2000: 0.25 bpp

You might also like