北邮国院视频图像处理Word文档下载推荐.docx
《北邮国院视频图像处理Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《北邮国院视频图像处理Word文档下载推荐.docx(29页珍藏版)》请在冰豆网上搜索。
Reading/writingPGM/PPMimages:
Thefirststeptowardsimageandvideoprocessingisreadingimagesfromfileandwritethemtofile.Thereexistdifferentstandardsthatstoretheinformationindifferentformats;
beforeopeninganimage,knowledgeofthestandardisnecessary.TwowidelyusedimageformatsarePPMandPGM.ThePGMformatisagreyscalefileformatdesignedtobeeasytomanipulate.APGMimagerepresentsagreyscalegraphicimage.Formostpurposes,aPGMimagecanjustbethoughtofanarrayofintegers.Thename"
PGM"
istheacronymof"
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.
Displaytheresultsofsu