A Matlab Playground for the JPEG Standard.docx
- 文档编号:8904351
- 上传时间:2023-02-02
- 格式:DOCX
- 页数:8
- 大小:74.32KB
A Matlab Playground for the JPEG Standard.docx
《A Matlab Playground for the JPEG Standard.docx》由会员分享,可在线阅读,更多相关《A Matlab Playground for the JPEG Standard.docx(8页珍藏版)》请在冰豆网上搜索。
AMatlabPlaygroundfortheJPEGStandard
Kolev,Nikolay
Pekarske,Andrew
ECE533
FinalProjectReport
12/12/03
NikolayandAndrewPresent:
AMatlabPlaygroundfortheJPEGStandard
Introduction:
ThegoalofthisprojectistoprovidemoreuseroptionsfortheJPEGEncoderprovidedbyProfessorHuforMatlab,exploredifferentlosslesscompressionapproachesandfrequencytransformperformanceapplicabletotheJPEGstandard,aswellasprovideacorrespondingJPEGDecodercomplementingProf.Hu’sJPEGdecoder.TheMatlabcodefromthisprojectisthoroughlycommentedandlaidoutinorganizedwaysothatanyonefamiliarwithMatlabcouldunderstandwhatistakingplaceintheprogram.Thisprojectintroducesthefollowinguserrun-timeoptionstotheJPEGDecoder/Encoderpair,whichwouldaidothersinunderstandingandlearningoftheJPEGstandardanditsrelatedconcepts.
RuntimeJPEGOptions:
1.ImageSelection:
a)p64int.txt(64x64)
b)Samplefrom8.28(8x8)
c)Zelda(128x128)
d)Barbara(256x256)
e)Lena(512x512)
2.TransformSelection
a)DCT(discretecosinetransform)
b)FFT(fastfouriertransform)
3.QuantizationMatrix
a)Samplefrom8.37
b)CompressionRation=8forSNM_Quantizer
4.EncodingMethod
a)Huffman
b)Arithmetic
Themotivationforthisprojectwastwofold.ThefirstistocreateawaytolearnmoreabouttheJPEGandtheoreticalandtechnicalimplementationofalgorithmsthatsuccessfullycompressinganimageandalsohelpotherstudentsorreadersinterestedinthisfieldtolearnactively.ThesecondreasonforundertakingthisprojectwastohavefunprogrammingandtolearnmoreaboutMatlab.
Approach:
Westartedtheprojectbycarryingoutresearchonlineandinseverallibraries.UsingtheUW-MadisonLibraryJournalsdatabasewesearchedthrougholdIEEEjournalslookingforpapersrelatedtoJPEGStandard(notJPEG2000)optimizations.Aspecificareaofinterestwehadwasadjustableoradaptablequantizationmatrixgeneration.WeinitiallylookedattheWUBAalgorithmbutdeemedittoocomplexforthescopeoftheproject.LaterwefoundapaperbyB.G.Sherlock,A.NagpalandD.MMonrocalled“AModelforJPEGQuantization”whichwasfeaturedinthe1994InternationalSymposiumonSpeech,ImageProcessingandNeuralNetworks(13-16April1994,HongKong).WedecidedtocallourimplementationofthismodelSNM_Quantizeraftertheauthorsofthepaper.
OncewehadoneruntimeoptionfortheJPEGencoderwestarteddiscussingotherfeaturesoftheJPEGstandardthatwewereinterestedinmodifying,likethediscretecosinetransform,Huffmanencoder,andblocksizes.Althoughchangingblockprocessingsizewaslaterdroppedduetotimeconcernsandcomplexityofparameterizingallofoursourcecode,itwasdecidedtoaddauniqueimplementationofarithmeticencoding,amethodforgeneratingpossiblyadaptivequantizationmatrix,aswellasusinganalternativetransformsuchasFourier.
TherealsowastheadditionaltaskofcreatingacorrespondingJPEGdecoderforthenewandoriginaloptionsoftheJPEGencoder.Someofthecodingforthedecoderonlyinvolveddoingtheexactsameoperationsdoneintheencoderbutcarryingthemoutinreverseorder.Butalargeportionofthecodinginthedecoderhoweverwasslightlymorecomplexthanthis,andprovedtobeagoodchallenge.
TasksPerformed:
ThelayoutoftheencoderanddecoderMatlabcodeissuchthattheyorganizedinseparatedirectoriesandoutputfilestoashareddirectory.Thispromotesthetruenatureofencodinganddecodingimagesbyforcingthedecodertorunonlyfromtheencodedvaluesoutputbytheencoder.Ifbothencoderanddecoderwereinthesamefile,certainvaluescouldbereusedinthedecoderthatcouldonlybemadeintheencoderbyhavingtheoriginalinputimage.ThereforewhentestingtheperformanceofdifferentJPEGalgorithms,onemustfirstruntheJPEGencoder(jpegencode)intheJPEG_EncoderdirectoryandthentodecodethatencodedimageonemustopentheJPEG_DecoderdirectoryandruntheJPEGdecoder(jpegdecode).
ThisprojectbeganbyexaminingtheEncoderanditsrelatedmodulesprovidedbyprofessorHu.Afterintenselystudyingtheencoderwewereabletostartworkondevelopingthedecoder,andspecificallytheHuffmandecoding,whichprovedtobeconsiderablytimeconsuming.WhiletheHuffmandecoderwasbeingdesigned,anarithmeticencoderanddecoderweremadetomakeuseoftheMatlabsuppliedarithencoandarithdecomodules.Afterwardtheunzig-zagandinversequantizerandtransformcodewasfinished.
DuringthetestingphaseitwasfoundthatthearithmeticencodingasdesignedhadfilesizesthatwerequitelargewhencomparedtoHuffmanencoding.ThedecisionwasmadetoaddEOBsymbolstothisencodingwhicheventuallymadetheencodedfilesizesrelativelycomparable.
Onceallthemoduleswerecompletelycoded,changesandrefinementstotheuserinterfacewereintroduced.Thisallowedtheusertoeasilyselectwhichtransform,quantizationmatrix,image,andencodingmethodistobeused.Inthefinalstage,codewasaddedattheendofthedecodertoaidthevisualcomparisonbetweentheoriginalandcompressedimages.
Results&Discussion(TransformSelection):
ThepurposeofthetransforminaJPEGstandardistoeliminatehighfrequenciescomponentsinanimage,whichareinpracticenotessentialforimagequalitybecausetheyaregenerallynotwelldiscernedbythehumaneye.Thisstepattemptstopackasmuchinformationaspossibleinaslittlespaceaspossible.Tothiseffect,accordingtoGonzalez&Woods,theperformanceofDCTissuperiortothatofFouriertransform.
TheresultsfromtheactualJPEGcodehoweverproducedaresultthatwasslightlyinconsistent.Thisisaknownunder-exploredareaoftheprojectaswewereunabletogetthealternateFFTworkingtoproduceavalidoutputimage.Somevisualresultsfollowbelow:
Original
DCT
FFT
Results&Discussion(QuantizationMatrixSelection):
UsingHuffmanencoding,theDCT,andimages0through4weobtainedthefollowingcompressedimagesizeswithdifferentquantizationmatrices.
InherenttotheJPEGStandard,quantizationisthelossystatethatdoescertainportionofthecompression.Thelargerthevaluesinthequantizationmatrix,themoreinformationisremovedwhichinturnresultsinsmallercompressedfiles/coefficientruns.IngeneralwhentheSNM_Quantizerisusedatacompressionratioof8,thequantizationvaluesarelargerthanthoseofthedefaultquantizationmatrix.Aftertheimageissentthroughatransformandzig-zagordered,themajorityofthe“valuable”imageinformationispackedintheupper-rightcorneroftheprocessedblock.Ifthevaluesofthequantizationmatrixarelargerthanthevaluesintheprocessedblockatthepointwhenthequantizationoccurs,thevaluesintheprocessedblockaresetto0(retainingonlytheintegerpartoftheresult),effectivelyremovingcoefficientsofsmallmagnitude.Whentherearemorezeroes,thesizeoftherunlengthofzeroesincreasesandanEOBsymbolcouldbeusedtorepresentthem,whichyieldsremarkabledatacompression(describedintheencodingselectionsectionbelow).
Ontheotherside,removinginformationfromtheoriginalimageinordertoreducethesizeoftransmittedencodedimagealsomightdrasticallyreducethequalityoftheimageandmakesitappearmore“blocky”.Therefore,dependingupontheapplicationforwhattheencodedimagesareneededfor,onemightneedtoevaluatethetrade-offbetweenimagequalityorlowerfilesizes–smallerimagesizespeedsuptransmissionalongbandwidthconstrainedchannels.
Iftimepermitted,itwouldhavebeeninterestingtoaddadditionalquantizationmatrices,orevenanimage-adaptivequantizationmatrixgenerator.Thiswouldprovidetheoptimalquantizationmatrixforeveryprocessedblockoftheimage,maintaininghighvisualquality,whilealsodrivingdownthefilesize.
BelowarethreeimagesoftheeyeofLenawithdifferentquantizationmatricesselected.Thereissomenoticeabledifferencebetweentheoriginalandthedefaultquantizationmatrixasthewhiteintheeyeappearsslightlygrainier.OnecouldnoticedefinitelymoregraininessintheresultproducedwiththeSNMquantizationmatrix.
Original
DefaultQuantizationMatrix
SNMQuantizationMatrix
Results&Discussion(EncodingSelection):
UsingthedefaultquantizationmatrixandtheDCTforencodingimages0through4weobtainedthefollowingcompressedimagesizeswithdifferentencodingmethods.
(*Sizedoesnotincludeadditionaloverheadfilesnecessaryfordecoding)
ItisclearlyshownthatourspecialimplementationoftheArithmeticEncodingAlgorithmistypicallynotasefficientastheHuffmanEncodingalgorithm.Atfirstglancethisdoesnotseemtomakeanysense,asarithmeticencodingtypicallydoesabetterjobofreachingacompressionthatiscomparablewithasequence’sentropy.Therearehowever,severalfactorsthatcomeintoplaythataffecttheresultsfromthisMatlabfile.
Firstitisimportanttonotethatadifferenceintransform,orquantizationmatrixwouldaffectthesizeofrunlengthsofzerosthataparticularimagemighthaveafterblockprocessingtheimagewithaparticulartransformandthenquantizingit.Bothencodingmethodshandlerunlengthsimilarlysuchthatwhenablockof64valueshasnomorepositivevalues(onlyzerosremain),anEOB(endofblock)symbolisinsertedintothesequencetobeencoded.TheonlydifferencebetweenthetwoisthatHuffmanusesadefaultvalueof999foranEOBsymbol,whileArithmetictakestheadaptiveapproachbysettingitsEOBsymboltooneplusthemaximumvalueinthesequence.Thearithmeticencodingchoosesthisi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab Playground for the JPEG Standard