Error-free compressio Useful i pplictio where o loss of iformtio is tolerble. This mybe due to ccurcy requiremets, legl requiremets, or less th perfect qulity of origil imge. Compressio c be chieved by removig codig d/or iterpixel redudcy. Typicl compressio rtios chievble by lossless techiques is from to. Vrible Legth Codig This is used to reduce codig redudcy. Codig redudcy is preset i y imge with o-uiform histogrm (i.e. whe ll the grylevels re ot eqully likely). Give imge with, sy 56 grylevels,,, =,,,55. This is our set of source symbols. { } { }, 55 For ech grylevel k, we eed its probbility p ( k ) i the imge. This my be obtied from the imge histogrm: p( ) =, = # pixels with vlue, = totl # pixels. k k k To ech grylevel k, we eed to ssig codeword ( biry strig). Suppose l k is the legth of codeword (= # bits required to represet k ) for symbol k. Totl umber of bits required to represet the imge is N N N k lk k = lk = lk p k ) = k= k= k= k ( L vg
Nturlly, we eed ecodig scheme with L vg s smll s possible. From Sho s theorem, we kow tht L H ( z). As metioed erlier, the Huffm procedure specifies code with vg H ( z) Lvg < H ( z) + Huffm Code The lgorithm is best illustrted by mes of exmple. Give source which geertes oe of six possible symbols A = {,,, 6 } with correspodig probbilities.,.4,.6,.,.4,.. { } Arrge the symbols i descedig order of their probbility of occurrece. Successively reduce the umber of source symbols by replcig the two symbols hvig lest probbility, with compoud symbol. This wy, the umber of source symbols is reduced by oe t ech stge. The compoud symbol is plced t pproprite loctio i the ext stge, so tht the probbilities re gi i descedig order. Brek ties usig y rbitrry but cosistet rule. Code ech reduced source strtig with the smllest source d workig bckwrds.
Source Reductio: Symbol Prob. 4.4.4.4.4.6 6.....4.... 4....6..4 5 Code Assigmet: Symb. Prob. Code 4.4.4.4.4.6 6.....4.... 4....6..4 5 L vg = p l i i =.4() +.() +.() +.(4) +.6(5) +.4(5) i =. bits/symbol.4(log(.4)) +.(log(.)) +.(log(.)) H ( z) = p i log( p i ) = i +.(log(.)) +.6(log(.6)) +.4(log(.4)) =.4 bits/symbol
The resultig code is clled Huffm code. It hs some iterestig properties: The source symbols c be ecoded (d decoded) oe t time. It is clled block code becuse ech source symbol is mpped ito fixed sequece of code symbols. It is istteous becuse ech codeword i strig of code symbols c be decoded without referecig succeedig symbols. It is uiquely decodble becuse y strig of code symbols c be decoded i oly oe wy. Exmple: Give the ecoded strig,, it c be decoded s follows: 6 The Huffm code is optiml (i terms of verge codeword legth) for give set of symbols d probbilities, subject to the costrit tht the symbols be coded oe t time. Disdvtge: For source with J symbols, we eed J source reductios. This c be computtiolly itesive for lrge J (ex. J = 56 for imge with 56 grylevels).
Tructed Huffm codig: Suboptiml pproches This is geerted by ecodig oly the ψ most probble symbols, for some iteger ψ < J. A prefix code followed by suitble fixed-legth code is used to ecode the rest of the symbols. Other exmples of suboptiml codes re B-code, biry shift code, d Huffm shift code.
Bit-ple Codig A gryscle imge is decomposed ito series of biry imges d ech biry imge is compressed by some biry compressio method. This removes codig d iterpixel redudcy. Bit-ple decompositio: Give gryscle imge with m grylevels, ech gryvlue c be represeted by m-bits, sy,,,, ) ( m m. The gryvlue r represeted by ( m, m,,, ) bse polyomil is give by the r = m m m + m + + + This bit represettio c be used to decompose the gryscle imge ito m biry imges (bit-ples). Altertively, oe c use the m-bit Gry code ( gm, gm,, g, g) to represet give gryvlue. The Gry code ( gm, gm,, g, g) c be obtied from,,,, ) by the followig reltioship: ( m m g m = m, d for i m, gi = i i+ where deotes exclusive OR of bits. The Gry code of successive grylevels differ t oly oe positio. 7 8 (biry represettio) (biry represettio) (Gry code) (Gry code)
The resultig biry imges re the compressed (error-free). We will study populr ecodig scheme clled ru-legth ecodig (RLC). Rulegth ecodig Ech row of bit ple (or biry imge) is represeted by sequece of legths (itegers) tht deote the successive rus of d pixels. Two pproches: Strt positio d legths of rus of s for ech row is used: (,)(7,)(,4)(7,)(,) (5,)(9,4) (,)(7,6) Oly legths of rus, strtig with the legth of ru is used:,,,,4,,,,,4,,,4,,6
, This techique is very effective i ecodig biry imges with lrge cotiguous blck d white regios, which would give rise to smll umber of lrge rus of s d s. The ru-legths c i tur be ecoded usig vrible legth code (ex. Huffm code), for further compressio. Let k be the frctio of rus of s with legth k. Nturlly, (,,, M ), would represet vector of probbilities (the probbility of ru of s beig of legth k). M i i) M (,,, M ) d L = i = i i be the verge legth of rus of s. Let H = i = log( be the etropy ssocited with Let bk be the frctio of rus of s with legth k. Nturlly, ( b, b,, b M ) would represet vector of probbilities (the probbility of ru of s beig of legth k). Let H be the etropy ssocited with ( b, b,, b M ) d M L = i = ib i be the verge legth of rus of s. The pproximte rulegth etropy of the imge is RL H RL = ( H + H) bits/ru ( L + L ) symbols/ru H provides estimte of the verge umber of bits per pixel required to code the ru legths i biry imge, usig vriblelegth code. The cocept of ru-legth c be exteded to vriety of -D codig procedures.
Rulegth Exmple Biry text imge.9.8.7 Plot of typicl row: (row # 5).6.5.4... 5 5 5 Rulegth ecodig of row # 5:, 7, 4,, 5,, 5,, 4,, 5, 4,,, 4, 5, 4, 4, 6,, 6,, 4, 4, 5,, 5,, 6,, 4,, 6,, 4,,, 4, 5, 4, 6,, 7 (4 rus)
.5.45.4.5..5 Distributio of legths of rus of i imge L H =. =. pixels/ru bits/ru..5..5 5 5 5..8.6.4...8 Distributio of legths of rus of i imge L H =. = 4.4 pixels/ru bits/ru.6.4. 5 5 5 H H RL = = L + H + L.8 bits/pixel
Lossless Predictive Codig Does ot require decompositio of gryscle imge ito bitples. Elimite iterpixel redudcy by extrctig d codig oly the ew iformtio i ech pixel. New iformtio i pixel is the differece betwee its ctul d predicted (bsed o previous pixel vlues ) vlues. Iput Imge f + fˆ e Symbol Ecoder Compressed Imge Predictor Nerest iteger Predictio error Predictio bsed o previous pixel vlues e fˆ = = f fˆ roud or m i= f α i = e f i + fˆ Compressed Imge Symbol Decoder e + + f Decompressed Imge fˆ Predictor
Exmple: -D first order lier predictor fˆ ( m, ) = roud [ αf ( m, ) ] (previous pixel predictor) I ech row, pixel vlue is predicted bsed o the vlue of the pixel to its left. The resultig predictio error e( m, ) = f ( m, ) fˆ( m, ) is ecoded. The first elemet of ech row (i.e., first colum of imge) is lso ecoded (usig, for exmple, differet Huffm code). Decoder recostructs e( m, ) bsed o the codewords d obtis the origil pixel vlues usig f ( m, ) = e( m, ) + fˆ( m, )
. Distributio of pixel vlues i origil imge.5..5..5 Etropy = 6.9 5 5 5. Distributio of predictio error vlues.8.6.4...8 Etropy = 4.4.6.4. - - - Possible dt reductio: 8 bits/pixel w/o compressio, 6.9 bits/pixel usig oly etropy codig, 4.4 bits/pixel usig predictive codig.