image inpaintingreadmeWord文档下载推荐.docx
《image inpaintingreadmeWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《image inpaintingreadmeWord文档下载推荐.docx(4页珍藏版)》请在冰豆网上搜索。
thepicturewindowandtheconcolewindow.Theprimaryuseractivityisdrawingthemaskovertheareatoberepaired.Themaskisdrawnwiththeleftmousebuttonanderasedwiththerightmousebutton.WhenevertheuserinitiatesafileI/Ooperation,thefilenameistobetypedintotheconsolewindow.
leftmousedrag-drawmask
rightmousedrag-erasemask
'
C'
-clearmask
u'
-unlimitedundo(ofmaskdrawing)
r'
-redo(maskdrawing)
U'
-toggleundoon/off(offsavessomememory--notmuch)
b'
-brushsize(rotatebetweenthreesizes)
t'
-togglemaskdisplayon/off
c'
-cyclethroughmaskcolors
s'
-saveimage
M'
-savemask
L'
-loadmask
+'
-oneiterationofinpainting
d'
-oneiterationofanisotropicdiffusion
D'
-togglediffusionon/off
i'
-100iterations,followedbyastepofdiffusion,ifdiffusionison
I'
-2000iterations,followedbyastepofdiffusion,ifdiffusionison
V'
-specifyhowmanyblocksof100iterationsofinpaintingtodo,followedbyastepof
diffusion,ifdiffusionison
a'
-15iterationsofinpainting,followedby2stepsofdiffusion
A'
-specifyhowmanyblocksof15i/2d
INPAINTING:
Theinpaintingalgorithmmeasuresthesmoothnessoftheimageandusesthistodecidehowtoextendcontoursthroughthemaskedregion.ItusestheLaplacianasasmoothnessindicator.To
findedgecontours,weusavectorperpendiculartothegradient.Thegradientoftheimagepointsinthedirectionofgreatestincrease.Alongedges,thegradientpointsperpendiculartotheedgebecausethegreatestchangeinthevalueoftheimageisacrossanedge.
Imageinpaintingisaniterativealgorithmthatonlychangespixelsinthemask.Inordertogetfromstepntostepn+1:
defineL(x,y)=2DLaplacianatpixel(x,y)
dLisavector,thechangeinsmoothnesstotheleft,right,top,andbottomofthecurrentpixel
Nisavector,avectorperpendiculartothegradient
Gisascalar,ameasureofthelengthofthegradient
Updateisapixelarray
Imageisapixelarray,theimageatstepn
ImageNextisapixelarray,theimageatstepn+1
deltatisascalar,thestepsizeforupdatinganimage
foreverypixel(x,y)inthemask
dL(x,y)=(L(x+1,y)-L(x-1,y),L(x,y+1)-L(x,j-1))
N=normalizedvectorperpendiculartogradient
B=dL.N
G=length*(N)
Update(x,y)=B*G
ImageNext(x,y)=Image(x,y)+deltat*Update(x,y)
length*isaspecialmeasureoflengththatneedstobeusedinordertogetstableresults.Itis
definedas
_x-xdirection
_y-ydirection
_f-forwardderivative-calculatederivativeasdifferencebetweenpixelinfrontandcurrent
pixel
_b-backardderivative-calculatederivativeasdifferencebetweencurrentpixelandpixelin
back
_m-minimumofvalueand0
_M-maximumofvalueand0
if(B>
0)
length*=sqrt(Image_xbm^2+Image_xfM^2+Image_ybm^2+Image_yfM^2)
else
length*=sqrt(Image_xbM^2+Image_xfm^2+Image_ybM^2+Image_yfm^2)
ANISOTROPICDIFFUSION:
Aftereveryseveralstepsofinpainting,werunaniterationofanisotropicdiffusion.Anisotropic
diffusionisoneapproachtonoiseremovalbecauseittendstosharpenedgeswhilesmoothingover
continuousregions.Itisusedherefortworeasons.Ithelpstosmoothoversomeoftheparts
filledinbytheinpaintingalgorithm.Italsohelpstojoinedgesacrossthemaskastheyare
beingdrawninsothattheywillbecontinuous.WeadaptedRobertEstes'
s
MCDalgorithmforouruse.
OPTIMIZATIONS
Weimplementedanumberofoptimizationsinanefforttomaketheprogramfasterandmoreresponsive.TheimageiskeptinaformatthatGLcanreaddirectly(whichallowsforfairlyquickredraws).However,forlargeimages,eventhisincursanoticabledelay,soformostmaskandimagemanipulations,wedrawthechangedpixelsdirectlytothescreentoavoidwhole-imageredraws.Themaskitselfisstoredinabitfield,andwedevelopedfastalgorithmsforiterationandmodificationwhichutilizethefactthatthemaskisusuallysparse.
Undoandredoarealsomemory-efficient;
althoughwemustdynamicallyallocatememoryastheuserinteractswiththeprogram,weuseadynamic,scalablevectorclasswhichavoidscostlylinkedlistsandpointers.Asaresulteachpixelchangerequiresonlyabout10bytesofstorageonaverage(4eachfor
xandycoords,1forindicatingthetypeofoperation,and1[onaverage]forpointingtothenextvector).
Fortheinpaintinganddiffusionalgorithms,weusedinlinefunctionsandpass-by-referenceasmuchaspossible,andtriedtoavoidtediousiterationsoverthewholeimage.Diffusionisaverycostlyalgorithm;
ourcurrentimplementationrequiresabout3xasmuchmemorytorunastheoriginalimage.Therearelikelymoreefficientimplementationsoutthere,butwecouldn'
tthinkofabetterwaytoimplementitthatwouldstillbefast.
--------------------------------
PublishedPaper
psfile
OriginalPaper:
Preprint
http:
//www.ima.umn.edu/preprints/dec99/dec99.html
AnisotropicDiffusionCode
//info.cipic.ucdavis.edu/ftp/estes/
Implementationofinpainting
//www-users.itlabs.umn.edu/~rams0053/