Top Banner
It d ti t JPEG Introduction to JPEG JPEG JPEG: Joint Photographic Expert Group work under 3 standards: ISO, CCITT, IEC Purpose Purpose: image compression Compression accuracy Works on full-color or gray-scale image
28

It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Aug 13, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

I t d ti t JPEGIntroduction to JPEG

JPEGJPEG: Joint Photographic Expert Groupwork under 3 standards: ISO, CCITT, IEC

PurposePurpose: image compression Compression accuracy

Works on full-color or gray-scale image

Page 2: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

C lColorGrayscaleGrayscale image:GrayscaleGrayscale image: Value 0-255

RGB colorRGB color model:RGB colorRGB color model:Three components

R 0-255G 0-255B 0-255

File size of grayscale image is 75% of l ia color image

Page 3: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

H d JPEG k?How does JPEG work?

Color transformRGBSource image data

DCT

Quantization

Huffman JPEGCompressed

image data

Page 4: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

St 1 l t f tiStep1: color transformationRGB

Color transform 1 Lossless

RGB

YCbCr

DCT

Quantization

Huffman

Page 5: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

YCbC l d lYCbCr color modelYCbCr model exploits the property of the visual system that moreYCbCr model exploits the property of the visual system that more sensitive to changes luminance than to change hue.Y is the luminance. Cb and Cr are the chromaticity. O l Y t ill h bl k/ hit TVOnly Y component will show black/white TVMore bits are used for Y, and less bits for Cb or Cr.

Y = 0 3R + 0 6G + 0 1BY 0.3R + 0.6G + 0.1BCb = -0.2R - 0.3G + 0.5B + 128Cr = 0.5R - 0.4G - 0.1B + 128

RGB YCbCr

R = Y +1.4(Cr–128)G = Y - 0.3 (Cb–128) - 0.7(Cr-128)B = Y + 1 8 (Cb 128)

YCbCr RGBB = Y + 1.8 (Cb–128)

Page 6: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

RGB iRGB image

Page 7: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

YCbC iYCbCr image

Page 8: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

St 1 l t f tiStep1: color transformation

This step is optionalNo for grayscale image

From RGB to luminance/chrominance color modelFrom RGB to luminance/chrominance color modelEnable to compress more in chrominance component

Y

ColorTransform

JPEG compressorY

CbRGB JPEG compressor JPEG streamTransform

Cr JPEG compressor

Page 9: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Step 2 : Discrete Cosine Transform

Color transformRGB

DCT 2 Lossless

Quantization

Huffman JPEG

Page 10: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Di t C i T fDiscrete Cosine Transform

Purpose:Convert from spatial domain to frequency domainBe able to separate what the eye can see from imperceptible

11D DCTD DCT:11D DCTD DCT:

250 100

1000

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0 -100

Page 11: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

C i b i f tiCosine basis functions

u=0 u=1 u=2 u=3

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

Page 12: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

C i b i f tii b i f tiCosine basis functionssine basis functionsA t f f i th lA set of waveforms is orthogonalOrthogonal waveforms are independentA set of waveforms scaled and addedA set of waveforms scaled and added together can represent any eight samples

DC coefficient (u=0)Scales the constant basis function (average value)( g )

AC coefficientsThe higher the frequency the less important the

ffi i tcoefficient

Page 13: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

1D DCT1D DCTFDCT

8 samples 8 DCT coefficients

IDCT

Page 14: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

B i f ti f 2D DCTBasis functions of 2D DCT

A set of 64 2D basis functions:

M lti l h i t llMultiply horizontally oriented set by vertically oriented set

Block 8x8 samples is d b 64represented by 64

coefficients

Page 15: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

2D DCT2D DCT

Page 16: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

S i DCT ffi i tScanning DCT coefficientsTh i ttThe zigzag pattern orders the basis f ti f th lfunctions from the low to high spatial f ifrequencies

One constant basis f ti DC

DC coefficientfunction one DCcoefficientRest are AC coefficients AC coefficientRest are AC coefficients

Page 17: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

2D Di t C i T f2D Discrete Cosine Transform

The forward equation is

)12(cos)12(cos)()()()(7 7 yvxuyxsvCuCvuS

16

cos16

cos),(22

),(0 0

yxsvuSx y

The inverse equation is

16

)12(cos16

)12(cos),(2

)(2

)(),(7

0

7

0

yvxuvuSuCvCyxsu v

th iuif

uC0

1)( 2

1

otherwise1

Page 18: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

DCT ffi i tDCT coefficientsFDCT

Block 8x8 samples

8x8 DCT coefficients

IDCT

Distribution of the DCT coefficients within the block is non-linear.Coefficients at the lower frequencies have large magnitude, while it has less magnitude at the higher magnitude.magnitude.A large number of bits are assigned to values corresponding to lower frequencies, while fewer bits to h h fhigher frequencies

Page 19: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

St 3 ti tiStep 3: quantization

Color transformRGB

DCT

Quantization 3 Lossy

Huffman JPEG

Page 20: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Q ti tiQuantization

Purpose:Eliminate less significant informationL f ffi i h llLow frequency coefficients have smaller quantization steps, therefore more accurately encodedLuminance data is quantized more accurately than the chromatic data

How?How?Each coefficient in each block is divided by separate quantization coefficientRound the result to integer

Page 21: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Q ti tiQuantizationG(u v) G’(u v)G(u, v) G (u, v)

),('),(),( vuG

vuqvuGround

q(u, v)

Page 22: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

Q ti tiQuantizationDCT coefficients

QuantizatedQuantizated

DCT coefficients

Q table

Page 23: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

St 4 H ff diStep 4: Huffman coding

Color transformRGB

DCT

Quantization

Huffman JPEG 4 Lossless

Page 24: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

C di

DC ffi i

Coding

DC coefficientEncode the difference between the value and already coded valuecoded value

Sample

Difference

AC coefficient

Previous sample

AC coefficientHuffman code: less bits for common values

Page 25: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

JPEG d dJPEG decoder

Color transformRGBSource image data

DCT

Dequantization

Huffman JPEGCompressed

image data

Page 26: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

MPEGMPEG

Page 27: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

MPEGMPEG

Page 28: It d ti t JPEGIntroduction to JPEG - BGUdip111/wiki.files/JPEG.pdf · DCT ffi i tDCT coefficients FDCT Block 8x8 samples 8x8 DCT coefficients IDCT Distribution of the DCT coefficients

MPEG iMPEG compression