北邮国院视频图像处理Word文件下载.docx
《北邮国院视频图像处理Word文件下载.docx》由会员分享,可在线阅读,更多相关《北邮国院视频图像处理Word文件下载.docx(29页珍藏版)》请在冰点文库上搜索。
PortableGreyMap."
Thename"
PPM"
istheacronymfor"
PortablePixelMap."
Imagesinthisformat(oraprecursorofit)wereoncealsocalled"
portablepixmaps."
Itisahighlyredundantformat,andcontainsalotofinformationthattheHumanVisualSystem(HVS)cannotevendiscern.However,asPGM,PPMisveryeasytowriteandanalyze.Thegoalofthefirstpartoftoday’slabistoletstudentsbecomecomfortablewiththesetwoformats.
YouwillimplementfunctionstoreadandtowritePPMandPGMimages.Thefinaldemonstrationoftheimplementedsoftwarewillbedoneusingwell-knowntestimages:
LENA,BABOON,PEPPERS,etc.YoucanfindPPMandPGMversionsoftheseimagesintheEBU723Uintranetpages.Thewritingfunctionmustaddascommentintheheader:
“imagecreatedbyyour_nameyour_surname”.
Includeinyoursubmissionthefileresultingfromreadingtheimagesprovidedandwritingthembackintheiroriginalformat.
Summarizein5pointstheoperationsnecessarytoreadaPGM/PPMimage:
1.Opentheimageinreadmode.
2.Ignorecommentsinthefile
3.DistinguishtheimageisaPGMorPPM.
4.Readinformationoftheimage.
5.Readmatrix.
Summarizein5pointstheoperationsnecessarytowriteaPGM/PPMimage:
1.Opentheimageinwritemode.
2.Writecommentsinthefile.
3.DecidewrittingaPGMorPPMimage.
4.Writeinformationoftheimage.
5.Writematrix.
WhatisthedifferencebetweentheidentifierP3andP6?
ForidentifierP3,theimageisstoredasASCIIandeachlineislessthan70characters.
ForidentifierP6,theimageisstoredasbinary.
P6formatissmallerthanP3formatandreadP6formatfileisfasterthanP3formatfile.
Exercise1(b)
Formatconversions:
inthispartofthelab,theimageswillbeconvertedfromcolourtogreyscale;
inotherwordsaPPMimagewillbeconvertedtothePGMformat.Youwillimplementafunctioncalled“BUPT_format_converter”whichtransformsimagesfromcolortogrey-scaleusingthefollowingYUVconversion:
Y=0.257R+0.504G+0.098B+16
U=0.439R+0.368G–0.071B+128
V=-0.148R–0.291G+0.439B+128
Whatcomponentrepresentstheluminance,i.e.thegrey-levels,ofanimage?
Yrepresentstheluminance.
Usetheeboxestodisplaytheresultsforthecolourtogrey-scaleconversion.
Lenacolour(RGB)
Lenagrey
Baboongrey
Babooncolour(RGB)
Isthetransformationbetweenthetwocolour-spaceslinear?
Motivateyouranswer
Thetransformationbetweenthetwocolour-spacesislinear.
Transformeachlayer,thencombineeachoutcome.OrTransformlayerstogether.Thesetwooutcomesaresame.
f(ax+by)=af(x)+bf(y)
DisplayintheboxtheLenaimageconvertedtoYUV3channelsformat.
Arethecolorsofthepreviouspicturedistorted?
Ifyeswhy?
Theyaredifferent.BecauseRGBusedforPCandYUVusedforTV.IfweshowYUVimageonPC,itwillbedistorted.
BasedontheformulafortheRGBtoYUVconversion,derivetheformulafortheYUVtoRGBconversion?
R=1.164*(Y-16)+1.596*(V-128)
G=1.164*(Y-16)-0.813*(V-128)-0.391*(U-128)
B=1.164*(Y-16)+2.018*(U-128)
UsetheformulayouderivedattheprevioussteptoconverttheYUVimagebacktotheoriginalRGBformat.Displaytheresultinthebox.
Exercise1(c)
Sub-sampling:
TheHVSisincapableofperceivingcertaindetailsinanimage.ThereforehighcompressionratioscanbeachievedbyexploitingthecharacteristicsoftheHVS,thusdiscardingwhathasalowvisualrelevance.However,thisprocesscanintroducedistortionsinthecompresseddata.AsimplewaytoexploitthecharacteristicsoftheHVScompressionpurposesistosub-sampleanimage.Adrawbackofthisapproachisthatitispossibletoincurinwell-knowproblemsofadiscreterepresentation,suchasaliasing.Thispartofthelabcoverssomesimplesub-samplingoperations.
Implementafunctionthatsub-samplesgreylevelimagesbyafactorn,withnamultipleof2.Thefunctionshouldbeabletosub-sampleindependentlyinthehorizontalandintheverticaldirectionorinbothdirectionsatthesametime.
Displaytheresultsofsub-samplingtheimageLenausingthefollowingfactors:
2horizontal,2vertical,2verticaland8horizontal,4verticaland4horizontal.Includethefilesoftheresultsinthesubmission.
Boxforthe4images
2horizontal
2vertical
2verticaland8horizontal
4verticaland4horizontal
Describeusingyourownwordsthealiasingproblemandhowtoavoidit,asappliedtosignalprocessing
Aliasingoccurswhenthesamplefrequencyisnothighenoughsothatathesampledsignalcannotrepresentatheoriginalasignals,liketheblurofimageedgesandapitchchangesaofmusic.
Toavoidit,weshouldchooseathesamplefrequencymorethantwiceofhighestfrequencyofsignalaccordingtoNyquistsampleatheory.Forpracticalasolutions,wealwaysincreasesamplefrequencyordecreasehighestsignalfrequency.
Givenascenesampledbyaccdwithminimumhorizontalsamplingfrequency10cm-1,whatisthemaximumhorizontalfrequencyintheimagethatcanbecorrectlyrepresented?
Fs=10cm-1
Fs=2*Fmax
SoFmax=5cm-1
Ifyousub-sampleanimage,whydoyouhavemoreproblemsrelatedtoaliasing?
Whenweadothis,thepixelsaareareduced.Asaresult,theresolutionaaredecresed.
Pastebelowaclearexampleofartifactsgeneratedbyaliasing.Forthistaskyoucanuseyourownchoiceofimage.Usetheboxbelowfortheimageandcomments.
4verticaland2horizontal
Exercise2(a)
Quantize:
Quantizationistheprocessofapproximatingthecontinuousvaluesintheimagedatawithafinitesetofdiscretevalues.Theinputofaquantizeristheoriginaldataandtheoutputisoneamongthefinitenumberoflevels.Thisprocessisanapproximation,andagoodquantizerisonewhichrepresentstheoriginalsignalwithminimumloss(quantizationerror).Inthislab,youwillworkwithascalaruniformquantizerappliedtogrey-scaleimages.
Lena,quantizationfactor2
Baboon,quantizationfactor8
Implementafunctionthatuniformlyquantizesgreylevelimages.Thefunctionwillallowthereductionofthenumberofgreylevelvaluesbyagivenfactorn(apowerof2).
Note.Tovisualizetheimage,youneedtore-mapitinthe8-bit-per-pixelrepresentation.Showtheresultsintheboxesbelow.
Peppers,quantizationfactor128
Peppers,quantizationfactor32
Usethegivenspacesforyouranswers.Donotextendthespacesorchangethefont-size.Page13
Isquantizationareversibleprocess?
Canyourecoverwhatyoudiscarded?
Brieflyexplain.
No,forthequantizationprocess,somecolourlevelarereducedandwecannotagetthembackbecauseweadonotknowwhichapixeldoweachangeintonearcolour.
WritetheresultsbacktoPGM/PPMfilesusingthefunctionyoucreated.Makesurethatyourwritingfunctionallocatesacorrectnumberofbitsperpixel.Whatisthesizeofthefilescomparedwiththeoriginal?
Giventheresults,whatisatypicalapplicationfieldforquantization?
Includeinyoursubmissiontheoutputfilesandcommentontheresults.
Thesizeoffilesbecomessmaller.Becausewereducesomecolourlevel,thebitsthatareusedforrepresentacolourarebecomesless.Thefileaarecompressed.IfaweuesfactorN,wegetanewfilehave1/Nsize.
Exercise2(b)
Histograms:
Thispartofthelabisdedicatedtoimageprocessingusinghistograms.Ahistogramisastatisticalrepresentationofthedatawithinanimage.Thehistogramcanberepresentedasaplotofthefrequencyofeachgreylevel.Thisrepresentationshowsthedistributionoftheimagedatavalues.Bymanipulatingahistogram,itispossibletoimprovethecontrastinanimageandtheoverallbrightnessortosegmentdifferentareasoftheimagebyapplyingoneormorethresholdstothehistogramitself.
Implementafunctiontooutputthehistogramvaluesofagivengreylevelimage.Displayintheboxestheresultinghistograms.
Lena
Baboon
Peppers
Ifyounormalizethevaluesofthehistogramsothattheysumto1,whatdoesthevalueofabinrepresent?
Representtheprobabilityofeachgreylevel
Exercise2(c)
Equalize:
Equalizationisoneofthepossibleimageprocessingalgorithmsimplementedusinghistograms.Histogramequalizationallowsuseenhancingthecontrastofimages.Histogramequalizationemploysamonotonic,non-linearmappingwhichre-assignstheintensityvaluesofpixelsintheinputimagesuchthattheoutputimagecontainsauniformdistributionofintensities(i.e.aflathistogram).
Implementafunctionthatequalizesgrey-scaleimagesbasedontheirhistogram.Theinputisagivengreylevelimage;
theoutputisthederivedimage