Você está na página 1de 26

COMP319

Feb.28,2011

Introduction to Multimedia Computing p g


FionaYanLiu DepartmentofComputing TheHongKongPolytechnicUniversity

LearningOutputsofLecture05 Learning Outputs of Lecture 05

Losslesscompression L l i

Arithmeticencode Arithmeticdecode Arithmetic decode Definition Distortionmeasure


Lossy compression

MSE,SNR,PSNR Ratedistortiontheory R t di t ti th

Quantization Chapter7&Chapter8
Lecture06:Lossy Compression 2

Referencereading Reference reading

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding Transform coding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding Transform coding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

Quantization

Quantizationistheheartofanylosscompression Q i i i h h f l i scheme Reducethenumberofdistinctoutputvaluestoamuch Reduce the number of distinct output values to a much smallerset

Original:{0,1,2,64128192255} Original: { 0,1,2, 64 128 192 255 } Smallerset:{0, 64, 128, 192} Partitionthedomainofinputvaluesintoequally(unequally) spacedintervals Uniformscalarquantization U if l ti ti Nonuniform scalarquantization
Lecture06:Lossy Compression 5

Twodifferentformsofquantization q

ExampleofQuantization Example of Quantization

Originaldata O i i ld

Total64dataD: Total16valuesX: Total 16 values X: Probabilitiesofeachvaluef(x):

{d1,d2,d64 } {0,1,15} {0 1 15 }

CompresseddataY: {y1,y2,y3,y4} Thenumberofdistinctoutputvalueswillbedecreasedfrom 16to4 16 to 4 Howtochoosetheboundariesoftheintervalsandhowto choosethevaluesineachintervals


Lecture06:Lossy Compression 6

UniformScalarQuantization Uniform Scalar Quantization

Uniformscalarquantization U if l i i Partitionthedomainofinputvaluesintoequallyspaced intervals

Y={1.55.59.513.5}
01* 23/45* 67/ 89*1011/ 1213*1415

Exampleinimagecompression

DividetheRGBcubeintoequalslidesineachdimension R:3bit;G:3bit;B:2bit;
Lecture06:Lossy Compression 7

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding Transform coding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

NonuniformScalarQuantization Nonuniform Scalar Quantization

Nonuniformscalarquantization N if l ti ti

Partitionthedomainofinputvaluesintoequally(unequally)spaced intervals Concentratethebitstowhereismostneed LloydMaxquantization

TrytominimizeMSE y

CompresseddataY:

Thenumberofdistinctoutputvalueswillbedecreasedfrom16to4 Th b f di ti t t t l ill b d df 16 t 4 Howtochoosetheboundariesoftheintervalsandhowtochoose thevaluesineachintervals


Lecture06:Lossy Compression 9

{y1,y2,y3,y4}

LloydMaxQuantization Lloyd Max Quantization


Nonuniform scalarquantization N if l ti ti LloydMaxquantization


Begin ChooseinitiallevelsetY0 i =0; Repeat

ComputeBi using i =i +1 ComputerYi using


Until|Y Until | Yi Yi1 | < threshold |<threshold End

bj
yj

y j 1 y j 2
bj b j 1 bj

xf ( x)dx f ( x)dx

b j 1

Lecture06:Lossy Compression

10

ExampleofLloydMax Quantization

Uniformscalarquantization f l

Y={1.55.59.513.5}
01* 23/45* 67/ 89*1011/ 1213*1415
Y0 B0 Y1 B1 Y2 B2 0.67 2.3 0.9 2.7 4 7.85 1.5 3.5 4.5 7.75 5.5 7.5 9.5 11.5 11 12.5 11.7 14.8 13.25 14 13.5

0 1 2 / 3 4 5 6 7 / 8 9 10 11 12 13 / 14 15
Lecture06:Lossy Compression 11

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

12

TransformCoding Transform Coding

Exampleoftransformcoding E l ft f di

OriginaldataX:{100100100100100100100100} TransformcodingT:didii1andd0 =0; a s o cod g d d 1 a d d 0; TransformedvectorY:{1000000000} YistheresultofalineartransformToftheinputvectorXin suchawaythatthecomponentsofYaremuchlesscorrelated Ifmostinformationisaccuratelydescribedbythefirstfew componentsofatransformedvector,thentheremaining componentscanbecoarselyquantized components can be coarsely quantized Y:{100}

Transformcoding

Compressionschemefortransformcoding Compression scheme for transform coding

Lecture06:Lossy Compression

13

AnalogSignals Analog Signals

Signalscanbedecomposedintoasumofsinusoids Si l b d di f i id

Lecture06:Lossy Compression

14

ExampleofRecoveryofAnalog SignalsusingSumofSinusoids
Fundamental frequency 1 0.5 0 -0.5 -1 1 0.5 0 -0.5 -1 Current signal 1 0.5 0 -0.5 -1 Fundamental frequency 2 1 0 -1 -2 Current signal 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0.5*2*fundamental 0.5 2 1 0 0 -1 1 -0.5 -2 Complex signal 0.4 0.2 0 -0.2 02 -0.4 0.33*3*fundamental 2 1 0 -1 1 -2 Complex signal

Fundamental frequency 1 0.5 05 0 -0.5 -1 2 1 0 -1 -2

Current signal 1 0.5 05 0 -0.5 -1

Fundamental frequency 2 1 0 -1 -2

Current signal

0.25*4*fundamental 0.4 0.2 0 -0.2 -0.4 2 1 0 -1 -2

Complex signal 0.5

0.5*5*fundamental 2 1 0 0 -1 -0.5 -2

Complex signal

Lecture06:Lossy Compression

15

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding Transform coding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

16

1DDiscreteCosineTransform 1D Discrete Cosine Transform

Givenaninputfunctionf(i)overoneintegervariablei (apieceofa vector),the1DDCTtransformsitintoanewfunctionF(u),withinteger urunningoverthesamerangeasi.Thegeneraldefinitionofthe transformis: M 1 2 (2i 1)u C (u ) cos F (u ) f (i ) 2M M i 0

i;u=0,1M1; TheconstantsC(u)aredeterminedby

Lecture06:Lossy Compression

17

1DDCTandIDCTwith8numbers 1D DCT and IDCT with 8 numbers


Consideradatasequencewith8numbers 1DDCT

1DIDCT

TheconstantsC(u)aredeterminedby

Lecture06:Lossy Compression

18

Exampleof1DDCT Example of 1D DCT

DiscreteCosineTransform(DCT) Di t C i T f (DCT)

FistheresultofalineartransformToftheinputvectorfin suchawaythatthecomponentsofFaremuchlesscorrelated InputvectorX:

Exampleoftransformcoding

f 1DDCT

{100100100100100100100100} {100 100 100 100 100 100 100 100}

TransformcodingT:

TransformedvectorY:

{2820000000}
Lecture06:Lossy Compression 19

Exampleof1DInvertDCT Example of 1D Invert DCT


InputvectorX I t t X

f F

{100100100100100100100100} {2820000000}

TransformedvectorY: Transformed vector Y:

InvertDCT Invert DCT

OutputdataX p

{100100100100100100100100}

Lecture06:Lossy Compression

20

ExampleofCompressionScheme for1DDCT

OriginaldataX:{6036212117122138} Original data X: { 60 36 21 21 17 12 21 38 } TransformcodingT:1DDCT TransformedvectorY:8020322161


Recovered data of [80 0 0 0 0 0 0 0] 60 60 Recovered data of [80 20 0 0 0 0 0 0] 60 Recovered data of [80 20 32 0 0 0 0 0] 50 50 50

40

40

40

30

30

30

20

20

20

10

10

10

Recovered data of [80 20 32 2 0 0 0 0] 60

Recovered data of [80 20 32 2 16 0 0 0] 60

Recovered data of [80 20 32 2 16 1 0 0] 60

50

50

50

40

40

40

30

30

30

20

20

20

10

10

10

Lecture06:Lossy Compression

21

OutlineofLecture06 Outline of Lecture 06


Uniformscalequantization U if l ti ti Nonuniform scalequantization Transformcoding Transform coding 1DDiscreteCosineTransform


1DDCTandInvertDCT Compressionschemefor1DDCT 2DDCTandInvertDCT Compressionschemefor2DDCT Chapter8

2DDiscreteCosineTransform

Referencereading Reference reading

Lecture06:Lossy Compression

22

Definitionof2DDCT Definition of 2D DCT

Givenaninputfunctionf(i;j)overtwointegervariablesiandj,the Gi en an inp t f nction f(i j) o er t o integer ariables i and j the 2DDCTtransformsitintoanewfunctionF(u;v),withintegeruand vrunningoverthesamerangeasiandj.Thegeneraldefinitionof thetransformis: the transform is:

i;u=0,1M1; j;v 0, 1 N 1; j; v =0,1N1; TheconstantsC(u)andC(v)aredeterminedby

Lecture06:Lossy Compression

23

2DDCTandIDCTwith8*8Numbers 2D DCT and IDCT with 8*8 Numbers


Consideranimageof(8*8) 2DDCT

2DIDCT

Lecture06:Lossy Compression

24

Exampleof2DDCTwith8*8 Numbers
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7
8 1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

1 2

1 2

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

3 4 5 6 7 8 1 2 3 4 5 6 7 8

3 4 5 6 7 8

Lecture06:Lossy Compression

25

CompressionSchemeof2DDCT forImageData

Spatialfrequency

Indicateshowmanytimespixelvalueschangeacrossan imageblock i bl k Withameasureofhowmuchtheimagecontentschangein Wi h fh h h i h i correspondencetothenumberofcyclesofacosinewaveper block Use u Usefulimagecontentschangerelativelyslowly age co te ts c a ge e at ve y s o y DCTcanconcentratetheinformationwithinfirstseveral components
Lecture06:Lossy Compression 26

TheDCTformalizesspatialfrequency

Spatialredundancyoftheimage

Você também pode gostar