COL783: Digital Image Processingpkalra/col783/session-17.pdf · 2021. 4. 22. · Image Compression...

Post on 11-Aug-2021

18 views 0 download

Transcript of COL783: Digital Image Processingpkalra/col783/session-17.pdf · 2021. 4. 22. · Image Compression...

COL783: Digital Image ProcessingPremKalra

pkalra@cse.iitd.ac.inh4p://www.cse.iitd.ac.in/~pkalra/col783

DepartmentofComputerScienceandEngineering

IndianInsEtuteofTechnologyDelhi

RecapSome definitions

•  Compression ratio •  Fidelity criteria

Data Redundancy •  Coding •  Interpixel •  Psychovisual

Compression techniques •  Loss-less and Lossy •  Symmetric and Asymmetric

Variable length coding •  Huffman Coding •  Information theoretic analysis

Entropy

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionKraft’s inequality

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionLower Bound

Shannon’sCodingTheorem

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionLower Bound

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompression

Variants of Huffman Coding •  Higher order estimate of entropy •  Truncated Huffman Coding •  Dynamic or Adaptive Huffman Coding

Efficiency of Huffman Coding

H(z)/L(z)

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionArithmetic Coding BasicIdea:a)  LikeHuffmancodingrequirespriorknowledgeofprobabiliEesb)  UnlikeHuffmancoding,whichassignsvariablelengthcodestosymbolsarithmeEc

codingassignscodestoavariablegroupofsymbolsi.e.themessage.c)  Thereisnoone-to-onecorrespondencebetweenthesymbolandits

correspondingcodeword.d)  Thecodeworditselfdefinesarealnumberwithinthehalf-openinterval[0,1)and

asmoresymbolsareadded,theintervalisdividedintosmallerandsmallersubintervals,basedontheprobabiliEesoftheaddedsymbols.

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionArithmetic Coding

Endofmessageorlengthofmessageisknown.Source:DigitalImageProcessing,GonzalezandWoods.Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionArithmetic Coding

Finalcode068

Source:DigitalImageProcessing,GonzalezandWoods.Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionArithmetic Decoding Followsencodingprocedure

Code068maybeconvertedtotherealnumber0.068,whichfallsinthefirstsub-interval[0,0.2)thereforefirstsymbolisa1,andsoon.

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods

•  CompressingmulEplestringscanbemoreefficientthancompressingsinglesymbolsonly(e.g.Huffmanencoding).

•  StringsofsymbolsareaddedtoadicEonary.Lateroccurrencesarereferenced.

•  StaEcdicEonary:EntriesarepredefinedandconstantaccordingtotheapplicaEonofthetext

•  AdapEvedicEonary:Entriesaretakenfromthetextitselfandcreatedon-the-fly

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZ77 ByLempelandZivin1977aboutlosslesscompressionwithanadapEvedicEonary.•  Runsthroughthetextinaslidingwindow•  Twobuffersareused-search(history)bufferandalookaheadbuffer.•  ThesearchbufferisusedasdicEonary•  Sizesofthesebuffersareparametersofthedesign

Source:h4p://jens.jm-s.de/comp/LZ77-JensMueller.pdfDigital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZ77

Look-ahead

Search

Source:h4p://jens.jm-s.de/comp/LZ77-JensMueller.pdf

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZ77

Decoding

Source:h4p://jens.jm-s.de/comp/LZ77-JensMueller.pdf

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZW ExtendedbyWelch(Lempel,ZivandWelch)

Thiscodingschemehasbeenadoptedinavarietyofimagingfileformats,suchasthegraphicinterchangeformat(GIF),taggedimagefileformat(TIFF)andtheportabledocumentformat(PDF).

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZW ExtendedbyWelch(Lempel,ZivandWelch)•  UnlikeHuffmancodingandarithmeEccoding,thiscodingschemedoes

notrequireaprioriknowledgeoftheprobabiliEesofthesourcesymbols.

•  Thecodingisbasedona“dicEonary”or“codebook”containingthesourcesymbolstobeencoded.ThecodingstartswithaniniEaldicEonary,whichisenlargedwiththearrivalofnewsymbolsequences.

•  ThereisnoneedtotransmitthedicEonaryfromtheencodertothedecoder.ThedecoderbuildsanidenEcaldicEonaryduringthedecodingprocess

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZW ExtendedbyWelch(Lempel,ZivandWelch)Example: 32 32 34 32 34 32 32 33 32 32 32 34

ConsideradicEonaryofsize256locaEons(numbered0to255)thatcontainsentriescorrespondingtoeachpixelintensityvalueintherange0-255.

Source:h4ps://nptel.ac.in/courses/117/105/117105083/#Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionDictionary based methods: LZW ExtendedbyWelch(Lempel,ZivandWelch)

Source:h4ps://nptel.ac.in/courses/117/105/117105083/#Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionRun Length Coding Run: a string of the same symbol Example

input: AAABBCCCCCCCCCAA output: A3B2C9A2

compression ratio = 16/8 = 2

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionPredictive Coding Basic premise: Current pixel is similar to the previous pixel (coherence)

Differential Coding

d(x,y) = I(x,y) – I(x-1,y)

d(x,y) prediction error which is to be encoded.

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompression

Compression

Predictive Coding

Source:DigitalImageProcessing,GonzalezandWoods.Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionPredictive Coding Decompression

Source:DigitalImageProcessing,GonzalezandWoods.Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783

ImageCompressionPredictive Coding

Digital Image Processing http://www.cse.iitd.ac.in/~pkalra/col783