Quick viewing(Text Mode)

FORMATION of YUV (Ycbcr) IMAGE from JPEG DATA

FORMATION of YUV (Ycbcr) IMAGE from JPEG DATA

FORMATION OF YUV (YCbCr) IMAGE FROM JPEG DATA

A thesis submitted in partial fulfillment of the requirements for the award of the degree of

MASTER OF ENGINEERING

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

Submitted By: ANSHUMAN GOYAL Roll No-8044106

Under the guidance of:

Mr. Kulbir Singh (TIET Patiala) Mr. Yogender Gupta (HCL Technologies, Noida)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

THAPAR INSTITUTE OF ENGINEERING & TECHNOLOGY (DEEMED UNIVERSITY), PATIALA – 147004.

Year - 2006 ii

CERTIFICATE

I,AnshumanGoyalherebycertifythattheworkwhichisbeingpresentedinthis thesisentitled “Formation of YUV (YCbCr) Image From JPEG Data” (WorkCarried out at HCL Technologies, Sector – 24, Noida ) by me in partial fulfillment of requirements for the award of degree of Master of Engineering in Electronics and Communication from Thapar Institute of Engineering and Technology (Deemed University),Patiala,isanauthenticrecordofmyownworkcarriedunderthesupervision of Mr. Yogender Gupta (Project Manager, HCL Technologies) and Mr. Kulbir Singh, TIETPatiala. ThematterpresentedinthisthesishasnotbeensubmittedinanyotherUniversity orInstitutefortheawardofMasterofEngineering. (Anshuman Goyal ) Thisiscertifiedthattheabovestatementmadebythecandidateiscorrecttothebestof myknowledge (Yogender Gupta) (Kulbir Singh) HCLTechnologies,Noida. SeniorLecturer,TIETPatiala CounterSigned: HeadofDepartment,ECED DeanofAcademicAffairs, T.I.E.T,Patiala. T.I.E.T,Patiala.

HCLTechnologies,A5Sector24,Noida FormationOfYUV(YCbCr)Image AnshumanGoyal,MEECE8044106 FromJPEGData iii

ACKNOWLEDGEMENT Words are often to less to revels one’s deep regards. An understanding of the work like this is never the outcome of the efforts of a single person. I take this opportunitytoexpressmyprofoundsenseofgratitudeandrespecttoallthosewhohelped methroughthedurationofthisthesis. First,IwouldliketothanktheSupremePower,theGOD,onewhohasalways guidedmetoworkontherightpathofthelife.Withouthisgrace,thiswouldnevercome tobetoday’srealty. This work would not have been possible without the encouragement and able guidance of my Supervisor ‘Mr. Kulbir Singh’ , and Project Manager at HCL Technologies, ‘Mr. Yogender Gupta’. Their enthusiasm and optimism made this experiencebothrewardingandenjoyable.Mostofthenovelideasandsolutionsfoundin this thesis are the result of our numerous stimulating discussions. His feedback and editorialcommentswerealsoinvaluableforthewritingofthisthesis.Iamgratefulto ‘Dr. R. S. Kaler’ Prof. & Head, ECED forprovidingthefacilitiesforthecompletion ofthesis.Iamalsogratefulto HCL Technologies, Sector – 24 Noida ,forprovidingme thefacilitiesforthecompletionofthesis. Itakeprideofmyselfbeingsonofidealgreatparentswhoseeverlastingdesire, sacrifice,affectionateblessingandhelpwithoutwhichitwouldhavenotbeenpossible formetocompletemystudies. Atlast,IwouldliketothanktoallthemembersandemployeesofElectronicsand CommunicationDepartment,TIETPatialaand HCLTechnologies,Sector–24,Noida whoseloveandaffectionmademystayatboththeplacesamemorable. Place:HCLTechnologies,Noida (AnshumanGoyal)

HCLTechnologies,A5Sector24,Noida FormationOfYUV(YCbCr)Image AnshumanGoyal,MEECE8044106 FromJPEGData iv

Abstract JPEGfileformatissupportedbyawidevarietyofapplicationsonavarietyof platformsandisthemostcommonfileformatused.JPEGimagesareconstructedfrom RGB data. Compression allows more images to be saved in the same amount of disk space while preserving the ICC Color profile and caption information. Note, however, thatJPEGcompressionresultsinlossofimageinformation that can not afterwards be restored. EXIF is an extension of the JPEG format that allows thumbnail data and informationabouttheimagetobeincludedinaJPEGfile. Images are saved in uncompressed YCbCr format, where the picture data is representedinoneluminance(Y)and2colorchannels(CbandCr)insteadofthenormal 3colorchannels(RGB).Thetwocolorchannelsoccupythesamespaceastheluminance andthefilesizeisthereforetwothirdsof the size of a RGB file. YCbCr isa moreefficientmodeoftheimagerepresentationthanRGBandhasthesamequalitybut occupieslessspace.WeuseYCbCrifwewantthebestcombinationofhighqualityand thelowestfilesizeinanuncompressedfinishedfile.YUVmodelshumanperceptionof colormorecloselythanthestandardRGBmodelusedincomputergraphicshardware. Theprimaryadvantagesofluminance/systemssuchasYUVarethatthey remaincompatiblewithandanalogtelevision.TheYchannelsavesnearlyall the data recorded by black and white cameras, so it produces a signal suitable for receptiononoldmonochromedisplays.Inthiscase,theUandVaresimplydiscarded.If displayingcolor,allthreechannelsareused,andtheoriginalRGBinformationcanbe decoded. AnotheradvantageofYUVisthatsomeoftheinformationcanbediscardedin ordertoreducebandwidth.Thehumaneyehasfairlylittlecolorsensitivity:theaccuracy ofthebrightnessinformationoftheluminancechannelhasfarmoreimpactontheimage discernedthanthatoftheothertwo.Byunderstandingthishumanshortcoming,standards such as NTSC are used to reduce the amount of data consumed by the chrominance channelsandconsiderablyleavingtheeyetoextrapolatemoreofthecolor.NTSCsaves only 11% of the original and 30% of the . The information is usually preservedintheYchannel.Therefore,theresultingUandVsignalscanbesubstantially compressed.

HCLTechnologies,A5Sector24,Noida FormationOfYUV(YCbCr)Imageiv AnshumanGoyal,MEECE8044106 FromJPEGData v

LIST OF ABBREVIATIONS

YUV YUVImageFormat

BER BitErrorRate

CD CompactDisk

CDMA CodeDivisionMultipleAccess

CR CompressionRatio

DCT DiscreteCosineTransform

DVD DigitalVersatileDisk

DWT DiscreteWaveletTransform

FFT FastFourierTransform

FT FourierTransform

HDTV HighDefinitionTelevision

HVS HumanVisualSystem

LSB LeastSignificantBit

MSE MeanSquareError

PSNR PeakSignaltoNoiseRatio

RMSE RootMeanSquareError

HCLTechnologies,A5Sector24,Noida FormationOfYUV(YCbCr)Imagev AnshumanGoyal,MEECE8044106 FromJPEGData TableofContents

Table of Contents Chapter 1 - Introduction ...... 4

1.1Objective...... 5

1.2SummaryofWorkDone...... 6

Chapter 2: The Various Image Formats...... 7

2.1TheRGBImageFormat ...... 7

2.2TheGIFImageFormat...... 8

2.3ThePNGImageFormat ...... 8

2.4TheJPEGImageFormat ...... 9

2.5TheYUV(YCbCr)ImageFormat...... 9

2.6ColorSpaces...... 10

2.6.1RGBColorSpace ...... 11

2.6.2YUVColorSpace...... 12

2.6.3YUVFormats ...... 14

2.6.4Samplingsystemsandratios...... 15

2.6.4.14:4:4...... 15

2.6.4.24:2:2...... 16

2.6.4.34:2:0...... 16

2.6.4.44:0:0...... 17

2.6.5YIQColorSpace ...... 18

2.6.6YCbCrColorSpace...... 19

2.6.7RGBYCbCrEquations:SDTV...... 19

2.6.8ComputerSystemsConsiderations...... 20

2.6.9RGBYCbCrEquations:HDTV...... 21

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 1 TableofContents

2.6.10ComputerSystemsConsiderations...... 21

2.6.114:4:4YCbCrFormat...... 22

2.6.124:2:2YCbCrFormat...... 23

2.6.134:1:1YCbCrFormat...... 24

2.6.144:2:0YCbCrFormat...... 25

2.6.15ProgressiveJPEG ...... 29

2.6.16SummaryofImageFormats ...... 30

Chapter 3 - Compression Models & JPEG...... 32

3.1Theoutlineofthebaselinecompressionalgorithm...... 32

3.1.1Transformtheimageintoasuitablecolorspace...... 32

3.1.2Downsampleeachbyaveragingtogethergroupsofpixels...... 33

3.1.3Groupthepixelvaluesforeachcomponentinto8x8blocks...... 33

3.2Extensions...... 35

3.3LosslessJPEG...... 36

3.3.1–JPEGImageFormation&BlockDiagram ...... 37

3.3.2TheJPEGFormationProcess...... 38

3.3.3TheDCTEquation...... 38

3.3.4TheDCTMatrix ...... 39

3.3.5DoingtheDCTonan8x8Block...... 39

3.3.6–Quantization...... 41

3.3.7–Coding...... 43

3.3.8–Decompression...... 44

3.3.9ComparisonofMatrices ...... 45

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 2 TableofContents

Chapter 4: Formation of YUV (YCbCr) & JPEG Image ...... 46

4.1LossyEncoding ...... 46

4.2LossyCompressionSteps...... 46

4.2.1I.ConvertcolorimagesintoYCbCrcolorspace...... 47

4.2.2II.DownsampleCbCrcomponents ...... 48

4.2.3III&IV.GroupPixelsinto8x8BlocksandDCTencode ...... 48

4.2.4V&VI.UnwrapandScaletheCoefficients ...... 49

4.2.5VII.QuantizeandEliminateNearZeroCoefficients...... 49

4.2.6VIII&IX.HuffmanEncodeDataandaddHeaderInfo ...... 50

4.3DecompressingJPEGimages...... 50

4.4ImageCoding...... 51

4.4.1–EntropyCoding...... 51

4.4.2–LZWCoding ...... 55

4.4.3Runencoding...... 58

Chapter 5: Results & Discussions...... 60

5.1QuantizationofImages...... 60

5.2RecoveredImage ...... 64

5.2.1PSNRCalculation(QuantizedImages) ...... 64

5.3DecoderOutput(YUVImage) ...... 68

5.3.1PSNR&ItsCalculation(YUVImages)...... 76

5.4Discussion(s) ...... 80

Conclusion(s) ...... 81

References...... 82

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 3 Chapter1Introduction

Chapter 1 - Introduction Modernhardwareanddatabasetechnologyhasmadeitpossibletostoregigabytes ofinformationindatabases.However,itcanbedifficulttoutilizefullytheinformationin alargedatabasewithcomplicatedstructures.Manymethods,suchasdatamining,have beenproposedandstudiedtohelpusersbetterunderstandandanalyzetheinformation. Database visualization is one of the effective solutions to this problem. Database visualization becomes more appealing when handling large data sets with complex relationships because information presented in the form of images is more direct and easilyunderstoodbyhumans Whenprocessingimagesforahumanobserver,itisimportanttoconsiderhow imagesare convertedintoinformationbytheviewer. Understanding visual perception helpsduringalgorithmdevelopment. Image data represents physical quantities such as chromaticity and luminance. Chromaticityisthecolorqualityoflightdefined by its wavelength. Luminance is the amount of light. To the viewer, these physical quantities may be perceived by such attributesascolorandbrightness. How we perceive color image information is classified into three perceptual variables:hue,saturationandlightness.Whenweusethewordcolor,typicallyweare referringtohue.Huedistinguishesamongcolorssuchasgreenandyellow.Huesarethe color sensations reported by an observer exposed to various wavelengths. It has been shownthatthepredominantsensationofwavelengthsbetween430and480nanometersis blue. Green characterizes a broad range of wavelengths from 500 to 550 nanometers. Yellow covers the range from 570 to 600 nanometers and wavelengths over 610 nanometersarecategorizedasred.Black,gray,andwhitemaybeconsideredcolorsbut nothues. Saturationisthedegreetowhichacolorisundilutedwithwhitelight.Saturation decreasesastheamountofaneutralcoloraddedtoapurehueincreases.Saturationis oftenthoughtofashowpureacoloris.Unsaturatedcolorsappearwashedoutorfaded, saturatedcolorsareboldandvibrant.Redishighlysaturated;pinkisunsaturated.Apure

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 4 Chapter1Introduction coloris100percentsaturatedandcontainsnowhitelight.Amixtureofwhitelightanda purecolorhassaturationbetween0and100percent. Lightnessistheperceivedintensityofareflectingobject.Itreferstotheof colorsfromwhitethroughgraytoblack;arangeoftenreferredtoasgraylevel.Asimilar term, brightness, refers to the perceived intensity of a selfluminous object such as a CRT.Therelationshipbetweenbrightness,aperceivedquantity,andluminousintensity, ameasurablequantity,isapproximatelylogarithmic. Contrastistherangefromthedarkestregionsoftheimagetothelightestregions. Themathematicalrepresentationis: I − I Contrast = max min I max + I min

Where I max and I min are the maximum and minimum intensities of a region or image. Highcontrast images have large regions of dark and light. Images with good contrasthaveagoodrepresentationofallluminanceintensities. Asthecontrastofanimageincreases,theviewerperceivesanincreaseindetail. Thisispurelyaperceptionastheamountofinformationintheimagedoesnotincrease. Our perception is sensitive to luminance contrast rather than absolute luminance intensities.

1.1 - Objective

TheRGBandYUVcolorspacesarelineartransformationsofeachother.RGB haschannelsforredgreenbluecomponents,andYUVhaschannelsforcolor(UV)and illumination(Y).Becausecolorandilluminationareseparate,YUVhastheabilitytobe more illuminationindependent which means shadows and illumination changes don’t affectitasmuch.InthisthesistheworkhasbeencarriedouttoprocessaJPEGimage andconvertthatimageintoYUV(YCbCr)imageformat.Theadvantageinusingthis process is that this will make the image size very small, since in YUV image the Luminancecomponent(Y)hasgotalltheinformationabouttheimageandwecanwith thehelpofcodinganddecodingof(CbandCr)componentsreducethesizeofimageup toverysmallbitsascomparedtoJPEGImage.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 5 Chapter1Introduction TheworkpresentedinthisthesishasthemainobjectiveofconvertingtheJPEG images into YCbCr (YUV) images so as to compress the image data so that it can be easilytransferredtothenetworkshavingverylessbandwidth. Inthefollowingthesisfirstofallthevariousimageformatshavebeenexplained suchasGIF,JPEG,PNGandYUV.SincetheYUVformatisthemostimportantoneso stresshasbeenlaidontheThentheYUVformatshavebeenexplainedindetail.The advantages of YUV images and their compression property have also been explained afterthat. 1.2 - Summary of Work Done In the following thesis we have converted a JPEG image into YUV (YCbCr) image formatbytakingtheDCTandQuantizingtheimage.Thereareseveralwaystoconvert to/from YCbCr. This is the CCIR (International Radio Consultant Committee) recommendation6011andisthetypicalmethodusedinJPEGcompression. ADecoderhasbeendesignedforthesame,whichconvertstheJPEGimageinto YCbCrformat.TheconversionprocesshasbeenachievedwiththeuseofClanguage. The final step which is the compression of the Chrominance component of the YUV imagehasbeenachievedbytheuseofLosslesscodingtechniques,soastomakethe imagesizesmallerenoughsothatitcanbetransferredeasilyonlowbandwidthnetworks. Inthesecondstageofthisproject,theJPEGimage is reconstructed from the YUVImage.ThisconversionisthepartofEncoderwhichconvertstheYUVimageinto JPEGformat.ThequalityoftheimagethusreceivedischeckedfromthePSNRRatio. ThesizeofthefilehasbeencomparedintheTable–5.3.3whichconcludesthat thesizeoftheimagecanbereducedtoverylargeextentifYUVimagesareused.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 6 Chapter2:TheVariousImageFormats

Chapter 2: The Various Image Formats 2.1 - The RGB Image Format

Ifwetakealookatourcomputermonitor’sdisplaywithamagnifyinglenswe wouldseethatitconsistsofaverylargenumberoftripletsofred,greenandbluedots[1 5].Dependingonthemonitormanufacturertheymayberounddotsorsmallsquaresor othershapesbuttherealwayswillbetripletsofred,greenandblueelements.Inmost monitorsthedotsarequitelargeandeasytoseeevenwithaweaklens. Imagesonthecomputerdisplayareformedwhenthemonitorpreciselyvariesthe brightnessofthered,greenandblueelementsineachtriplet[3,4,5,6].Becausethedots areclosetogetherthehumaneyewillfusethethreered,greenandbluedotsofvarying brightnessintoasingledotthatappearstobethecolorcombinationofthethreelevelsof red,greenandbluecolor[2].Forthoseofuswhomissedartclassinschool,allcolors perceivedbyhumanscanbeformedbytherightbrightnesscombinationofred,greenand bluecolor.Amazing,buttrue! Fromhereoninwe’llrefertotheRed,GreenandBlue elements of images as "R","G"and"B". Imagesoncomputersareusuallynothingmorethanaseriesofnumbertriplets whereeachtripletofthreenumbersisintendedtocontrolasingletripletofR,GandB dotsonthemonitor.Eachtripletofnumbersisasinglepixel.Anumberoftripletssuch as67,228,180whichmeanstoturntheRelementupto67brightness,theGelementto 228brightnessandtheBelementto180brightness.Theresultwillbeseenbyhumansas aprettyshadeofgreenbluecolor.TheRGBnumbersarecalledcolorvalues. Imagefilesarearrangedsothatthereisaseriesofpixelsinrowsthatcorrespond totherowsoftinytripletdotsonthemonitor.Whenanimageisdisplayedonthemonitor sothateachpixeltripletintheimagefilecontrolsonecolortripletonthemonitorwesay thattheimageis"naturalsize"or"100%zoom". Inmostmodernsoftwarepackageswetakeforgrantedtheabilitytozoominor zoomoutofanimagetoseeitsmallerorlargerthannaturalsize.Ifwezoomin,our graphicssoftwarewilltaketheRGBvaluesinapixel that were originally intended to

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 7 Chapter2:TheVariousImageFormats control just one color triplet and will use that same value across and down as many tripletsasisnecessarytomaketheimagebiggeronthemonitor.Ifwezoomoutsothat theimageismuchsmallerthanintended,thentherewillbemoreRGBvaluesthanthere arecolortripletstocontrol.InthatcaseourgraphicssoftwarewillaverageouttheRGB pixelvaluestofigureoutwhataveragevalueshouldbeusedtodrivethecolortripletfor thatspotintheimage.ManifoldSystemperformsthesefunctionsautomatically.

2.2 - The GIF Image Format

GIF stands for Graphics Interchange Format. It is probably the most common imageformatusedontheWeb.GIF'shavetheadvantageofusuallybeingverysmallin size, which makes them fastloading [12, 13, 28]. Unlike JPEG's, GIF's use lossless compression,whichmeanstheymakethefilesizesmallwithoutlosingorblurringanyof theimageitself. AnothergoodthingthatGIF'scandoisanimation.WecanmakeananimatedGIF bydrawingeachframeoftheanimationinagraphicspackagethatsupportstheanimated GIFformat,thenexporttheanimationtoasingleGIFfile. ThemajordisadvantageofGIF'sisthattheyonlysupportupto256colors(thisis knownas8bitcolorandisatypeofindexedcolorimage).Thismeansthey'renotgood forphotographs,oranyotherimageapplicationthatcontainslotsofdifferentcolors.

2.3 - The PNG Image Format

PNGisarelativelynewinvention.ItstandsforPortableNetworkGraphics.Itwas designedtobeanalternativetotheGIFfileformat,butwithoutthelicensingissuesthat areinvolvedintheGIFcompressionmethod. There are two types of PNG: PNG8 format, which holds 8 bits of color information (comparable to GIF), and PNG24 format, which holds 24 bits of color (comparabletoJPEG). PNG8 often compresses images even better than GIF, resulting in smaller file sizes [29, 12, 13]. On the other hand, PNG24 is often less effective than JPEG's at compressing truecolor images such as photos, resulting in larger file sizes than the

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 8 Chapter2:TheVariousImageFormats equivalentqualityJPEG's.However,unlikeJPEG,PNG24islossless,meaningthatall oftheoriginalimage'sinformationispreserved. PNG also supports transparency like GIF, but can have varying degrees of transparencyforeachpixel,whereasGIF'scanonlyhavetransparencyturnedonoroff foreachpixel.ThismeansthatwhereastransparentGIF'softenhavejaggededgeswhen placedoncomplexorillmatchingbackgrounds,transparentPNG'swillhavenicesmooth edges. NotethatunlikeGIF,PNG8doesnotsupportanimation.Sincethisisthenew format,thereforesomeoldimageprocessingapplicationsdon’tunderstandthisformat.

2.4 - The JPEG Image Format

JPEG stands for Joint Photographic Experts Group, a bunch of boffins who inventedthisformattodisplayfullcolorphotographicimagesinaportableformatwitha smallfilesize.LikeGIFimages,theyarealsoverycommonontheWeb.Theirmain advantageoverGIF'sisthattheycandisplaytruecolorimages[29,22,23](upto16 million colors), which makes them much better for images such as photographs and illustrationswithlargenumbersofcolors. ThemaindisadvantageoftheJPEGformatisthatitislossy.Thismeansthatwe losesomeofthedetailofourimagewhenweconvert it to JPEG format. Boundaries betweenblocksofcolormayappearmoreblurry,andareaswithlotsofdetailwilllose theirsharpness.Ontheotherhand,JPEG'sdopreserveallofthecolorinformationinthe image,whichofcourseisgreatforhighcolorimagessuchasphotographs.JPEG'salso can'tdotransparencyoranimationinthesecases;wehavetousetheGIFformat(or PNGformatfortransparency).

2.5 - The YUV (YCbCr) Image Format

The YUV model defines a color space in terms of one luminance and two chrominance components. YUV is used in the PAL and NTSC systems of television broadcasting,whicharethestandardsinmuchoftheworld.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 9 Chapter2:TheVariousImageFormats

YUV models human perception of color more closely than the standard RGB modelusedincomputergraphicshardware,butnotascloselyastheHSLcolorspaceand HSVcolorspace. Y stands for the luminance component (the brightness) and U and V are the chrominance(color)components.TheYCbCrorYPbPrcolorspace,usedincomponent ,isderivedfromit(Cb/PbandCr/PraresimplyscaledversionsofUandV),andis sometimesinaccuratelycalled"YUV".TheYIQcolorspaceusedintheNTSCtelevision broadcastingsystemisrelatedtoit,althoughinamorecomplexway. YUVsignalsarecreatedfromanoriginalRGB(red,greenandblue)source.The weighted values of R, G and B are added together to produce a single Y signal, representing the overall brightness, or luminance, of that spot. The U signal is then createdbysubtractingtheYfromthebluesignaloftheoriginalRGB,andthenscaling; andVbysubtractingtheYfromthered,andthenscalingbyadifferentfactor.Thiscan beaccomplishedeasilywithanalogcircuitry. ThefollowingequationscanbeusedtoderiveY,UandVfromR,GandB: Y=0.299R+0.587G+0.114B U=0.492(B−Y)=−0.147R−0.289G+0.436B V=0.877(R−Y)=0.615R−0.515G−0.100B

2.6 - Color Spaces

Acolorspaceisamathematicalrepresentationofasetofcolors.Thethreemost popularcolormodelsareRGB(usedincomputergraphics);YIQ,YUV,orYCbCr(used invideosystems);andCMYK(usedincolorprinting)[2528].However,noneofthese colorspacesaredirectlyrelatedtotheintuitivenotionsofhue,saturation,andbrightness. Thisresultedinthetemporarypursuitofothermodels,suchasHSIandHSV,tosimplify programming, processing, and end user manipulation. All of the color spaces can be derived fromtheRGBinformationsuppliedby devices such as cameras and scanners [31].

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 10 Chapter2:TheVariousImageFormats

2.6.1 - RGB

Thered,green,andblue(RGB)colorspaceiswidelyusedthroughoutcomputer graphics.Red,green,andbluearethreeprimaryadditivecolors(individualcomponents areaddedtogethertoformadesiredcolor)andarerepresentedbyathreedimensional, Cartesian coordinate system (Figure 2.6.1). The indicated diagonal of the cube, with equalamountsofeach primarycomponent,representsvarious graylevels.Table2.6.1 contains the RGB values for 100% amplitude, 100% saturated color bars, a common videotestsignal.

a Red Blue Cyan Black White Green Green Range Yellow Normal Normal Magent R 0to255 255 255 0 0 255 255 0 0 G 0to255 255 255 255 255 0 0 0 0 B 0to255 255 0 255 0 255 0 255 0

Table2.6.1 →100%RGBColorBars

Cyan

Magenta White

Green

Black

RED Yellow

Figure 2.6.1 →TheRGBColorCube

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 11 Chapter2:TheVariousImageFormats

TheRGBcolorspaceisthemostprevalentchoiceforcomputergraphicsbecause colordisplaysusered,green,andbluetocreatethedesiredcolor[1519].Therefore,the choiceoftheRGBcolorspacesimplifiesthearchitectureanddesignofthesystem.Also, a system that is designed using the RGB color space can take advantage of a large numberofexistingsoftwareroutines,sincethiscolorspacehasbeenaroundforanumber ofyears.However,RGBisnotveryefficientwhendealingwith“realworld”images.All threeRGBcomponentsneedtobeofequalbandwidthtogenerateanycolorwithinthe RGBcolorcube.Theresultofthisisaframebufferthathasthesamepixeldepthand displayresolutionforeachRGBcomponent.Also,processinganimageintheRGBcolor spaceisusuallynotthemostefficientmethod.Forexample,tomodifytheintensityor colorofagivenpixel,thethreeRGBvaluesmustbe read from the frame buffer, the intensity or color calculated, the desired modifications performed, and the new RGB valuescalculatedandwrittenbacktotheframebuffer. If the system had access to an imagestoreddirectlyintheintensityandcolorformat,someprocessingstepswouldbe faster. For these and other reasons, many video standards use and two color difference signals. The most common are the YUV, YIQ, and YCbCr color spaces. Althoughallarerelated,therearesomedifferences.

2.6.2 - YUV Color Space The YUV model defines a color space in terms of one luminance and two chrominancecomponents[19].YUVisusedinthePALandNTSCsystemsoftelevision broadcasting,whichisthestandardinmuchoftheworld. YUV models human perception of color more closely than the standard RGB modelusedincomputergraphicshardware,butnotascloselyastheHSVcolorspace. Y stands for the luminance component (the brightness) and U and V are the chrominance(color)components.TheYCbCrorYPbPrcolorspace,usedincomponent video,isderivedfromit(Cb/PbandCr/PraresimplyscaledversionsofUandV),andis sometimesinaccuratelycalled"YUV".TheYIQcolorspaceusedintheNTSCtelevision broadcastingsystemisrelatedtoit,althoughinamorecomplexway. YUVsignalsarecreatedfromanoriginalRGB(red,greenandblue)source.The weighted values of R, G and B are added together to produce a single Y signal,

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 12 Chapter2:TheVariousImageFormats representing the overall brightness, or luminance, of that spot. The U signal is then createdbysubtractingtheYfromthebluesignaloftheoriginalRGB,andthenscaling; andVbysubtractingtheYfromthered,andthenscalingbyadifferentfactor.Thiscan beaccomplishedeasilywithanalogcircuitry. The YUV color space is used by the PAL (Phase Alternation Line), NTSC (National Television System Committee), and SECAM (Sequentiel Couleur Avec MémoireorSequentialColorwithMemory)compositecolorvideostandards[2427]. Theblackandwhitesystemusedonlyluma(Y)information;colorinformation(Uand V)wasaddedinsuchawaythatablackandwhitereceiverwouldstilldisplayanormal blackandwhite picture. Color receivers decoded the additional color information to displayacolorpicture. The basic equations to convert between gammacorrected RGB (notated as R´G´B´anddiscussedlaterinthischapter)andYUVare:

Y=0.299R´+0.587G´+0.114B´ Eq–2.6.2.1

U=–0.147R´–0.289G´+0.436B´ Eq–2.6.2.2

=0.492(B´–Y)

V=0.615R´–0.515G´–0.100B´ Eq–2.6.2.3

=0.877(R´–Y)

R´=Y+1.140V Eq–2.6.2.4

G´=Y–0.395U–0.581V Eq–2.6.2.5

B´=Y+2.032U Eq–2.6.2.6

Y   .0 299 .0 578 .0 114  R       U  = − .0 147 − .0 289 .0 436  G Eq–2.6.2.7 V   .0 615 − .0 515 − .0 100 B

FordigitalR´G´B´valueswitharangeof0255,Yhasarangeof0–255,Ua rangeof0to±112,andVarangeof0to±157.Theseequationsareusuallyscaledto

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 13 Chapter2:TheVariousImageFormats simplifytheimplementationinanactualNTSCorPALdigitalencoderordecoder.Note that for digital data, 8bit YUV and R´G´B´ data shouldbesaturatedatthe0and255 levelstoavoidunderflowandoverflowwraparoundproblems. Ifthefullrangeof(B´–Y)and(R´–Y)hadbeenused,thecompositeNTSCand PAL levels would have exceeded what the (then current) blackandwhite television transmittersandreceiverswerecapableofsupporting.Experimentationdeterminedthat modulated subcarrier excursions of 20% of the luma (Y) signal excursion could be permittedabovewhiteandbelowblack.Thescalingfactorswerethenselectedsothatthe maximumlevelof75%amplitude,100%saturationyellowandcyancolorbarswouldbe atthewhitelevel(100IRE)[27].

2.6.3 - YUV Formats YUVformatsfallintotwodistinctgroups,thepackedformatswhereY,U(Cb) andV(Cr)samplesarepackedtogetherintomacropixelswhicharestoredinasingle array, and the planar formats where each component is stored as a separate array, the finalimagebeingafusingofthethreeseparateplanes[23]. Inthediagramsbelow,thenumericalsuffixattachedtoeachY,UorVsample indicatesthesamplingpositionacrosstheimageline,so,forexample,V 0indicatesthe th leftmostVsampleandY nindicatestheYsampleatthe(n+1) pixelfromtheleft. Subsamplingintervalsinthehorizontalandverticaldirectionsmaymeritsome explanation.Thehorizontalsubsamplingintervaldescribeshowfrequentlyacrossaline asampleofthatcomponentistakenwhiletheverticalintervaldescribesonwhichlines samplesaretaken.Forexample,UYVYformathasahorizontalsubsamplingperiodof2 forboththeUandVcomponentsindicatingthatUandVsamplesaretakenforevery secondpixelacrossaline.Theirverticalsubsamplingperiodis1indicatingthatUandV samplesaretakenoneachlineoftheimage[46]. ForYVU9,though,theverticalsubsamplingintervalis4.ThisindicatesthatU and V samples are only taken on every fourth line of the original image. Since the horizontalsamplingperiodisalso4,asingleUandasingleVsamplearetakenforeach squareblockof16imagepixels.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 14 Chapter2:TheVariousImageFormats

2.6.4 - Sampling systems and ratios

Thesubsamplinginavideosystemisusuallyexpressedasathreepartratio.The threetermsoftheratioare:thenumberofbrightness("luminance""luma"orY)samples, followedbythenumberofsamplesofthetwocolor("chroma")components:U/Cbthen V/Cr, for each complete sample area. For quality comparison, only the ratio between thosevaluesisimportant,so4:4:4couldeasilybecalled1:1:1;however,traditionallythe valueforbrightnessisalways4,withtherestofthevaluesscaledaccordingly.

Figure 2.6.4.1 →YCbCrImageLayout

Sometimes,fourpartrelationsarewritten,like4:2:2:4.Inthesecases,thefourth numbermeansthesamplingfrequencyratioofakeychannel.Invirtuallyallcases,that numberwillbe4,sincehighqualityisverydesirableinkeyingapplications. The mapping examples given are only theoretical and for illustration. The bit streamsofreallifeimplementationswillmostlikelydiffer.

2.6.4.1 - 4:4:4 Eachofthethreechannelshasthesamesamplerate,soeachsinglepixelinthe resultingimagegetsthreefullwords(usually8or10bitslong)ofinformation,resulting in3bytesperpixelfor8bitquantizationwhennotusingcompression.

Mapping:

Thebitstream[Y 0U 0V 0Y 1U 1V 1Y 2U 2V 2Y 3U 3V 3]willmaptothefollowing fourpixels:[Y 0U 0V 0][Y 1U 1V 1][Y 2U 2V 2][Y 3U 3V 3]

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 15 Chapter2:TheVariousImageFormats

Thisisthebestcolorsamplingratio(it yieldsa perfect representation of each pixel's color), and is used as an intermediate format in highend film scanners and cinematicpostproduction.Notethat4:4:4may(andoftenindeeddoes,asinsomemodes ofHDCAMSR)alsomeanthatthethreevaluesareallcolorvaluesintheRGBcolor space,whichmustalwaysbesampledatthesamefrequency.

2.6.4.2 - 4:2:2 Each of the two colordifference channels has half the sample rate of the brightness channel, so horizontal color resolution is only half that of 4:4:4. For uncompressedvideoand8bitquantization,eachmacropixeloftwoneighboringpixels uses4bytesofmemory. Mapping:

Thebitstream[Y 0U 0Y 1V 1Y 2U 2Y 3V 3]willmaptothefollowingfourpixels:

[Y 0U 0V 1][Y 1U 0V 1][Y 2U 2V 3][Y 3U 2V 3] Thisisstillaverygoodquality,andmosthigherenddigitalvideoformatsuse thisratio: • DigitalBetacam. • DVCPRO50. • D9. • CCIR601/SerialDigitalInterface/D1.

2.6.4.3 - 4:2:0 4:2:0doesnotmeanthatthereisnoVorCrinformationstoredatall,itmeans that in each line, only one color difference channel is stored with half the horizontal resolution[25,27,28].Thechannelwhichisstoredflipseachline,sotheratiois4:2:0 for one line, 4:0:2 in the next, then 4:2:0 again, and so on. This leads to half the horizontalaswellashalftheverticalresolution,givingaquarterofthecolorresolution overall.ThePALandSECAMcolorsystemsareespeciallywellsuitedtothiskindof datareduction.Uncompressedvideointhisformatwith8bitquantizationuses6bytes foreverymacropixel(2×2pixels).

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 16 Chapter2:TheVariousImageFormats

Mapping:

The bit stream [Y o0 U o0 Y o1 Y o2 U o2 Y o3 ] [Y e0 V e0 Y e1 Y e2 V e2 Y e3 ] will map to the followingtwolinesoffourpixelseach:

[Y o0 U o0 V e0 ][Y o1 U o0 V e0 ][Y o2 U o2 V e2 ][Y o3 U o2 V e2 ]

[Y e0 U o0 V e0 ][Y e1 U o0 V e0 ][Y e2 U o2 V e2 ][Y e3 U o2 V e2 ] Thequalityofthismethodisverycloseto4:1:1,anditisusedinthefollowingformats: • DVDandotherMainProfileMPEG2implementations. • PALDVandDVCAM. • HDV. • MostcommonJPEGandMJPEGimplementations.

2.6.4.4 - 4:0:0 Thisratioispossible (indeed,somecodecdosupportit),butnotwidely used, sinceitscolorfidelityisevenbelowthatofVHS[25,27,28].Itmeanshalfthevertical andquartersthehorizontalcolorresolutions,withonlyoneeighthofthebandwidthofthe maximum color resolutions used. Uncompressed video in this format with 8bit quantizationuses10bytesforeverymacropixel(4x2pixels).

Mapping:

Thebitstream[Y o0 U o0 Y o1 Y o2 Y o3 ][Y e0 V e0 Y e1 Y e2 Ye3 ]willmaptothefollowingtwo linesoffourpixelseach:

[Y o0 U o0 V e0 ][Y o1 U o0 V e0 ][Y o2 U o0 V e0 ][Y o3 U o0 V e0 ]

[Y e0 U o0 V e0 ][Y e1 U o0 V e0 ][Y e2 U o0 V e0 ][Y e3 U o0 V e0 ]

Somevideocodecmayoperateat4:0:0.5or4:0:0.25asanoption,soastoallow higherthanVHSqualitywithouthavingtotaketoolargeofahitonbandwidth

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 17 Chapter2:TheVariousImageFormats

2.6.5 - YIQ Color Space

TheYIQcolorspaceisderivedfromtheYUVcolorspaceandisoptionallyused bytheNTSCcompositecolorvideostandard[25,27,28].(The“I”standsfor“inphase” andthe“Q”for“quadrature,”whichisthemodulationmethodusedtotransmitthecolor information.)ThebasicequationstoconvertbetweenR´G´B´andYIQare:

Y =0.299R´+0.587G´+0.114B´ Eq–2.6.5.1

I =0.596R´–0.275G´–0.321B´ Eq–2.6.5.2

=Vcos33°–Usin33°

=0.736(R´–Y)–0.268(B´–Y)

Q =0.212R´–0.523G´+0.311B´ Eq–2.6.5.3

=Vsin33°+Ucos33°

=0.478(R´–Y)+0.413(B´–Y)

 I  0 1  cos (33) sin (33) U    =       Eq–2.6.5.4 Q 1 0 − sin (33) cos (33) V 

R´ =Y+0.956I+0.621Q Eq–2.6.5.5

G´ =Y–0.272I–0.647Q Eq–2.6.5.6

B´ =Y–1.107I+1.704Q Eq–2.6.5.7

FordigitalR´G´B´valueswitharangeof0255,Yhasarangeof0–255,Ihavea rangeof0to±152,andQhasarangeof0to±134.IandQareobtainedbyrotatingtheU and V axes 33° [25, 27, 28]. These equations are usually scaled to simplify the implementationinanactualNTSCdigitalencoderordecoder. Notethatfordigitaldata,8bitYIQandR´G´B´datashouldbesaturatedatthe0 and255levelstoavoidunderflowandoverflowwraparoundproblems.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 18 Chapter2:TheVariousImageFormats

2.6.6 - YCbCr Color Space

The YCbCr color space was developed as part of ITUR BT.601 during the developmentofaworldwidedigitalcomponentvideostandard.YCbCrisascaledand offsetversionoftheYUVcolorspace[26,27,29].Yisdefinedtohaveanominal8bit rangeof16235;C bandC raredefinedtohaveanominalrangeof16–240.Thereare several YCbCr sampling formats, such as 4:4:4, 4:2:2, 4:1:1 and 4:2:0 that are also described.

2.6.7 - RGB - YCbCr Equations: SDTV

Thebasicequationstoconvertbetween8bitdigitalR´G´B´datawitha16–235 nominalrangeandYCbCrare:

Y601 =0.299R´+0.587G´+0.114B´ Eq–2.6.7.1

Cb=–0.172R´–0.339G´+0.511B´+128 Eq–2.6.7.2

Cr=0.511R´–0.428G´–0.083B´+128 Eq–2.6.7.3

R´=Y 601 +1.371(Cr–128) Eq–2.6.7.4

G´=Y 601 –0.698(Cr–128)–0.336(Cb–128) Eq–2.6.7.5

B´=Y601+1.732(Cb–128) Eq–2.6.7.6

WhenperformingYCbCrtoR´G´B´conversion,theresultingR´G´B´valueshave anominalrangeof16–235,withpossibleoccasionalexcursionsintothe0–15and236– 255values[25,27,28].ThisisduetoYandCbCroccasionallygoingoutsidethe16–235 and 16–240 ranges, respectively, due to video processing and noise. Note that 8bit YCbCrandR´G´B´datashouldbesaturatedatthe0and255levelstoavoidunderflow and overflow wraparound problems. Table 2.6.8.1 lists the YCbCr values for 75% amplitude,100%saturatedcolorbars,acommonvideotestsignal.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 19 Chapter2:TheVariousImageFormats

2.6.8 - Computer Systems Considerations

If the R´G´B´ data has a range of 0–255, as is commonly found in computer systems,thefollowingequationsmaybemoreconvenienttouse:

Y601 =0.257R´+0.504G´+0.098B´+16 Eq–2.6.8.1

Cb=–0.148R´–0.291G´+0.439B´+128 Eq–2.6.8.2

Cr=0.439R´–0.368G´–0.071B´+128 Eq–2.6.8.3

R´=1.164(Y601–16)+1.596(Cr–128) Eq–2.6.8.4

G´=1.164(Y601–16)–0.813(Cr–128)–0.391(Cb–128) Eq–2.6.8.5

B´=1.164(Y601–16)+2.018(Cb–128) Eq–2.6.8.6

Note that 8bit YCbCr and R´G´B´ data should be saturated at the 0 and 255 levelstoavoidunderflowandoverflowwraparoundproblems.

Red Blue Cyan Black White Green Green Range Yellow Nominal Magenta SDTV Y 16To235 180 162 131 112 84 65 35 16 Cb 16To240 128 44 156 72 184 100 212 128 Cr 16To240 128 142 44 58 198 212 114 128 HDTV Y 16To235 180 168 145 133 69 51 28 16 Cb 16To240 128 44 147 63 193 109 212 128 Cr 16To240 128 136 44 52 204 212 120 128

Table 2.6.8.1 →75%YCbCrColorBars

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 20 Chapter2:TheVariousImageFormats

2.6.9 - RGB - YCbCr Equations: HDTV

Thebasicequationstoconvertbetween8bitdigitalR´G´B´datawitha16–235 nominalrangeandYCbCrare:

Y709=0.213R´+0.715G´+0.072B´ Eq–2.6.9.1

Cb=–0.117R´–0.394G´+0.511B´+128 Eq–2.6.9.2

Cr=0.511R´–0.464G´–0.047B´+128 Eq–2.6.9.3

R´=Y709+1.540(Cr–128) Eq–2.6.9.4

G´=Y709–0.459(Cr–128)–0.183(Cb–128) Eq–2.6.9.5

B´=Y709+1.816(Cb–128) Eq–2.6.9.6

WhenperformingYCbCrtoR´G´B´conversion,theresultingR´G´B´valueshave anominalrangeof16–235,withpossibleoccasionalexcursionsintothe0–15and236 255values[25,27,28].ThisisduetoYandCbCroccasionallygoingoutsidethe16–235 and 16–240 ranges, respectively, due to video processing and noise. Note that 8bit YCbCrandR´G´B´datashouldbesaturatedatthe0and255levelstoavoidunderflow andoverflowwraparoundproblems. Table2.6.8.1liststheYCbCrvaluesfor75%amplitude, 100% saturated color bars,acommonvideotestsignal.

2.6.10 - Computer Systems Considerations

If the R´G´B´ data has a range of 0–255, as is commonly found in computer systems,thefollowingequationsmaybemoreconvenienttouse:

Y709=0.183R´+0.614G´+0.062B´+16 Eq–2.6.10.1

Cb=–0.101R´–0.338G´+0.439B´+128 Eq–2.6.10.2

Cr=0.439R´–0.399G´–0.040B´+128 Eq–2.6.10.3

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 21 Chapter2:TheVariousImageFormats

R´=1.164(Y709–16)+1.793(Cr–128) Eq–2.6.10.4

G´=1.164(Y709–16)–0.534(Cr–128)–0.213(Cb–128)

Eq–2.6.10.5

B´=1.164(Y709–16)+2.115(Cb–128) Eq–2.6.10.6

Note that 8bit YCbCr and R´G´B´ data should be saturated at the 0 and 255 levelstoavoidunderflowandoverflowwraparoundproblems.

2.6.11 - 4:4:4 YCbCr Format

Figure2.6.11.1illustratesthepositioningofYCbCrsamplesforthe4:4:4formats. EachsamplehasaY,aCb,andaCrvalue[25,27,28].Eachsampleistypically8bits (consumerapplications)or10bits(provideoapplications)percomponent.Eachsample thereforerequires24bits(or30bitsforprovideoapplications).

Figure 2.6.11.1 →4:4:4CoSitedSampling.

The sampling positions on the active scan lines of an interlaced picture.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 22 Chapter2:TheVariousImageFormats

2.6.12 - 4:2:2 YCbCr Format Figure2.6.12.1illustratesthepositioningofYCbCrsamplesforthe4:2:2formats. For every two horizontal Y samples, there is one Cb and Cr sample. Each sample is typically 8 bits (consumer applications) or 10 bits (provideo applications) per component.Eachsamplethereforerequires16bits(or20bitsforprovideoapplications), usuallyformattedasshowninFigure2.6.12.1 To display 4:2:2 YCbCr data, it is first converted to 4:4:4 YCbCr data, using interpolationtogeneratethemissingCbandCrsamples[25,27,28].

Figure 2.6.12.1 →4:2:2CoSitedSampling.

The sampling positions on the active scan lines of an interlaced picture.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 23 Chapter2:TheImageFormatsExplained

2.6.13 - 4:1:1 YCbCr Format Figure2.6.13.1illustratesthepositioningofYCbCrsamplesforthe4:1:1format (also known as YUV12), used in some consumer video and DV video compression applications[25,27,28].ForeveryfourhorizontalYsamples,thereisoneCbandCr value.Eachcomponentistypically8bits.Eachsamplethereforerequires12bits,usually formattedasshowninFigure2.6.13.1. To display 4:1:1 YCbCr data, it is first converted to 4:4:4 YCbCr data, using interpolationtogeneratethemissingCbandCrsamples.

Figure 2.6.13.1 →4:1:1CoSitedSampling.

The sampling positions on the active scan lines of an interlaced picture.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 24 Chapter2:TheImageFormatsExplained

2.6.14 - 4:2:0 YCbCr Format

Ratherthanthehorizontalonly2:1reductionofCbandCrusedby4:2:2,4:2:0 YCbCr implements a 2:1 reduction of Cb and Cr in both the vertical and horizontal directions [25, 26, 27, 28]. It is commonly usedfor video compression. As shown in Figure2.6.14.1through2.6.14.5,thereareseveral4:2:0samplingformats.Table2.6.14.1 liststheYCbCrformatsforvariousDVapplications.Todisplay4:2:0YCbCrdata,itis firstconvertedto4:4:4YCbCrdata,usinginterpolationtogeneratethenewCbandCr samples.

Figure 2.6.14.1 →4:2:0SamplingforH.261,H.263,andMPEG1 .

The sampling positions on the active scan lines of a progressive or non-interlaced picture.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 25 Chapter2:TheImageFormatsExplained

Figure 2.6.14.2 →4:2:0SamplingforMPEG2.

The sampling positions on the active scan lines of a progressive or non-interlaced picture.

50 DV DV DV 1, 2 H.263 H.261, Digital MPEG Digital S 576-Line 480-Line 480-Line 576-Line DVCAM DVCAM DVCAM Beta-cam Beta-cam DVCPRO DVCPRO 4:2:2 Co-Sited X X X 4:1:1 Co-Sited X X X 4:2:0 X X 4:2:0 Co-Sited X X

Table 2.6.14.1 →YCbCrFormatsforVariousDVApplications.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 26 Chapter2:TheImageFormatsExplained

Figure 2.6.14.3 →4:2:0SamplingforMPEG2.

The sampling positions on the active scan lines of an interlaced picture

(top field first = 1).

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 27 Chapter2:TheImageFormatsExplained

Figure 2.6.14.4 →4:2:0SamplingforMPEG2 .

The sampling positions on the active scan lines of an interlaced picture

(top field first = 0).

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 28 Chapter2:TheImageFormatsExplained

Figure 2.6.14.5 →4:2:0CoSitedSamplingfor576LineDVandDVCAM .

The sampling positions on the active scan lines of an interlaced picture.

2.6.15 - Progressive JPEG UnlikenormalJPEGimages,whicharedisplayedonelineatatimefromtopto bottom, progressive are displayed in alternating lines, and then filled in on a secondpass[29].DependingonwhichgraphicsviewerorWebbrowserisbeingused, progressiveJPEGsmayproducea"Venetianblind"effectorsimplyablurryorblocky imagethatgraduallysharpens.PagesusingprogressiveJPEGsletpeopleseeatleastthe outline of an image sooner, and often appear to load faster than pages using normal JPEGs.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 29 Chapter2:TheImageFormatsExplained

2.6.16 - Summary of Image Formats

Figure 2.6.16.1 →TheRGB,YCbCrandJPEGFileLayout[30,12]

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 30 Chapter2:TheImageFormatsExplained

Thistablesummarizesthekeydifferencesbetweentheimageformats.

GIF JPEG PNG – 8 PNG – 24 Betterforclipartand Betterfor Betterforclipartand Betterfor drawngraphicswith photographswith drawngraphicswith photographswith fewcolor,orlarge lotsofcoloror fewcolor,orlarge lotsofcolororfine blocksofcolor finecolordetail blocksofcolor colordetail Canonlyhaveupto Canhaveupto16 Canonlyhaveupto Canhaveupto16 256color millioncolor 256color millioncolor Imagesare"lossless" Imagesare Imagesare"lossless" Imagesare theycontainthe "lossy"they theycontainthe "lossless"they sameamountof containless sameamountof containthesame informationasthe informationthan informationasthe amountof original(butwith theoriginal original(butwith informationasthe only256color) only256color) original Canbeanimated Cannotbe Cannotbeanimated Cannotbeanimated animated Canhavetransparent Cannothave Canhavetransparent Canhave areas transparentareas areas transparentareas

Table 2.6.16.2 →Keydifferencebetweentheimageformats

Onthewhole,GIF’sarebetterfortheWeb,asWebgraphicstendtobesmall, have a small amount of colors, and sometimes need fancy stuff like animation or transparency.However,JPEGsarereallyhandywhenwehaveaverycomplexorlarge image(suchasaphoto),and/orwewantafullcolorimage.PNG8can oftenproduce smallerfilesizesthanGIF,andbothtypesofPNGarelossless. We will be working more on JPEG’s as the work carried out is mainly for photographsandimagedata.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 31 Chapter3:CompressionModels&JPEG

Chapter 3 - Compression Models & JPEG JPEGworksoneitherfullcolororgrayscaleimages;itdoesnothandlebilevel (blackandwhite)images,atleastnotwell[1,5,12,24].Itdoesn'thandlecolormapped images either; and we have to preexpand those into an unmapped fullcolor representation.JPEGworksbeston"continuoustone"images.Imageswithmanysudden jumpsincolorvalueswillnotcompresswell. TherearealotofparameterstotheJPEGcompressionprocess.Byadjustingthe parameters,wecantradeoffcompressedimagesizeagainstreconstructedimagequality overa‘very’widerange.Wecangetimagequalityrangingfromopart(at100xsmaller thantheoriginal24bitimage)toquiteindistinguishablefromthesource(atabout3x smaller).Usuallythethresholdofvisibledifferencefromthesourceimageissomewhere around10xto20xsmallerthantheoriginal,i.e.,1to2bitsperpixelforcolorimages. images do not compress as much. In fact, for comparable visual quality,agrayscaleimageneedsperhaps25%lessspacethanacolorimage;certainlynot the66%lessthatwemightnaivelyexpect. JPEG defines a "baseline" lossy algorithm, plus optional extensions for progressiveandhierarchicalcodingdiscussedlaterinthetext.Thereisalsoaseparate losslesscompressionmode;thistypicallygivesabout2:1compression,i.e.about12bits percolorpixel.MostcurrentlyavailableJPEGhardwareandsoftwarehandlesonlythe baselinemode.

3.1 - The outline of the baseline compression algorithm

3.1.1 - Transform the image into a suitable color space.

There is a no option for grayscale, but for color images we generally want to transformRGBintoaluminance/chrominance colorspace (YCbCr, YUV, etc) [29]. The luminancecomponentisgrayscaleandtheothertwoaxesarecolorinformation.Thereason for doing this is that we can afford to lose a lot more information in the chrominance componentsthanwecanintheluminancecomponent:thehumaneyeisnotassensitiveto highfrequencychromainfoasitistohighfrequencyluminance.Wedon'thavetochange thecolorspaceifwedon'twantto,sincetheremainderofthealgorithmworksoneachcolor

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 32 Chapter3:CompressionModels&JPEG componentindependently,anddoesn'tcarejustwhatthedatais.However,compressionwill belesssincewewillhavetocodeallthecomponentsatluminancequality.Notethatcolor spacetransformationisslightlylossyduetoroundofferror,buttheamountoferrorismuch smallerthanwhatwetypicallyintroducelateron.

3.1.2 - Down sample each by averaging together groups of pixels.

Theluminancecomponentisleftatfullresolution,whilethechromacomponents areoftenreduced2:1horizontallyandeither2:1or1:1(nochange)vertically.InJPEG speakthesealternativesareusuallycalled2h2vand2h1vsampling,butwemayalsoseethe terms"411"and"422"sampling.Thisstepimmediatelyreducesthedatavolumebyonehalf or onethird. In numerical terms it is highly lossy, but for most images it has almost no impactonperceivedquality,becauseoftheeye'spoorerresolutionforchromainfo.Note thatdownsamplingisnotapplicabletograyscaledata;thisisonereasoncolorimagesare morecompressiblethangrayscale.

3.1.3 - Group the pixel values for each component into 8x8 blocks.

Transformeach8x8blockthroughadiscretecosinetransform(DCT).TheDCT is a relative of the Fourier transform and likewise gives a frequency map, with 8x8 components.Thuswenowhavenumbersrepresentingtheaveragevalueineachblockand successively higherfrequency changes within the block.Themotivationfordoingthisis that we can now throw away highfrequency information without affecting lowfrequency information.(TheDCTtransformitselfisreversibleexceptforroundofferror.)

 In each block, divide each of the 64 frequency components by a separate "quantizationcoefficient",androundtheresultstointegers.Thisisthefundamental informationlosing step. The larger the quantization coefficient, the more data is discarded. Note that even the minimum possible quantization coefficient, 1, loses some info, because the exact DCT outputs are typically not integers. Higher frequencies are always quantized less accurately (given larger coefficients) than lower,sincetheyarelessvisibletotheeye.Also,theluminancedataistypically quantized more accurately than the chroma data, by using separate 64element

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 33 Chapter3:CompressionModels&JPEG

quantizationtables.Tuningthequantizationtablesforbestresultsissomethingofa black art, and is an active research area. Most existingencodersusesimplelinear scaling of the example tables given in the JPEG standard, using a single user specified"quality"settingtodeterminethescalingmultiplier.Thisworksfairlywell formidrangequalities(nottoofarfromthesampletablesthemselves)butisquitenon optimalatveryhighorlowqualitysettings.  EncodethereducedcoefficientsusingeitherHuffmanorarithmeticcoding.(Strictly speaking, baseline JPEG only allows Huffman coding; arithmetic coding is an optionalextension.)[25]Noticethatthisstepislossless,soitdoesn'taffectimage quality.ThearithmeticcodingoptionusesQcoding;itisidenticaltothecoderused inJBIG.BeawarethatQcodingispatented.Mostexistingimplementationssupport onlytheHuffmanmode,soastoavoidlicensefees.Thearithmeticmodeoffersmay be5or10%bettercompression,whichisn'tenoughtojustifypayingfees.  Tackonappropriateheaders,etc,andoutputtheresult. In a normal "interchange" JPEGfile,allofthecompressionparametersareincludedintheheaderssothatthe decompressor can reverse the process. These parameters include the quantization tablesandtheHuffmancodingtables.Forspecializedapplications,thespecpermits thosetablestobeomittedfromthefile;thissavesseveralhundredbytesofoverhead, butitmeansthatthedecompressormustknowaprioriwhattablesthecompressor used.Omittingthetablesissafeonlyinclosedsystems.Thedecompressionalgorithm reversesthisprocess.Thedecompressormultipliesthereducedcoefficientsbythe quantizationtableentriestoproduceapproximateDCTcoefficients.Sincetheseare only approximate, the reconstructed pixel values are also approximate, but if the designhasdonewhatit'ssupposedtodo,theerrorswon'tbehighlyvisible.Ahigh quality decompressor will typically add some smoothing steps to reduce pixelto pixel discontinuities. The JPEG standard does not specify the exact behavior of compressorsanddecompressors,sothere'ssomeroomforcreativeimplementation. Inparticular,implementationscantradeoffspeedagainstimagequalitybychoosing more accurate or fasterbutlessaccurate approximations to the DCT. Similar tradeoffsexistforthedownsampling/upsamplingandcolorspaceconversionsteps.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 34 Chapter3:CompressionModels&JPEG

3.2 - Extensions

Theprogressivemodeisintendedtosupportrealtimetransmissionofimages.It allowstheDCTcoefficientstobesentpiecemealinmultiple"scans"oftheimage.With eachscan,thedecodercanproduceahigherqualityrenditionoftheimage.Thusalow qualitypreviewcanbesentveryquickly,andthenrefinedastimeallows[31].Thetotal spaceneededisroughlythesameasforabaselineJPEGimageofthesamefinalquality. (Infact,it canbesomewhat*less*ifa customHuffman table is used for each scan, becausetheHuffmancodescanbeoptimizedoverasmaller,moreuniformpopulationof datathanappearsinabaselineimage'ssinglescan.)Thedecodermustdoessentiallya full JPEG decode cycle for each scan: inverse DCT, upsample, and color conversion mustallbedoneagain,nottomentionanycolorquantizationfor8bitdisplays.Sothis scheme is useful only with fast decoders or slow transmission lines. Up until 1995, progressiveJPEGwasararebird,butitsuseisnowspreadingassoftwaredecodershave becomefastenoughtomakeitusefulwithmodemspeeddatatransmission. Thehierarchicalmoderepresentsanimageatmultipleresolutions.Forexample, one could provide 512x512, 1024x1024, and 2048x2048 versions of the image. The higherresolutionimagesarecodedasdifferencesfromthenextsmallerimage,andthus requiremanyfewerbitsthantheywouldifstoredindependently. (However, the total numberofbitswillbegreaterthanthatneededtostorejustthehighestresolutionframe in baseline form.) The individual frames in a hierarchical sequence can be coded progressivelyifdesired.Hierarchicalmodeisnotwidelysupportedatpresent. Part3oftheJPEGstandard,approvedattheendof1995,introduceseveralnew extensions. The one most likely to become popular is variable quantization, which allows the quantization table to be scaled to different levels in different parts of the image.Inthiswaythe"morecritical"partsoftheimagecanbecodedathigherquality than the "less critical" parts. A signaling code can be inserted at any DCT block boundarytosetanewscalingfactor. ThethirdmajorextensionaddedbyPart3isa"tiling" concept that allows an imagetobebuiltupasacompositeofJPEGframes, which may have different sizes, resolutions,qualitysettings,evencolorspaces.(Forexample,acolorimagethatoccupies asmallpartofamostlygrayscalepagecouldberepresentedasaseparateframe,without

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 35 Chapter3:CompressionModels&JPEG havingtostorethewholepageincolor.)Again,there'ssomeoverlapinfunctionality withvariablequantizationandselectiverefinement.Thegeneralcaseofarbitrarytilesis rathercomplexandisunlikelytobewidelyimplemented.Inthesimplestcaseallthe tilesarethesamesizeandusesimilarqualitysettings.Thiscasemaybecomepopular evenifthegeneraltilingmechanismdoesn't,becauseitsurmountsthe64Kpixelona side image size limitation that was (not very foresightedly) built into the basic JPEG standard.Theindividualframesarestillrestrictedto64Kforcompatibilityreasons,but thetotalsizeofatiledJPEGimagecanbeupto232 pixelsonaside.

3.3 - Lossless JPEG

TheseparatelosslessmodedoesnotuseDCT,sinceroundofferrorspreventa DCTcalculationfrombeinglossless.Forthesamereason,onewouldnotnormallyuse colorspaceconversionordownsampling,althoughthesearepermittedbythestandard. Thelosslessmodesimplycodesthedifferencebetween each pixel and the "predicted" valueforthepixel.Thepredictedvalueisasimplefunctionofthealreadytransmitted pixelsjustaboveandtotheleftofthecurrentone(forexample,theiraverage;8different predictor functions are permitted). The sequence of differences is encoded using the samebackend(Huffmanorarithmetic)usedinthelossymode. Lossless JPEG with the Huffman back end is certainly not a stateoftheart losslesscompressionmethod,andwasn'tevenwhenitwasintroduced.Thearithmetic codingbackendmaymakeitcompetitive,butweareprobablybestofflookingatother methodsifweneedonlylosslesscompression. Themainreasonforprovidingalosslessoptionisthatitmakesagoodadjunctto thehierarchicalmode:thefinalscaninahierarchicalsequencecanbealosslesscoding oftheremainingdifferences,toachieveoveralllosslessness.Thisisn'tquiteasusefulas itmayatfirstappear,becauseexactlosslessnessisnotguaranteedunlesstheencoderand decoderhaveidenticalIDCTimplementations(i.e.,identicalroundofferrors).Andwe can'tusedownsamplingorcolorspaceconversioneitherifwewanttruelosslessness. Butinsomeapplicationsthecombinationisuseful.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 36 Chapter3:CompressionModels&JPEG

3.3.1 – JPEG Image Formation & Block Diagram Aswehaveseen,theYCbCrcolorspaceseemstobeveryappropriateforimage compression [26 – 30]. Indeed, we can discard most of the information in both chrominancecomponentswithoutimpairingthequalityoftheimage.JpegandJpeg2000 both use this color space in their compression scheme and exploit this property in differentways. YIQOrYUVColorSpace

f(I,J) F(U,V) Fq(u,v) DCT Quantization

8X8 Quantiz Coding Tables Tables

Header DC Tables DPCM Entropy Coding DATA RLC AC Figure 3.3.1.1 →JPEGImageFormationBlockDiagram.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 37 Chapter3:CompressionModels&JPEG

3.3.2 - The JPEG Formation Process ThefollowingisageneraloverviewoftheJPEGprocess.Later,detailedmethod ofJPEG'swillbeexplainedsothatamorecomprehensiveunderstandingoftheprocess maybeacquired[30]. 1. Theimageisbrokeninto8x8blocksofpixels. 2. Workingfromlefttoright,toptobottom,theDCTisappliedtoeachblock. 3. Eachblockiscompressedthroughquantization. 4. Thearrayofcompressedblocksthatconstitutetheimageisstoredinadrastically reducedamountofspace. 5. Whendesired,theimageisreconstructedthroughdecompression,aprocessthat usestheInverseDiscreteCosineTransform(IDCT).

3.3.3 - The DCT Equation 1 N −1 N −1  2( x + )1 iΠ   2( y + )1 iΠ  D i,( j) = C i)( C( j)∑∑ p(x, y) cos   cos   Eq − 1.3.2.3 2N x=0 y=0  2N   2N   1   if u = 0 C(u) =  2  Eq − 2.3.2.3 1 if u > 0  P(x,y)isthex,y th elementoftheimagerepresentedbythematrixp.Nisthesize oftheblockthattheDCTisdoneon[29].Theequationcalculatesoneentry(i.j th )ofthe transformedimagefromthepixelvaluesoftheoriginalimagematrix.Forthestandard 8x8 block that JPEG compression uses, N equals 8 and x and y range from 0 to 7. ThereforeD(i,j)wouldbeasinEquation3.3.3.3. 1 7 7  2( x + )1 iΠ   2( y + )1 iΠ  D i,( j) = C i)( C( j)∑∑ p(x, y) cos   cos   Eq − 3.3.2.3 4 x=0 y =0  16   16  Because the DCT uses cosine functions, the resulting matrix depends on the horizontal,diagonal,andverticalfrequencies[28].Thereforeanimageblockwithalotof

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 38 Chapter3:CompressionModels&JPEG changeinfrequencyhasaveryrandomlookingresultingmatrix,whileanimagematrix ofjustonecolor,hasaresultingmatrixofalargevalueforthefirstelementandzeroes fortheotherelements.

3.3.4 - The DCT Matrix TogetthematrixformofEquation3.3.4.1,wewillusethefollowingequation:  1   if i = 0  N  T i,( j) =   Eq–3.3.4.1  2  2( j + )1 iΠ   Cos   if i > 0  N  2N   Foran8x8blockitresultsinthefollowingmatrix: .3536 .3536 .3536 .3536 .3536 .3536 .3536 .3536    .4904 .4157 .2778 .0975 −.0975 −.2778 −.4157 −.4904 .4619 .1913 −.1913 −.4619 −.4619 −.1913 .1913 .4619    .4157 −.0975 −.4904 −.2778 .2778 .4904 .0975 −.4157 T =   Eq–3.3.4.2 .3536 −.3536 .−3536 .3536 .3536 −.3536 −.3536 .3536    .2778 −.4904 .0975 .4157 −.4157 −.0975 .4904 −.2778 .1913 −.4619 .4619 −.1913 −.1913 .4619 −.4619 .1913    .0975 −.2778 .4157 −.4904 .4904 −.4157 .2778 −.0975 Thefirstrow( i=1)ofthematrixhasalltheentriesequalto1/18asexpectedfrom Equation3.3.4.1. ThecolumnsofTformanorthonormalset,soTisanorthogonalmatrix.When doingtheinverseDCTtheorthogonalityofTisimportant,astheinverseofTisT’which iseasytocalculate[28].

3.3.5 - Doing the DCT on an 8x8 Block Thepixelvaluesofablackandwhiteimagerangefrom0to255instepsof1, wherepureblackisrepresentedby0andpurewhiteby255.Thusitcanbeseenhowa photo,illustration,etc.canbeaccuratelyrepresentedbythese256shadesofgray[30].

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 39 Chapter3:CompressionModels&JPEG

Sinceanimagecompriseshundredsoreventhousandsof8x8blocksofpixels,the followingdescriptionofwhathappenstoone8x8 block is a microcosm of the JPEG process;whatisdonetooneblockofimagepixelsisdonetoallofthem,intheorder earlierspecified[32]. Now, let's start with a block of imagepixel values. This particular block was chosenfromtheveryupperlefthandcornerofanimage. 154 123 123 123 123 123 123 136   192 180 136 154 154 154 136 110 254 198 154 154 180 154 123 123   239 180 136 180 180 166 123 123 Original =   Eq–3.3.5.1 180 154 136 167 166 149 136 136   128 136 123 136 154 180 198 154 123 105 110 149 136 136 180 166   110 136 123 123 123 163 154 136 BecausetheDCTisdesignedtoworkonpixelvaluesrangingfrom128to127, theoriginalblockis"leveledoff'bysubtracting128fromeachentry.Thisresultsinthe followingmatrix.  26 − 5 − 5 − 5 − 5 − 5 − 5 8     64 52 8 26 26 26 8 −18 126 70 26 26 52 26 − 5 − 5    111 52 8 52 52 38 − 5 − 5 M =   Eq–3.3.5.2  52 26 8 39 38 21 8 8     0 8 − 5 8 26 52 70 26   − 5 − 23 −18 21 8 8 52 38    −18 8 − 5 − 5 − 5 8 26 8  We are now ready to perform the Discrete Cosine Transform, which is accomplishedbymatrixmultiplication. D = TMT ′ Eq3.3.5.3

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 40 Chapter3:CompressionModels&JPEG

InEquation3.3.5.3matrixMisfirstmultipliedontheleftbytheDCTmatrixT fromtheprevioussection;thistransformstherows.Thecolumnsarethentransformedby multiplyingontherightbythetransposeoftheDCTmatrix.Thisyieldsthefollowing matrix. 162 3. 40 6. 20 0. 72 3. 30 3. 12 5. −19 7. −11 5.     30 5. 108 4. 10 5. 32 3. 27 7. −15 5. 18 4. − 0.2  − 94 1. − 60 1. 12 3. − 43 4. − 31 3. 1.6 − 3.3 1.7    − 38 6. − 83 4. − 4.5 − 22 2. −13 5. 15 5. − 3.1 5.3 D =   Eq–3.3.5.4 − 31 3. 17 9. − 5.5 −12 4. 14 3. 0.6. 11 5. − 0.6     − 9.0 −11 8. 12 8. 2.0 28 1. 12 6. 4.8 9.2   6.4 − 4.2 12 2. 6.6 −18 7. −12 8. 7.7 12 0.    −10 0. 11 2. 8.7 −16 3. 21 5. 0.0 9.5 10 7. 

Thisblockmatrix3.3.5.4nowconsistsof64DCTcoefficients,C ij ,whereiandj rangefrom0to7.Thetopleftcoefficient,C 00 ,correlatestothelowfrequenciesofthe originalimageblock.AswemoveawayfromC 00 inalldirections,theDCTcoefficients correlatetohigherandhigherfrequenciesoftheimageblock,whereC 77 correspondsto thehighestfrequency.Itisimportanttonotethatthehumaneyeismostsensitivetolow frequencies,andresultsfromthequantizationstepwillreflectthisfact.

3.3.6 – Quantization Our8x8blockofDCTcoefficientsisnowreadyforcompressionbyquantization. AremarkableandhighlyusefulfeatureoftheJPEGprocessisthatinthisstep,varying levels of image compression and quality are obtainable through selection of specific quantizationmatrices[31,32].Thisenablestheusertodecideonqualitylevelsranging from1to100,where1givesthepoorestimagequalityandhighestcompression,while 100givesthebestqualityandlowestcompression.Asaresult,thequality/compression ratiocanbetailoredtosuitdifferentneeds. Subjectiveexperimentsinvolvingthehumanvisualsystem have resulted in the JPEGstandardquantizationmatrix.Withaqualitylevelof50,thismatrixrendersboth highcompressionandexcellentdecompressedimagequality.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 41 Chapter3:CompressionModels&JPEG

16 11 10 16 24 40 51 61    12 12 14 19 26 58 60 55  14 13 16 24 40 57 69 56    14 17 22 29 51 87 80 62 Q =   Eq–3.3.6.1 50 18 22 37 56 68 109 103 77    24 35 55 64 81 104 113 92  49 64 78 87 103 121 120 101   72 92 95 98 112 100 103 99  If,however,anotherlevelofqualityandcompressionisdesired,scalarmultiples oftheJPEGstandardquantizationmatrixmaybeused.Foraqualitylevelgreaterthan50 (lesscompression,higherimagequality),thestandardquantizationmatrixismultiplied by(100qualitylevel)/50[26,29,30].Foraqualitylevellessthan50(morecompression, lowerimagequality),thestandardquantizationmatrixismultipliedby50/qualitylevel. The scaled quantization matrix is then rounded and clipped to have positive integer valuesrangingfrom1to255.Forexample,thefollowing quantization matrices yield qualitylevelsof10and90.  80 60 50 80 120 200 255 255    55 60 70 95 130 255 255 255  70 65 80 120 200 255 255 255   70 85 110 145 255 255 255 255 Q =   Eq–3.3.6.2 10  90 110 185 255 255 255 255 255   120 175 255 255 255 255 255 255 245 255 255 255 255 255 255 255   255 255 255 255 255 255 255 255  3 2 2 3 5 8 10 12    2 2 3 4 5 12 12 11  3 3 3 5 8 11 14 11   3 3 4 6 10 17 16 12 Q =   Eq–3.3.6.3 90  4 4 7 11 14 22 21 15    5 7 11 13 16 12 23 18 10 13 16 17 21 24 24 21   14 18 19 20 22 20 20 20

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 42 Chapter3:CompressionModels&JPEG

Quantization is achieved by dividing each element in the transformed image matrixDbythecorrespondingelementinthequantizationmatrix,andthenroundingto thenearestintegervalue.Forthefollowingstep,quantizationmatrixQ 50 isused.  D  C = round ij  Eq–3.3.6.4 ij    Qij  10 4 2 5 1 0 0 0    3 9 1 2 1 0 0 0 − 7 − 5 1 − 2 −1 0 0 0   − 3 − 5 0 −1 0 0 0 0 C =   Eq–3.3.6.5 − 2 1 0 0 0 0 0 0    0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0    0 0 0 0 0 0 0 0 Recallthatthecoefficientssituatedneartheupperleftcomercorrespondtothe lower frequencies to which the human eye is most sensitive of the image block. In addition, the zeros represent the less important, higher frequencies that have been discarded,givingrisetothelossypartofcompression[24,25].Asmentionedearlier, onlytheremainingnonzerocoefficientswillbeusedtoreconstructtheimage.Itisalso interestingtonotetheeffectofdifferentquantizationmatrices;useofQ 10 wouldgiveC significantlymorezeros,whileQ 90 wouldresultinveryfewzeros.

3.3.7 – Coding ThequantizedmatrixCisnowreadyforthefinalstepofcompression.Before storage, all coefficients of C are converted by an encoder to a stream of binary data (01101011...).Indepthcoverageofthecodingprocessisbeyondthescopeofthisarticle. However,wecanpointoutonekeyaspectthatthereader is sure to appreciate. After quantization,itisquitecommonformostofthecoefficientstoequalzero.JPEGtakes advantageofthisbyencodingquantizedcoefficientsinthezigzagsequenceshownin Figure1[27,28].Theadvantageliesintheconsolidationofrelativelylargerunsofzeros,

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 43 Chapter3:CompressionModels&JPEG whichcompressverywell.ThesequenceinFigure3.3.7.1(4x4)continuesfortheentire 8x8block.

Figure 3.3.7.1 →Encodingquantizedcoefficientsinthezigzagsequence

3.3.8 – Decompression Reconstructionofourimagebeginsbydecodingthebitstreamrepresentingthe quantizedmatrixC.EachelementofCisthenmultipliedbythecorrespondingelement ofthequantizationmatrixoriginallyused.

Rij = Qij x Cij Eq–3.3.8.1

160 44 20 80 24 0 0 0    36 108 14 38 26 0 0 0 − 98 − 65 16 − 48 − 40 0 0 0   − 42 − 85 0 − 29 0 0 0 0 R =   Eq–3.3.8.2 − 36 22 0 0 0 0 0 0    0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0    0 0 0 0 0 0 0 0 TheIDCTisnextappliedtomatrixR,whichisroundedtothenearestinteger. Finally,128isaddedtoeachelementofthatresult,givingusthedecompressedJPEG versionNofouroriginal8x8imageblockM[28–30]. N = round(T ′ R T ) + 128 FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 44 Chapter3:CompressionModels&JPEG

3.3.9 - Comparison of Matrices LetusnowseehowtheJPEGversionofouroriginalpixelblockcompares. 154 123 123 123 123 123 123 136   192 180 136 154 154 154 136 110 254 198 154 154 180 154 123 123   239 180 136 180 180 166 123 123 Original =   Eq–3.3.9.1 180 154 136 167 166 149 136 136   128 136 123 136 154 180 198 154 123 105 110 149 136 136 180 166   110 136 123 123 123 163 154 136 149 134 119 116 121 126 127 128   204 168 140 144 155 150 135 125 253 195 155 166 183 165 131 111   245 185 148 166 184 160 124 107 Decompressed =   Eq–3.3.9.2 188 149 132 155 172 159 147 136   132 123 125 143 160 166 168 171 109 119 126 128 139 158 168 166   111 127 127 114 118 141 147 135 Thisisaremarkableresult,consideringthatnearly70%oftheDCTcoefficients were discarded prior to image block decompression/reconstruction. Given that similar resultswilloccurwiththerestoftheblocksthatconstitutetheentireimage,itshouldbe no surprise that the JPEG image will be scarcely distinguishable from the original. Remember, there are 256 possible shades of gray in a blackandwhite picture, and a differenceof,say,10,isbarelynoticeabletothehumaneye.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 45 Chapter–4FormationofYUV(YCbCr)&JPEGImage

Chapter 4: Formation of YUV (YCbCr) & JPEG Image 4.1 - Lossy Encoding ThelossycompressionschemeiswherealltheactionhappensforJPEGs.This schememakesuseofthediscretecosinetransformtoconvertimagesandcompressesthe resultingDCTcoefficients[31,32].Thelossycompressionschemecanvarythelevelof compression ratio used, giving control over the final image quality (and file size, roughly).TheamountofcompressionJPEGcansupplydependsalmostentirelyonthe sourceimage.Bestresultscomefromusingimageswithfewhighfrequencydetails. TheDCTisappliedto8x8pixelblocks,thissizebeing selected as a tradeoff between computational complexity, compression speed and quality. Two methods are used in compression; the coefficients are quantized, and are then Huffman or arithmeticallycompressed.Thequantizingofthecoefficientsiswherethelossypartof thesequence,wherehighfrequencyinformationisdiscarded.

4.2 - Steps

ThestepsinDCTencodinganimagecanbelooselybrokenupinto9steps. I. ConvertnongrayscaleimagesintoYCbCrcomponents. II. DownsampleCbCrcomponents. III. Grouppixelsinto8x8blocksforprocessing. IV. DCTeachpixelblock. V. Unwrapthecoefficients. VI. Scaleeachcoefficientbya'quantization'factors. VII. Eliminatenearzerocoefficients. VIII. Huffmanencodingofdata. IX. Addheaderinfoandquantizationfactors.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 46 Chapter–4FormationofYUV(YCbCr)&JPEGImage

4.2.1 - I. Convert color images into YCbCr color space Each component of color images is compressed independently, as with the losslesscompressionscheme.RGBcolorspaceisnotthemostefficientwaytoJPEG compressimages,asitisparticularlysusceptibletocolorchangesduetoquantization. Color images are converted from RGB components into YCbCr color space, whichconsistsoftheluminance(grayscale)andtwochroma(color)components.Note thatalthoughsomeliterature(includingsomepreviouslyproducedbytheHyperMedia Unit)statesthatimagesareconvertedintoYUVcomponentsorisjustveryhazyabout whatformattheimageisconvertedtoitisnotYUVexactly.However,theYCbCrcolor spaceissimplyalightened,gammaadjustedversionofYUVcolorspace[32].These equationsare(to1decimalplace): Y = 0.3R + 0.6G + 0.1B Eq − 4.3.1.1 U U = B − Y Cb = + 5.0 Eq − 2.1.3.4 2 V V = R − Y Cr = + 5.0 Eq − 3.1.3.4 2

Figure 4.2.1.1 →TheRGBColorSpaceCube The Y component contains the luminance information of the images and is in effectagrayscaleversionoftheimage.OnanRGBcolorcube,thiswouldcorrespondto

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 47 Chapter–4FormationofYUV(YCbCr)&JPEGImage a line running from (0,0,0) to (1,1,1). Cb and Cr are perpendicular color planes, approximatelygreenminusmagentaandblueminusyellow.Notethattheweightingsin theYUVequationabovegivesmostdetailtothegreencomponentandleasttotheblue. Thisreflectsthefactthatthehumaneyeismoresusceptibletovariationsinthecolor greenandlesstoblue.

4.2.2 - II. Down sample CbCr components OncetheimagehasbeenconvertedintoYCbCrcolorspace(ifrequired),theCb andCr componentsare downsampled by a factorof2 [22, 23, 27]. We can do this because the human eye gets more detail from the luminance information, than the chrominance[26].ThisishowtheCrandCbcomponentshavemuchlesscontrast(and thuslessinformation)thantheluminancecomponent. Thisdownsamplinggivesanimmediate50%reductioninthesizeofthefile whichexplainswhycolorimagesalwaysseemsmallerthangrayscaleimageswhenJPEG compressed.Downsamplingratiosareexpressedintheusualmanner.i.e.4:1:1means thattheUandVcomponentshavebeensubsampled4times(into4x4pixelblocks). The human eye is more susceptible to change in luminance (grey levels) than changeinchrominance(colors).Asmostofthedetailsthehumaneyepicksuparestored intheYcomponent,moreerrorcanbetoleratedintheCbCrcolorcomponents.

4.2.3 - III & IV. Group Pixels into 8x8 Blocks and DCT encode Thisstepseemsfairlyobvious.EachofthethreeYCbCrcolorplanesareencoded separatelybutusingthesamescheme.Eightbyeightpixelblocks(64pixelsintotal) werechosenasthesizeforcomputationalsimplicity.Otherblocksizeshavebeenused forotherencodingschemes[26,31].Forexample,theCinepakcodecusedbyApple's QuickTimesoftwareuses4x4blockstogiveveryquick(butoftenpoorerquality)DCT encoding and decoding. Older professional video capture cards made by Radius use 16x16blockbecausetheycansupplytheextraprocessingpowerrequired.Ifthesizeof theimageisnotafactorof8,itispaddedouttotherequiredsize,withextraspacebeing addedontheleftandbottomoftheimage.Whentheimageisdecoded,thesepadpixels arechoppedoff.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 48 Chapter–4FormationofYUV(YCbCr)&JPEGImage

The64datapointsareDCTencodedusingtheequation: 1 7 7  (2x +1)uπ   (2y +1)vπ  F(u,v) = C(u) C(v) ∑∑ f (x, y)Cos  Cos   Eq–4.2.3.1 4 x=0 y =0  16   16  1 C(u), C(v) = For u,v =0 Where N Eq–4.2.3.3 C(u), C(v) = 1 Otherwise

4.2.4 - V & VI. Unwrap and Scale the Coefficients The coefficients are unwrapped in the infamous 'zigzag' pattern which just converts the 8x8 array into a single 64 element array with the coefficients of most significanceoccurringfirst. These coefficients are then scaled except for theDCcomponentwhichisthe scaledaverageintensityvalueoftheentireimage(orYUVplane,inthecaseofacolor image)[24,25].Thequantizationfactorsusedinscalingthecoefficientsisnotactually dictated in the JPEG specification. The encoding algorithm can actually use whatever scalefactorsitlikes,astheseareincludedwiththefinaldata.TheJPEGstandardhasa genericsetofquantizationfactorswhichareoftenused. Quantizationachievestwogoals: 1. It allowsmoredetailtobekeptinthe(moreimportant) low frequency data. 2. Itaveragestozero,coefficientvalueswhichareclosetozero

4.2.5 - VII. Quantize and Eliminate Near Zero Coefficients Next,coefficientswhichhavebeenscaledtonearzerovaluesareactuallygiven zerovalues,inthehopethattherewillbemanyzerocoefficientsandthereforecompress well[30].Thisisthesecondlossypartofthecompressionprocess,wherewedeliberately andirretrievablylooseinformation. ThemajorlossypartoftheJPEGprocessisquantization,whereeachcoefficient isdividedbyitsownscalefactor.Thelargerthisnumberis,themorecompressionwill beappliedtotheimagedata.Thisstepiswheretheintendedqualityofthefinalimage

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 49 Chapter–4FormationofYUV(YCbCr)&JPEGImage canbespecified.Althoughitispossibletocalculationandencodecustomquantization tables,inpracticethedefaultISOJPEGtablesareusedmostofthetime.

4.2.6 - VIII & IX. Huffman Encode Data and add Header Info TheresultingquantizedintegercoefficientsarethenHuffmanencodedtosqueeze that extra bit of compression out of the image. Huffman compression is lossless of course.Headerinformationisaddedtothedata,including the quantization factor, the scalefactorsandtheHuffmantables.DoabitofformattingandoutsquirtsaJPEGfile!

4.3 - Decompressing JPEG images The JPEG compression scheme can be described as asymmetrical, in that the methodusedforcompression,whenreversed,isthemethodfordecompression. 1. Removeheaderinfoandquantizationfactors. 2. ExtractdatafromHuffmanencodebitstream. 3. Scaleeachcoefficientbytheinverse'quantization'factors. 4. PreparethecoefficientsforIDCTin8x8blocks. 5. IDCTeachcoefficientblock. 6. Putthe8x8pixelblocksintotheimagebuffer. 7. ScaleuptheCbCrcomponents. 8. ConverttheYCbCrcomponentsintoanRGBimage. ThemaindifferenceindecodingistheuseoftheInverseDiscreteCosineTransform, whichis: 1 7 7  (2x +1)uπ   (2y +1)vπ  F(u,v) = ∑∑ F(x, y)C(u)C(v)Cos  Cos   Eq–4.3.1 4 u=0 v =0  16   16  1 C(u), C(v) = For u,v =0 Where N Eq–4.3.3 C(u), C(v) = 1 Otherwise

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 50 Chapter–4FormationofYUV(YCbCr)&JPEGImage

4.4 Image Coding

Storage, transmission and retrieval of image data involve massive amounts of data.Asingleblackandwhitevideoimagecontains768x575pixels.Whenweuse1 byteforeachpixelthismeans0.431MByteforeachimage[29–31].Thequestionarises whetherwecouldassignthebitsmoreintelligentlytooursampleddatasothatwecould uselessspace.Inthischapterwewilldiscussanumberoftechniquestodoso[27].We will discuss coding and decoding techniques that preserve the full data (lossless techniques),aswellasmethodsthatintroducedistortionsinthedata(lossytechniques) andhaveatradeoffbetweenthenumberofbitsneededandtheaccuracyofthecoding. Whentheinformationisprogramdata,forinstance,nodistortioncanbetolerated. In imagedatasomelosscanbepresentwithoutnoticingitinthedisplayedimages[30].

4.4.1 – Entropy Coding LetustakeasanexamplethatwewanttoencodethecharactersinEnglishtexts. NotallcharactersintheEnglishoccurequallyfrequently.Theeandthespacearemuch morefrequentthanthezorthex.Instraightforwardencoding,thesamenumberofbits (fixedlengthcode)wouldencodeeachcharacter.Byassigningtotheeandspaceshort codesandtothezandxlongercodes,wecanreducethenumberofbitsneededtoencode atextfragment[24,25,26].Awellknowncodingmethod using this principle is the Huffmancode.Themethodisbasedupondividingthesetofsymbolstobeencodedeach timeintwoequallyprobablesubsets,andcodingthesetwosubsetswitha1anda0.If oneofthesubsetscontainsonlyonesymbol,wearedonewiththatsubset[2428]. Wewillillustratetheprocedurebyasimpleexample.Assumethatwehaveto transmittheoutputofasensor,whoseoutputisquantizedinto8possiblevalues0,1,2,3, 4,5,6,7.Thissensormonitorsaprocessthatinitsnormalstatehasvalue3or4.Onlyin exceptionalconditionshigherorlowervalueswilloccur.Theprobabilitythatacertain valueoccursisgiveninthesecondcolumnofTable4.4.1.1[27].Theprocedurestartsby takingtogetherthetwovalueswithlowestprobabilityandsummingtheirprobabilitiesto gettheprobabilityofthecombinedvalues.Inthiscasethevalues0and7arecombined with probabilities 0.02 and 0.03. The combination has a probability of 0.05. This

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 51 Chapter–4FormationofYUV(YCbCr)&JPEGImage

procedureisillustratedinFigure4.4.1.1.Next1and6(0.04and0.05)arecombinedwith aresultingprobabilityof0.09.Nowtheleastprobablearethecombinations(0,7)and(1, 6),thesearetakentogetherwithacombinedprobabilityof0.14.Then2and5aretaken togetherandsoon.Thisprocedureofrepeatedcombinationcreatesthegraphshownin figure42.Nextthecodesareassignedbystartingattherootandassigninga0toaleft branchanda1toarightbranch[2327].The0'sand1'swecomeacrosstravelingfrom theroottothevaluewewanttoencode,constitutetheHuffmancode.Theresultingcode tableisgiveninthethirdcolumnofTable4.4.1.1.Theaveragenumberofbitsrequired by this coding procedure for a given sensor value is obtained by multiplying the probabilityofacode(2ndcolumn)withthenumberofbits(4thcolumn)andsumming these values. The average number of bits is 2.53, and we obtain a reduction of 16% comparedtothestraightforwardfixedlengthencodingwith3bits.

Value Probability Code No. Of Bits -log P i -Pi log P i 0 0.02 000 4 5.64 0.11 1 0.04 0010 4 4.64 0.18 2 0.12 010 3 3.06 0.37 3 0.30 10 2 1.74 0.52 4 0.31 11 2 1.69 0.52 5 0.13 011 3 2.94 0.38 6 0.05 0011 4 4.32 0.22 7 0.03 0001 4 5.06 0.14 Table 4.4.1.1 →Symbols,theirprobabilityandtheHuffmancodes.Theaveragebit lengthis2.53,theentropyis2.45.Straightforwardthecodingresultsinafixed3bit length. Inthegraph,weassigneda0toaleftbranchand a 1 to a right branch. This assignationiscompletelyarbitrary.Wecouldhaveassignedthevaluesalsotheopposite wayorevenarbitrarily.InanycasetheresultwouldbevalidHuffmancode.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 52 Chapter–4FormationofYUV(YCbCr)&JPEGImage

0 7 1 6 2 5 3 4 0.02 0.03 0.04 0.05 0.12 0.13 0.30 0.31

0 1 0 1 0 1 0 1 0.05 0.09 0.25 0.61 0 1 0.14

0 1 0.39

0 1 1.00 Figure 4.4.1.2 →ConstructionoftheHuffmancodeforsensordatawith8values giveninthetoprow.Theprobabilitiesaregiveninsmallletters. Thelowestbitratewhichwecanattainwiththesetypesofcodingcanbeobtained from the basics of information theory. When we send a message to somebody, who almostsurelyknowsbeforehandwhatthemessagewillbe,hereceives onlyverylittle information[2328].Whenwesendsomebodyamessage,whichhedoesnotexpectat all, he receives a lot of information. This basic aspect of the information content of a message can also be presented more formally. If we know beforehand that a message almostsurelywillbea,then‘a’isveryprobable,inotherwords,itsprobabilityP(a) ≈1. Ontheotherhand,theinformationcontentHofthemessagewillbeverysmall:

P( a) ≈1 ⇒ H(a) ≈0 Eq–4.4.1.1

Conversely, when we receive a message b with is very unlikely, p( b) ≈ 0, and its informationcontentisalmostinfinite.Or

P( b) ≈0 ⇒ H( b) →∞ Eq–4.4.1.2

Whenthereareonlytwoequallyprobablemessages aand b,withP( a)=P( b)=0.5, theanswertowhetherwereceived aor b providesuswith1bitofinformation:

P( a)=P( b)=0.5 ⇒ H( a)=H( b)=1bit Eq–4.4.1.3

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 53 Chapter–4FormationofYUV(YCbCr)&JPEGImage

Generalizing this concept, the information H( a) obtained when we receive a is definedas:

H( a) =2*logP( a) Eq–4.4.1.4

IfP( a)istheaprioriprobabilityofmessage a. Becauseoftheminussign, His a positivequantity,aswewouldexpect.Thisgivesusanewlookonthebitswearedaily _ dealingwith!Theaverageinformation H weobtainwhenwereceiveamessagecanbe calculatedasasumoverallpossiblemessages(ina given context) of the information associatedwitheachmessage,weightedbyitsaprioriprobability:

_ H = Σ PilogP i Eq–4.4.1.5

Theaverageinformation(expressedinbits)isalso called the entropy. As the entropyistheaverageinformationweobtainfromamessagewiththegivenprobabilities, itisthelowerboundontheaveragenumberofbitsweneedtoencodethesemessages, whentheencodingwouldbeoptimal.IntheHuffmancodewehavetodividethesetof outcomesinequallyprobablesubsets.Thisisonly possible in approximation, and the entropyisalowerboundforthebitratewecanobtainwiththeHuffmancode.Inthe exampletheaveragebitrateis2.53,theentropyis2.45,whichweshouldcomparetothe 3bitsneededwhenwewouldhaveencodedthemessagesstraightforwardly. Whensuccessivesensorvaluesarecorrelated,afurtherreductioninbitratecan be obtained. An example is the maximum daily temperature. The maximum of the temperaturetomorrowcanbeexpectedtobeclosetotoday'stemperature.Thedifference willmostprobablybeonlyafewdegrees[25–28].Inthatcaseitismoreefficientto codethetemperaturedifferencethatthetemperatureitself.Thisiscalleddecorrelation. Takeasanexamplesensordatathatmayhave256different,butequallyprobable values.Whenthesensordatareadingattimeiisk,thefollowingprobabilitiesaregiven:

P(s i+1 =k1|s i=k)=0.25 Eq–4.4.1.6

P(s i+1 =k|s i=k)=0.5 Eq–4.4.1.7

P(s i+1 =k+1|s i=k)=0.25 Eq–4.4.1.8

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 54 Chapter–4FormationofYUV(YCbCr)&JPEGImage

P(s i+1 =m|s i=k)=0for|mk|>1. Eq–4.4.1.9

This means that a certain amount of correlation exists between subsequent data values.Theentropyofthefirstvalueofourdatasequencewouldbe8bits(all256values beingequallyprobable).However,theentropyofeachnextsymbolisonly1.5bits.Soby encodingthedifference,weshrinkfrom8bitsto1.5bits. BesidestheHuffmancoding,otherentropybasedencoding schemes exist, one of whichisthe arithmetic coding. Animportantaspectisthatwehavetoknowbeforehand the probabilities of the possiblemessages[24–28].Whentheseprobabilitiesinrealitydeviatestronglyfromthe guessed or theoretical expected probabilities used to construct the code table, the encoding is still correct, though it will be far from optimal: we can even obtain an increaseinbitrateinsteadofareduction. AnotheraspectoftheHuffmancodeisthatisverysensitivetoerrors.Ifthereisan error in the transmission of the data, all codes following the error will be incorrect becausethesynchronizationbetweenencodinganddecodingislost.Thestartingpointof thenextcodewillbeaffected.Topreventthepropagationoferror,theHuffmancodes canbesentinblocksofncodes,sothatonlyoneblockisaffected,andthenextblocks arecorrectagain.

4.4.2 – LZW Coding Acodingmethodforwhichitisnotneededtoknowaprioriprobabilitiesisthe LempelZivWelchorbrieflyLZWcoding.IntheLZWtechnique,fixedlengthblocksof data (say of 8 Kbytes) are encoded and decoded, and the coding table is built simultaneouslyonbothsides.Itisnotnecessaryto transmit a coding table separately. TheLZWtechniqueexploitsthefactthatcertaincombinationsofsymbolsoccurmore frequently than others do. It discovers repetitions in the data and uses these in the encoding. Loosely speaking, the algorithm starts by transmitting the individual values, recordingallpairsofvaluesitencounteredandassigningadditionalcodestothem.As soon as it discovers a pair that it has come across before, the code of this pair is transmittedandthealgorithmstartsnowrecordingtripletsbeginningwiththisspecific pair.Theproceduregoesoninthisway,andwhenlongerrepeatingpatternsarepresent theyaresuccessivelyencoded.Onthedecodersidethesameprocesstakesplace.Based

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 55 Chapter–4FormationofYUV(YCbCr)&JPEGImage uponthereceivedsequence,thedecoderrecordsthepairsitencountersandassigns(the same)additionalcodestothem.Sowhenapairoccursasecondtime,thesystemknows thecodeandtheunderlyingcodedvalues. We will illustrate the LZW technique with the case that we want to transmit sensordatawith256differentvalues.Straightforwardlyencodedthatwouldcost8bits foreachvalue.Initiallythecodingtablesarefilledonthecodinganddecodingsidefrom entry0toentry255withthecodevalues0to255.Theentries256and257arereserved foraClearTablecodeandforaspecialEndofInformationcode.Thefirstfreeposition inthetableisentry258.Asaresultwestartwithtransmitting9bitsofinformation.As soonasentry510isoccupied,weswitchover to10bits codes. Similarly a switch is madeto11bitcodesafter1022,andsoon.Whenwereachtheendofthetable(e.g. 4095)aClearTablecodeistransmitted,andthewholeprocessstartsagainwith9bits codes. Theprocedureisrealizedbyconcatenationoftheincomingvaluesintostrings,as longastheconcatenatedstringsareinthecodetableandsoacodevalueexists.Ifthe stringisnotinthetableitshouldbeassignedanewcodevalue,andsoitisstoredinthe next free address in the table. The string without the last concatenation is the largest stringwecanencodeandsoitstableaddresses(codevalue)issendtotheoutput.We starttheprocedureofthestringconcatenationagainwiththelastinputvalue. ThisprocedureisillustratedinFigure7.2.1for a data block starting with the characters7,6,7,6,8,8,7,7,7,6,...... Whenwetakethefirstcharacter7whichisin the initial table at entry 7, we do nothing but initializing the string to 7. The next characteris6,andas7,6isnotpresentinthetablewestore7,6atposition258andoutput 7.Thenewstringissettothelastcharacter:6.Inputof7resultsin6,7whichisalsonot inthetable,therefore6,7isstoredatposition259,weoutputa6,andinitializethestring to7.Whenagaina6isreceived,7,6isinthetablesoweconcatenatethenextvalue whichis8.As7,6,8isnotinthetablewestorethatstringatposition260,output258 (codeof7,6)andinitializethestringto8.Thisprocessisexactlythesameatthedecoder side,exceptthatwenowhavetolookup258tofindthevalues7,6andtouseonlythe firstvalueintheconcatenationprocedure.ItcanbeseeninFigure7.2.1illustratingthe encoding:theoverlapbetweentwosuccessivelyencodedpartsisonly1value.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 56 Chapter–4FormationofYUV(YCbCr)&JPEGImage

Aspecialsituationoccurswhenweencodethenextpartofourdatablock7,7,7,6. Thepair7,7isnotinthetablesothisstringisstoredatposition262.Thenweencounter withthenext7again7,7whichisnowpresentinthetablesothereisnooutput,untilwe have the next 6 and we output 262. On the decoder side this looks like a problem, becauseacodeisreceivedthatwasnotconstructedinthedecoder.Asthissituationcan onlyoccurwhenthefirstcharacterofthepreviousstringisrepeated,thelastvalueofthe unknowncodeshouldbethesameasthefirstvalue of the previous code and can be constructed. LWZ Encoder

stored :258 259 260 261 262 263 264 address

7 6 7 6 8 8 7 7 7 6

code : 7 6 258 8 8 7 263 output

LWZ Decoder Received Code Table Value Table Address Decoded Output 7 7 6 7,6 258 6 258 6,7 259 7,6 8 7,6,8 260 8 8 8,8 261 8 7 8,7 262 7 263 7,7 263 7,7 Figure 4.4.2.1 →LWZencodinganddecodingofthesequence(7,6,7,6,8,8,7,7,7,6)

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 57 Chapter–4FormationofYUV(YCbCr)&JPEGImage

4.4.3 - Run encoding Acodingmethodspeciallysuitedforbinaryimages,likefaximages,isrunlength encoding.Theideaisthatpixelsdonotfliptheirvalueorcolorveryoftenifonewalks alongalineoftheimage[28].Itisthuswisetocodetheflipsofthepixelsinsteadofthe pixelvaluesthemselves. LetusseehowRunLengthcodingworksrun.Takea(horizontal)linefromthe image.Saythefirstpixelisblack.Nowwecountthenumberofblackpixelsontheline untilweencounterawhitepixel.Thisiscalledarun,andthenumberofpixelscountedis thelengthofthisrun.Thesamecanbedoneforthenextrunofwhitepixelsandthen againfortheblackpixelsetc.,untilthewholelinehasbeencoded.Theresultingcodefor alineisalistof{pixelvalue,runlength}pairswhichdescribethelineexactly. Ifwe agreethatalinealwaysstartswithawhitepixelwecaneliminatethepixelvaluesinthe listsothatthelistreducestoalistofonlyrunlengths. Note that this coding method becomesinefficientwhentheimagecontainsfrequentlyalternatingpixelvalues. Besides the run length coding, some other forms of run coding are used as illustratedinFigure4.4.3.1.Intherunpositioncodingthebeginpositionofeachrunis coded. Itisagainassumedthatthefirstruniswhite,andwhenthisisnotthecasean additionalfirstcode0isadded.Intherunposition/lengthencodingthebeginninglength ofoneruntypeisencoded.Theselasttworuncoding schemes are particularly useful whenthecodingiscombinedwithprocessingofrunencodedbinaryimages. Thetransmissionofafaxgoestwostepsfurther.First,thehistogramoftherun lengthsofa'typical'letterisshowninFigure4.4.3.1.Peaksinthehistogramcorrespond tothewidthofthepaper,theinterworddistanceandtheintercharacterdistance.Since theprobabilityoftherunlengthsisnotequalforallrunswecancodetherunlengths withaHuffmancoding.ButwithHuffmancodingwehavetotransmita'codebook'in whichatranslationisgivenwhichcoderesolvestowhichrunlength.Thesecondtrickis toassumethatfaxmessagesallhaveahistogram[25].Assumingthis,thecodebookof theHuffmancodingisequalforallfaxmessages,sothereisnoneedtotransmitthe codebookanymore,sinceitisknownbothatthetransmittersideandatthereceiverside.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 58 Chapter–4FormationofYUV(YCbCr)&JPEGImage

InpracticetheCCITTnorm,aninternationalstandard,hasdifferentcodebooksforthe background and for the foreground colors, since they have different runlength probabilities. Run-Length coding

4 4 4 20 16 Codedparameterisderunlength.Itisassumethatthefirstrunis Whenthefirstrunisblack →firstrun length

runposition coding

4 8 12 32 48 Codedparameteristhebeginpositionofarun.Firstrunblackresults firstposition=0

position and length coding

4 4 12 20 32 16 Codedparametersarethebeginandthelengthof oneruntype :theblack (orwhite)runs. Figure 4.4.3.1 →Differenttypesofruncoding.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 59 Chapter–5Results&Discussions

Chapter 5: Results & Discussions 5.1 Quantization of Images

Varioustestimageshavebeenquantizedtodifferentlevelsandtheoutputhas beendisplayed.Itmaybenoticedthattheimageswhichhavehigherquantizationlevels havegoodamountofinformationassociatedwiththembutthecompressionmaybevery less.Sothereneedsatradeoffinbetweenthequantizationlevelsandthequalityofthe image. Here three standard test images have been taken (lena.tif, cameraman.tif and rice.tif).AlloftheseimageshavebeenquantizedtothreedifferentlevelsQ10Q50Q90 andtheresultantimageshavebeenshown. The DCT (Discrete Cosine Transform) of the image is also shown. It may however be noticed from the image that after takingtheDCTofanimagethehigher frequencycomponentsandthelowerfrequencycomponentsoftheimageareseparated outandwecanthusdiscardthelowerfrequencycomponentssoastocompresstheimage asinJPEGimageformation. Itmaybenoticedfromtheresultsintables5.1.1–5.1.3thattheimageswhich havebeenquantizedtohigherlevelshavesomeinformationwhiletheimageswhichhave been quantized to the lower levels have the redundant or very less information. Thus thereneedstobeatradeoffinbetweenthequantizationlevelsandthequalityofimage. After the image has been quantized the tables 5.2.1 – 5.2.3 shows the image restoredaftertheapplyingtheinversequantizationordequantization.Itmaybeclearly seenthattheimageswhichwerequantizedtolowerlevelsarenotrestoreduptothemark andthereissomeredundancyinthefinalimageobtained.Whiletheimagesrestoredafter dequantizationofhigherleverquantizedimages,thereisverylessredundantinformation inthem. InthesimilarwaywequantizetheCbandCrcomponentsuptoverylowlevelof degree(Highlosslesscompression)asbothofthesecomponentsdon’taddtothequality ofimage.TheCbandCrcomponentarelessvisibletotheimageandthusaddsonlyto thecolorofimagesotheycanbesuppressedtothehigherlevelofdegree.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 60 Chapter–5Results&Discussions

Table 5.1.1 – The DCT & Quantized Image (Lena.tif) Original Image Transformed Image

DCT Image

Quantized Image Q10

Quantized Image Q50 OriginalImage

Quantized Image Q90

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 61 Chapter–5Results&Discussions

Table 5.1.2 – The DCT & Quantized Image (Cameraman.tif) Original Image Transformed Image

DCTImage

Quantized ImageQ 10

Quantized ImageQ 50 OriginalImage

Quantized ImageQ 90

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 62 Chapter–5Results&Discussions

Table 5.1.3 – The DCT & Quantized Image (Rice.tif) Original Image Transformed image

DCTImage

Quantized ImageQ 10

Quantized ImageQ 50

Quantized ImageQ 90

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 63 Chapter–5Results&Discussions

5.2 - Recovered Image

Theimagerecoveredafterthedequantizationoftheimagesisshownhereunder. ThePSNR(PeakSignaltoNoiseRatio)isalsocalculated.Comparingtheoriginalimage withtherestoredone.

5.2.1 - PSNR Calculation (Quantized Images)  Max (Orignial image ) 2  PSNR = 10 * log    MSE 

M N 2 Eq.–5.2.1.1 ∑ ∑ []I (x, y) − Iˆ(x, y) MSE = x=1y = 1 NM Where: I(x, y) = Original Image Iˆ(x, y) = Transformed Image M , N = DimensionsOf Image

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 64 Chapter–5Results&Discussions

Table 5.2.1 – De-quantized and IDCT Image (Lena.tif) Original Image Recovered Image PSNR

3.7508

Restorationat10%

5.8102

Restorationat50%

6.9812

Restorationat90%

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 65 Chapter–5Results&Discussions

Table 5.2.2– De-quantized and IDCT Image (Cameraman.tif) Original Image Recovered Image PSNR

3.3853

Restorationat10%

5.7028

Restorationat50%

6.9127

Restorationat90%

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 66 Chapter–5Results&Discussions

Table 5.2.3– De-quantized and IDCT Image (Rice.tif) Original Image Recovered Image PSNR

5.8093

Restorationat10%

6.8308

Restorationat50%

8.1267

Restorationat90%

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 67 Chapter–5Results&Discussions

5.3 - Decoder Output (YUV Image) 400 Format (Y – Component Only)

Figure 5.3.1 – 400 Format (Y – Component Only) 420 Format (Y- Component)

Figure 5.3.3 – 420 Format (Y – Component) FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 68 Chapter–5Results&Discussions

420 Format (U - Component)

Figure 5.3.3 – 420 Format (U – Component) 420 Format (V - Component)

Figure 5.3.3 – 420 Format (V – Component) FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 69 Chapter–5Results&Discussions

422 Format (YCbCr Image)

Figure 5.3.5 – 422 Format (YCbCr Image) 422 Format (Y Component)

Figure 5.3.6 – 422 Format (Y – Component)

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 70 Chapter–5Results&Discussions

422 Format (U Component)

Figure 5.3.7 – 422 Format (U – Component) 422 Format (V Component)

Figure 5.3.8 – 422 Format (V – Component) FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 71 Chapter–5Results&Discussions

444 Format (YCbCr Image)

Figure 5.3.9 – 444 Format (YCbCr Image) 444 Format (Y Component)

Figure 5.3.10 – 444 Format (Y - Component)

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 72 Chapter–5Results&Discussions

444 Format (U Component)

Figure 5.3.11 – 444 Format (U - Component) 444 Format (V Component)

Figure 5.3.12 – 444 Format (V - Component) FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 73 Chapter–5Results&Discussions

RGB16 Format (Original Image)

Figure 5.3.13 – RGB16 Format (Original Image) RGB16 Format (Y Component)

Figure 5.3.14 – RGB16 Format (Y - Component)

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 74 Chapter–5Results&Discussions

RGB16 Format (U Component)

Figure 5.3.15 – RGB16 Format (U - Component) RGB16 (V Component)

Figure 5.3.16 – RGB16 Format (V – Component)

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 75 Chapter–5Results&Discussions

5.3.1 - PSNR & Its Calculation (YUV Images) TocalculatethePeakSignaltoNoiseRatio(PSNR)weusetheformula:  Max (Orignial image ) 2  PSNR = 10 * log    MSE  M N 2 ∑ ∑ []I (x, y) − Iˆ(x, y) MSE = x=1y = 1 NM Where: I(x, y) = Original Image Iˆ(x, y) = Transformed Image M , N = DimensionsOf Image Here we took two standard test images (Lena & Airplane) in RGB and JPEG format. First of all we convert the RGB image into YUV Format with the help of DecoderandthenweconverttheJPEGfileofthesameimageandconvertitintoYUV format.ThenwecalculatethePSNRfrombothofthesefiles.Wealsocalculatetheno.of cycles(CPUClockcycles)requiredtodecodeanimage.Thisisdeterminedbyatool namedas“ARM”Processorwhichtellsusabouttheno.ofcyclesrequiredforthewhole process.TheResultsthusreceivedareasshowninTable5.3.1–5.3.3.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 76 Chapter–5Results&Discussions

Table 5.3.1 Filename: airplane (512 x 512, ARM Processor) Input Image Encode Quality Cycles Used PSNR Format Format Factor 400 400 5 32953396 49.897975 400 400 100 32953718 49.897975 400 400 1000 32953877 49.897975 420 400 5 33085261 49.897975 420 400 100 33085583 49.897975 420 400 1000 33085742 49.897975 Y 49.897975 420 420 5 47436657 Cb 50.036000 Cr 50.023174 Y 49.897975 420 420 100 47436979 Cb 50.036000 Cr 50.023174 Y 49.897975 420 420 1000 47437138 Cb 50.036000 Cr 50.023174 422 400 5 33221200 49.897975 422 400 100 33221522 49.897975 422 400 1000 33221681 49.897975 Y 49.897975 422 420 5 46896407 Cb 41.261183 Cr 40.715854 Y 49.897975 422 420 100 46896729 Cb 41.261183 Cr 40.715854 Y 49.897975 422 420 1000 46896888 Cb 41.261183 Cr 40.715854 Y 49.897975 422 422 5 61024768 Cb 50.031224 Cr 50.008190 Y 49.897975 422 422 100 61025090 Cb 50.031224 Cr 50.008190 Y 49.897975 422 422 1000 61025249 Cb 50.031224 Cr 50.008190

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 77 Chapter–5Results&Discussions

Table 5.3.3 Filename: Baboon (512 x 512, ARM Processor)

Encode Quality Cycles Image Format PSNR Format Factor Used 400 400 5 34155923 49.863668 400 400 100 34156241 49.863668 400 400 1000 34156403 49.863668 420 400 5 34287788 49.863668 420 400 100 34288106 49.863668 420 400 1000 34288268 49.863668 Y 49.863668 420 420 5 49195710 Cb 49.943581 Cr 49.885723 Y 49.863668 420 420 100 49196028 Cb 49.943581 Cr 49.885723 Y 49.863668 420 420 1000 49196190 Cb 49.943581 Cr 49.885723 422 400 5 34423727 49.863668 422 400 100 34424045 49.863668 422 400 1000 34424207 49.863668 Y 49.863668 422 420 5 48825577 Cb 42.696632 Cr 42.307690 Y 49.863668 422 420 100 48825895 Cb 42.696632 Cr 42.307690 Y 49.863668 422 420 1000 48826057 Cb 42.696632 Cr 42.307690 Y 49.863668 422 422 5 63775168 Cb 49.926413 Cr 49.902282 Y 49.863668 422 422 100 63775486 Cb 49.926413 Cr 49.902282 Y 49.863668 422 422 1000 63775648 Cb 49.926413 Cr 49.902282

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 78 Chapter–5Results&Discussions

Table 5.3.3 File Size after the formation of YUV images Original ImageName Quality Image Transformed %Size (JPEG) (WidthxHeight) Factor Format (YUV)Size Reduced Size Lena.jpg(512x512) 655KB 5 400 232KB 64.58 Lena.jpg(512x512) 655KB 10 400 232KB 64.58 Lena.jpg(512x512) 655KB 50 400 232KB 64.58 Lena.jpg(512x512) 655KB 90 400 232KB 64.58 Lena.jpg(512x512) 655KB 5 420 356KB 45.65 Lena.jpg(512x512) 655KB 10 420 359KB 45.19 Lena.jpg(512x512) 655KB 50 420 364KB 44.43 Lena.jpg(512x512) 655KB 90 420 368KB 43.82 Lena.jpg(512x512) 655KB 5 422 415KB 36.64 Lena.jpg(512x512) 655KB 10 422 418KB 36.18 Lena.jpg(512x512) 655KB 50 422 422KB 35.57 Lena.jpg(512x512) 655KB 90 422 425KB 35.11 Lena.jpg(512x512) 655KB 5 444 555KB 15.27 Lena.jpg(512x512) 655KB 10 444 559KB 14.66 Lena.jpg(512x512) 655KB 50 444 562KB 14.20 Lena.jpg(512x512) 655KB 90 444 582KB 11.15 Baboon.jpg(512x512) 734KB 5 400 285KB 61.17 Baboon.jpg(512x512) 734KB 10 400 285KB 61.17 Baboon.jpg(512x512) 734KB 50 400 285KB 61.17 Baboon.jpg(512x512) 734KB 90 400 285KB 61.17 Baboon.jpg(512x512) 734KB 5 420 396KB 46.05 Baboon.jpg(512x512) 734KB 10 420 402KB 45.23 Baboon.jpg(512x512) 734KB 50 420 410KB 44.14 Baboon.jpg(512x512) 734KB 90 420 414KB 43.60 Baboon.jpg(512x512) 734KB 5 422 501KB 31.74 Baboon.jpg(512x512) 734KB 10 422 506KB 31.06 Baboon.jpg(512x512) 734KB 50 422 510KB 30.52 Baboon.jpg(512x512) 734KB 90 422 515KB 29.84 Baboon.jpg(512x512) 734KB 5 444 594KB 19.07 Baboon.jpg(512x512) 734KB 10 444 600KB 18.26 Baboon.jpg(512x512) 734KB 50 444 609KB 17.03 Baboon.jpg(512x512) 734KB 90 444 617KB 15.94 The above table shows the original size of the JPEGimageandthesizeofthe YUVimageformedafterthedecodingprocess.ItcanthusbeclearlyseenthattheYUV formatreducesthesize oftheimage.Withthedifferent quality factor the size of the imagevaries.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 79 Chapter–5Results&Discussions

5.4 - Discussion(s) FromtheabovetablesandresultsitisverifiedthattheYUVimagesoformedis havingaverylesssizethantheoriginalJPEGimage. But there needs to be trade off betweentheimagequalityandthesizeoftheimage.Ithasbeennoticedthatthe400 format have very small image size which is due to the reason that there is no color component(Chrominance)componentinit.Thisisthereasonthatthereisnochangein theimagesizeduetothechangeinqualityfactorfor400Images. Itcanalsobeseenfromtables5.3.1–5.3.3thatthenumberofcyclesrequiredto decode the 400 image is less than the number of cycles to decode the 420 and 422 images.Thisisduetothereasonthatmoreprocessingisrequiredwhilewearedecoding thechromacomponents. Theimagessoreceivedshouldhaveagoodtradeoffwiththeimageperception andthequalityfactor.Thequalityfactorneedstobemaintainedinsuchafashionsothat thequalityofimageisgoodinrespecttotheHumanvisionperception. So, YUV formats are definitely going to revolutionize the way images are transmittedoverthelowbandwidthchannels.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 80 Conclusion(s) Conclusion(s)

FromthispieceofworkwecanconcludethattransformationofJPEGimageinto itsequivalentYCbCrimage,notonlyrequireslessamountofdatatobestoredbutitcan also provide us very high compression rates. The Chroma components are very less sensitivetotheeyesandhenceapplyingmorelosslesscodingonthechromacomponents wecancompressimagesuptoverylowsize.Thiscompressedimagewhencheckedwith the human Perception of image vision will come nearly equal to the standard JPEG image.

TheapplicationsoftheYUVimagesaremainlytothewebapplications,asnow days more and more people are using the internet with multimedia and images with smallersizewillleadtolessbandwidthrequirementaswellaslessstorage.

In the end we can conclude that the YCbCr image format is going to be the revolutionaryimageformatinthecomingtime.Notonlytheimagesarebeingdecodedin this format the video files specially MPEG – 4 Part 2 is being converted in YUV Formatsinordertocompetewiththebandwidthrequirementsofthepresentindustries.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 81 References References [1] Digital Compression and Coding of ContinuousTone Still Images, Part 1, RequirementsandGuidelines.ISO/IECJTC1CommitteeDraft109181, Feb. 1991. [2] Digital Compression and Coding of ContinuousTone Still images, Part 2, ComplianceTesting.ISO/IECJTCICommitteeDraft109182.l~bepublished Summer1991. [3] http://exchange.manifold.net/manifold/manuals/manifold/images/rgb_images_an d_channels.htm. [4] Office Document Architecture (ODA) and Interchange Format, Part 7: Raster GraphicsContentArchitectures. ISO/IECJTC1InternationalStandard86137 1994. [5] Pennebaker, W.B., JPEG Tech. Specification, Revision 8. Informal working paperJPEG8R8,1990. [6] Pennebaker, W.B., Mitchell, J.L., et. At. Arithmetic coding articles. *IBM J. Res.Dev.32,6SpecialIssuespp717774,1988. [7] K. R. Rao, P. Yip, Discrete cosine transform: algorithms, advantages, applications,AcademicPressProfessional,Inc.,SanDiego,CA,1990 [8] Wallace, G.K. Overview of the JPEG (ISO/CCITT) still image compression standard.ImageProcessingAlgorithmsandTechniques.InProceedingsofthe SPIE,VOL.1244,pp.220233,1990. [9] Wallace, G., Vivian, R., and Poulsen, H. Subjective testing results for still picture compression algorithms for international standardization. In Proceedings of the IEEE Global Telecommunications Conference, IEEE CommunicationsSociety,pp10221027,1988. [10] D. Salmon, “Data Compression, the Complete Reference,” SpringerVerlag, NY:NewYork,pp.101162,1998. [11] P.G.HowardandJ.S.Vitter,“DesignandAnalysisofFastTextCompression Based on QuasiArithmetic Coding,” Proceedings of the IEEE Data CompressionConference(DCC'93),Snowbird,UT,1993.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 82 References [12] www.eee.manchester.ac.uk/intranet/ug/coursematerial/2nd%20Year/EE2034 Programming%20II/Lecture01.pdf [13] Benson,K.Blair,TelevisionEngineeringHandbook.McGrawHill,Inc.,1986. [14] Devereux,V.G.,1987,LimitingofYUVdigitalvideosignals,BBCResearch DepartmentReportBBCRDpp22,1987. [15] EIAStandardEIA189A,EncodedColorbarSignal,1976. [16] Faroudja, Yves Charles, NTSC and Beyond. IEEE Transactions on Consumer Electronics,VOL.34,No.1,1988. [17] ITURBT.601–5,1995,StudioEncodingParametersofDigitalTelevisionfor Standard4:3andWidescreen16:9AspectRatios1996. [18] ITURBT.709–4,ParameterValuesfortheHDTVStandardsforProductionand InternationalProgrammerExchange,2000. [19] Photo CD Information Bulletin, Fully Utilizing Photo CD Images–PhotoYCC ColorEncodingandCompressionSchemes,EastmanKodakCompany,1994. [20] Wang,Q.andWard,R.K.,“ANewOrientationAdaptiveInterpolationMethod for JPEG Image Formation,” IEEE Trans. On Image Processing, accepted , 2005. [21] Pourazad, M.T., Nasiopoulos, P., Ward, R.K., “An H.264Based Video Encoding Scheme for 3D TV,” 14th European Signal Processing Conference Florence,Italy,accepted,2002. [22] VideoDemystifiedAHandbookfortheDigitalEngineerThirdEditionbyKeith JackbyKeithJack,LLHTechnologyPublishingandEagleRockVA2001. [23] http://www.cnet.com/Resources/Info/Glossary/Terms/progressivejpeg.html [24] BrianA.Wandell,FoundationofVision,StanfordUniversity,pp199206,1995. [25] AllenB.Poirson&BrianA.Wandell,Patterncolorseparablepathwayspredict sensitivitytosimpledcoloredpatterns,VisionResearch,1995. [26] Marcus J. Nadenau & Julien Reichel, Opponent Color, Human Vision and WaveletsforImageCompression. http://dewww.epfl.ch/~reichel/Publication/CIC99.pdf [27] DavidS.Taubman&MichaelW.Marcellin,JPEG2000Image Compression FundamentalsStandardsandPractices,KluwerAcademicPublishers,2002.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 83 References [28] William B. Pennebaker & Joann L. Mitchell, Jpeg Image Data Compression Standard,VanNostrandReinhold,1993. [29] JPEG Still Image Compression Standard. William B. Pennebaker, Joan L. Mitchaell,VanNostrandReinhold,1993. [30] TheJPEGstillpicturecompressionstandard.CommunicationsoftheACM.G. K.Wallace,1991. [31] Aldus Developers Desk, TIFF Tag Image File Format Revision 6.0. Aldus Corporation,SeattleWA,1992. [32] WallaceG.K.,TheJPEGstillpicturecompressionstandard,Communicationsof theACM,,VOL34,no.4,pp3144,1991.

FormationofYUV(YCbCr)ImageFromJPEGData AnshumanGoyal–8044106([email protected]) HCLTechnologies,A5Sector–24,Noida. 84