it d ti t jpegintroduction to jpeg - bgudip111/wiki.files/jpeg.pdf · dct ffi i tdct coefficients...

Post on 13-Aug-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

H d JPEG k?How does JPEG work?

Color transformRGBSource image data

DCT

Quantization

Huffman JPEGCompressed

image data

St 1 l t f tiStep1: color transformationRGB

Color transform 1 Lossless

RGB

YCbCr

DCT

Quantization

Huffman

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)

RGB iRGB image

YCbC iYCbCr image

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

Step 2 : Discrete Cosine Transform

Color transformRGB

DCT 2 Lossless

Quantization

Huffman JPEG

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

C i b i f tiCosine basis functions

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

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

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

1D DCT1D DCTFDCT

8 samples 8 DCT coefficients

IDCT

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

2D DCT2D DCT

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

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

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

St 3 ti tiStep 3: quantization

Color transformRGB

DCT

Quantization 3 Lossy

Huffman JPEG

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

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

),('),(),( vuG

vuqvuGround

q(u, v)

Q ti tiQuantizationDCT coefficients

QuantizatedQuantizated

DCT coefficients

Q table

St 4 H ff diStep 4: Huffman coding

Color transformRGB

DCT

Quantization

Huffman JPEG 4 Lossless

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

JPEG d dJPEG decoder

Color transformRGBSource image data

DCT

Dequantization

Huffman JPEGCompressed

image data

MPEGMPEG

MPEGMPEG

MPEG iMPEG compression

top related