houghtransform变换图形学课件cysfitting_第1页
houghtransform变换图形学课件cysfitting_第2页
houghtransform变换图形学课件cysfitting_第3页
houghtransform变换图形学课件cysfitting_第4页
houghtransform变换图形学课件cysfitting_第5页
已阅读5页,还剩112页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ImageandVisionInstructor:ImageandVisionInstructor:ChenHCI&MultimediaLab,PekingEdgedetectionWhatEdgedetectionWhatcomesnextFitting(曲线拟合Transform(霍Fitting(曲线拟合Transform(霍夫变换RobustFitting(直线拟合UR=20IFitting:convertmeaninglessfeaturestoFitting(直线拟合UR=20IFitting:convertmeaninglessfeaturestomeaningfulThefirststepofimageunderstand,lowerfeatureshigherStandardlinearsolutiontoestimatingy=Standardlinearsolutiontoestimatingy=ax+b=fx,a,MinimizeE=x,a,bf2-iiiTakederivativewrtaandb,settoLeastSquaresb)2iii=-2xi[LeastSquaresb)2iii=-2xi[yi-(axi+b)]=i¶E=2[y-(ax+b)]=iiinxi-xi1n(yi-axia= ,b=i -22xiiiiiLineLeastsquaresfit(takederivativesw.r.t.Defineobservationmatrices,vectorofLineLeastsquaresfit(takederivativesw.r.t.Defineobservationmatrices,vectorofy 2=2ATAM ynC{BALineY=aX+y LineY=aX+y 2=2B=M ynC{BAy=ax+1M1=ax2+ATB=ATTTTCC=T1ATB=axn+Let’smakeitmorexx1x123ny=[y,Let’smakeitmorexx1x123ny=[y,,y]',X,h=[a,1 n11Thisisanover-determinedlinearequationXh=h=(XTX)-1Linefittingcanbemax.likelihood-Linefittingcanbemax.likelihood-butchoiceofmodelisimportantMatlab%averyeasydemooflinefittingMatlab%averyeasydemooflinefittingA=[xones(11,1)];%choice1:use%choice2:usepseudo%drawall%drawfittedLeastSquaresFitUnderwhatcasesdoestheleastsquareLeastSquaresFitUnderwhatcasesdoestheleastsquarefitmethodworkwell?Ifweknowwhichpointsbelongtowhichandifthereisnonoisyy=ax+b=fx,a,f2x,a,-MinimizeEiiiConicsCurvedescribedby2nd-degreeequationConicsCurvedescribedby2nd-degreeequationinthe=2pointsdetermineastraight5pointsdetermineanon-degenerateFivepointsdefineaForeachpointtheconicpasses+bxy+cy2+dx+ey+f=i iii22c=,b,c,d,e,fx,xy,FivepointsdefineaForeachpointtheconicpasses+bxy+cy2+dx+ey+f=i iii22c=,b,c,d,e,fx,xy,y,x,y,1c=i stackingconstraintsx2xxy1 111xxy1 2221c=2xxx3 3332xxx1 4442xxx5 555LineFitting:TillnowitisLineFitting:TillnowitisassumedthatweknowwhocamefromwhichlineorconicIfweknownothingatallabouthowmanylinesandwhichpointbelongstowhichline……CurveHoughRobustCurveHoughRobustChooseaparametricobject/someobjectsChooseaparametricobject/someobjectstorepresentasetoftokens(标识点)Threemainwhatobjectrepresentsthissetoftokenswhichofseveralobjectsgetswhichhowmanyobjectsare(youcouldreadlineforobjecthere,orcircle,orellipseor...)FindinglinesinanWedoforFindinglinesinanWedoforlinesonlyinourGeneralgoal:FromedgestostraightOptionSearchforthelineateverypossibleWhatisthecostofthisOptionUseavotingtransform(霍夫变换AdvantageofExample:Twocandidates(A&B)runforthepresidentAssumption:thecorrectprobabilityofeachvoteisAdvantageofExample:Twocandidates(A&B)runforthepresidentAssumption:thecorrectprobabilityofeachvoteis0.7Scheme1:assignedbytheformerCorrectScheme2:generalelection,thecandidatewithmorevotesCorrectratefor3votes:C0.3+(0.7)3=3Correctratefor5votes:C3(0.7)3(0.3)2+C4(0.7)4(0.3)+(0.7)5=55Correctratefor100,000,000votes:LinesinCartesiany(x,y Alineisasetofpoints(x,LinesinCartesiany(x,y Alineisasetofpoints(x,(y-y1)=k(x-y=kx+xx0x/x0+y/=k¥xTransform(霍夫变换—from(x,y)to(Slope,y=-m0x+Transform(霍夫变换—from(x,y)to(Slope,y=-m0x+b2=-m2x+bb1=-m1x+(m0,b0),(m1,b1),(m2,b2)aremximageHoughWhatdoesapoint(x0,y0)intheimagespacemapthesolutionsofb=-x0m+(x,y)thisisalineinHoughimage(x,y)spaceandHough(m,b)ybimage(x,y)spaceandHough(m,b)ybHoughximagemConversely,AlineintheimagecorrespondstoapointinHoughspaceHoughTransform:bymxBlurlinescorrespondstoblurDetectingLinesbyfindingmaxima/clusteringinparameterHoughTransform:bymxBlurlinescorrespondstoblurDetectingLinesbyfindingmaxima/clusteringinparameterHoughtransform:mimplementationtheparameterHoughtransform:mimplementationtheparameterspaceisacounterisincrementedateachcellwherethelines3.peaksareHoughtransform:Problem:unboundedparameterdomain,verticallinesHoughtransform:Problem:unboundedparameterdomain,verticallinesrequireinfinitex=m¥xq:determinetheslopeoftheline:r:thedistancefromthelinetotheHoughtransform:xcosq+ysinq=DifferentHoughtransform:xcosq+ysinq=DifferentrforconstantDifferentqforconstantHoughtransform:x+ysin=WhatdoesthecurvelooklikeintheHoughspaceEachgreenbingetsar=x+ysinxy+y2cosqsinq=+++y2sin(q=EachfeaturepointcorrespondstoasinecurveinHoughspaceHoughtransform:x+ysin=WhatdoesthecurvelooklikeintheHoughspaceEachgreenbingetsar=x+ysinxy+y2cosqsinq=+++y2sin(q=EachfeaturepointcorrespondstoasinecurveinHoughspaceHoughtransform:HoughTypicallyHoughtransform:HoughTypicallyusethefollowingr=xcosq+yρistheperpendiculardistancefromthelinetotheoriginqistheanglethisperpendicularmakeswiththexaxisDifferentchoicesofq,ρ>0givedifferentHoughForanyimagepoint(x,y)thereisHoughForanyimagepoint(x,y)thereisaoneparameterfamilyoflines(aHoughsinecurve)throughthispoint,givenbyEachpointvotesforalllines(aHoughsinecurve)ofitscorrespondingifthereisaline(aHoughpoint)thathaslotsofvotes,thatshouldbethelinepassingthroughthecorrespondingpoints.HoughTransform:Awardassignment:makeHoughTransform:Awardassignment:makeacleardemopictureandHoughtransformBasicHoughtransformInitializeH[ρ,HoughtransformBasicHoughtransformInitializeH[ρ,foreachedgepointI[x,y]inthecomputetheHoughcurveforq=0to180H[ρ,q]+=Findthevalue(s)of(ρ0,q0)whereq]isThedetectedlineintheimageisgivenr0=xcosq0+yr=xcosq+yHoughTransform:StraightSquareCircleHoughTransform:StraightSquareCircleHoughTransform:StraightHoughTransform:StraightHoughTransform:EdgeHoughHoughTransform:EdgeHoughHoughTransform:Problem:LookingforHoughTransform:Problem:LookingforstraightlinesintheaboveHoughtransformqrHoughtransformqrLinedetectionLinedetectionErrorveryErrorveryNoisedegradestheNoisedegradesthelotsofnoisecanlotsofnoisecanleadtolargepeaksintheNoiseThisistheNoiseThisisthenumberofvotesthatthereallineof20pointsgetswithincreasingWhatistheincrementsWhatistheincrementsforqandtoobig?Wecannotdistinguishbetweendifferenttoosmall?noisecauseslinestobeHowmanyofdetectedlinesarecountthepeaksintheHoughWhichedgepointbelongstowhichtagtheHardlyeversatisfactoryduetoproblemswithnoiseandcellsizedefeatMatlabRGB=I=%converttoMatlabRGB=I=%converttoBW=%extract[H,T,R]=hough(BW,'RhoResolution',0.5,'ThetaResolution',0.5);%houghtransformtitle('Houghtransformofgantrycrane.png');xlabel('\theta'),ylabel('\rho');axison,axisnormal,holdon;%displaytheMatlabI=MatlabI=BW=%cannyedge[H,T,R]=P=houghpeaks(H,2);%Precordsindicesof2highestpeakT-Rpairsxlabel('\theta'),ylabel('\rho');axison,axisnormal,holdplot(T(P(:,2)),R(P(:,1)),'s','color','white');%drawhoughpeaksaswhiteMatlabI=rotI=imrotate(I,33,'crop');%rotatetopreventdegradationBW=edge(rotI,'canny');MatlabI=rotI=imrotate(I,33,'crop');%rotatetopreventdegradationBW=edge(rotI,'canny');[H,T,R]=xlabel('\theta'),ylabel('\rho');axison,axisnormal,holdP=x=T(P(:,2));y=%drawhoughtransformimagewith5peakslines=houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);figure,imshow(rotI),holdon;max_len=fork=xy=[lines(k).point1;%green len=norm(lines(k).point1-lines(k).point2);if(len>max_len)max_len=len;xy_long=xy;%redend%highlightthelongestlineRealWorldFoundEdgeParameterRealWorldFoundEdgeParameterFindinglinesandotherFindinglinesandotherparameterizedobjectsisanimportanttaskforcomputervision.The(generalized)Houghtransformcandetectarbitraryshapesfrom(edgedetected)tokens.Successratedependsdirectlyuponthenoiseintheedgeimage.Downsides:Canbeslow,especiallyforobjectsinarbitraryscalesandorientations(extraparametersincreaseaccumulatorspaceexponentially).ExtensionUsetheimageExtensionUsetheimage foreachedgepointI[x,y]inthecomputeuniquegradientatH[d,q]+=q)basedonExtensiongivemorevotesforstrongerExtensionchangethesamplingof(d,q)togivemore/lessExtensionthesameprocedurecanbeusedwithcircles,squares,oranyothershapeExtensiongivemorevotesforstrongerExtensionchangethesamplingof(d,q)togivemore/lessExtensionthesameprocedurecanbeusedwithcircles,squares,oranyothershape*CurveFittingbyHoughLety=f(x,*CurveFittingbyHoughLety=f(x,a)bethechosenparameterizationofatargetcurve.Discretizetheintervalsofvariationofa1,…akands1,…skbethenumberofthediscretizedLetA(s1,…sk)beanarrayofintegercountersandinitializeallitselementstozero.ForeachpixelE(i,j)suchthatE(i,j)=1,incrementallcountersonthecurvedefinedbyy=f(x,a)inA.FindalllocalmaximaabovecertainCurveFittingbyHoughCurveFittingbyHoughSufferwiththesameproblemsaslinefittingbyHoughTransform.Computationalcomplexityandstoragecomplexityincreaserapidlywithnumberofparameters.NotveryrobusttoCircleSimilartolineThree---=o222CircleSimilartolineThree---=o222oConstructa3DaccumulatorarrayDimensions:x0,y0,FixoneoftheparameterschangetheIncrementcorrespondingentryinFindthelocalmaximainMorePracticalCircleUsetheMorePracticalCircleUsethetangentdirectionqattheedgepoint(Reducesearchspaceforx0,y0)qComputex0,y0givenx,y,x0=x-ry0=y-rIntheimageWithIntheimageWithnoorientation,eachtoken(point)votesforallpossibleimagecircles.Withorientation,eachtokencanvoteforasmallernumberofcircles.x0=x-rx0=x-ry0=y-rInHoughWithnoorientation,eachimagetoken(point)votesforonefullHoughWithorientation,eachtokencanvoteforasmallerpartofaRealWorldRealWorldCircleCrosshairindicatesresultsofHoughtransform,boundingboxfoundviamotiondifferencing.FindingEdgesFindingEdges(noteFindingCoinsFindingCoinsFindingCoinsNotethatbecausethequartersandpennyaredifferentsizes,FindingCoinsNotethatbecausethequartersandpennyaredifferentsizes,adifferentHoughtransform(withseparateaccumulators)wasusedforeachcircleCoinfindingsampleimagesfrom:VivikKwatraSummaryHoughSmartSummaryHoughSmartLocalevidenceforglobalOrganizedinaCarefulwithSubjecttoCurseofWorksgreatforsimplefeatureswithlessthan3unknownsWillfailforcomplexobjects(e.g.,allCurseofGoal:lookingforsometargetinagivenCaseCurseofGoal:lookingforsometargetinagivenCase1:1DCase2:2DCase3:3DCurveHoughRobustCurveHoughRobustLeastsquaresassumesGaussianOutliers:PointswithextremelylowprobabilityofLeastsquaresassumesGaussianOutliers:Pointswithextremelylowprobabilityofoccurrence(accordingtoGaussianstatistic)CanresultfromdataassociationStronglyinfluenceleastRobustGoal:developparameterestimationmethodsinsensitivetoRobustGoal:developparameterestimationmethodsinsensitivetosmallnumbersoflargeerrorsGeneralapproach:trytogivelargedeviationslessweightM-estimators:minimizesomefunctionotherthan(y-f(x,a,b,…))2LeastabsolutevalueE=i-fxiLeastabsolutevalueE=i-fxi,a,insteadx,a,.-f2EiiiPointsfarawayfromtrendgetcomparativelylessinfluenceExample:ForconstantMinimizingsquaresgivesMinimizingabsoluteExample:ForconstantMinimizingsquaresgivesMinimizingabsolutevaluegiveExample:constant–ForconstantfunctionMinimizingsquaresExample:constant–ForconstantfunctionMinimizingsquaresgivesMin(E=(yi-a)2i¶E=-2(y-a)=-2(y-na)=iiiia=yi/n=mean(YiExample:constant–ForconstantfunctionMinimizingabsolutevaluegivesExample:constant–ForconstantfunctionMinimizingabsolutevaluegivesE=yi-imsamplestothensamplestotheDE=E2-E1=m-n=Dd(m-MinimumisreachedwhenSamplenumberisSamplenumberisEstimatingmotionTypically:EstimatingmotionTypically:pointsintwoFundamentalTheProblemwithLeastsquaresisatechniqueforfittingamodeltodataTheProblemwithLeastsquaresisatechniqueforfittingamodeltodatathatexhibitaGaussianerrorWhenthereareoutliers—datapointsthatarenotdrawnfromthesamedistribution—theestimationresultcanbebiasedLinefittingusingregressionisbiasedbyfromHartley&SimplerFittingastraightSimplerFittingastraightRobustViewestimationasRobustViewestimationasatwo-stageClassifydatapointsasoutliersorFitmodeltoDiscardNopointwithDiscardNopointwithRANdomSAmpleFischler&BollesCopeswithalargeproportionofMainSelect2pointsMainSelect2pointsatFita“Support”=numberofLinewithmostsupportsGeneralRandomlyselectsInstantiateaGetconsensussetSiRepeatforNtrials,returnmodelwithmaxAdemoforlineTrial1:AdemoforlineTrial1:SupportTrial2:Supportnumber=6Trial3:SupportTrial2WinswithmaximalsupportnumberWhywillthisMoreWhywillthisMoresupport->betterBestLinehasmostFitamoregeneralRobustfitofamodeltodataRANdomSAmpleConsensus:designedforbaddata(inbestcase,upto50%outliers)(RANdomSAmpleRandomlychooseminimal(RANdomSAmpleRandomlychooseminimalsubsetofdatanecessarytofitmodel(aPointswithinsomedistancethresholdtofmodelareconsensusset.Sizeofconsensussetismodel’sRepeatforNsamples;modelwithbiggestsupportismostrobustfitPointswithindistancetofbestmodelareFitfinalmodeltoallandtheirsupportsforline-fittingfromHartley&AfterRANSACdividesdataintoinliersandAfterRANSACdividesdataintoinliersandandyieldsestimatecomputedfromsetofinlierswithgreatestImprovethisinitialestimatewithestimationoverallinliers(i.e.,standardminimization)Butthismaychangeinliers,soalternatefittingwithre-classificationasinlier/outlierfromHartley&HowmanyOftenenoughHowmanyOftenenoughthatwearelikelytohaveagoodHowbigaSmallestWhatdoescloseDependsontheWhatisagoodThenumberofnearbypointsissobigitisunlikelytobeallRANSAC:HowmanyWewant:RANSAC:HowmanyWewant:atleastonetrialwithasampleofallCan’tguarantee:useUsingallpossiblesamplesisoftenInstead,pickNsothat,withprobabilitypofatleastonesampleisfreefromoutliers(orbeingallinliers)log1-p/log1-1-eswhereeisprobabilitythatpointisanTypicallyp=CalculateIfw=proportionCalculateIfw=proportionofinliers=1-P(samplewithallP(asamplewithatleastanoutlier)=1-P(allNsampleshaveoutliers)=(1-WewantP(Nsamplesanoutlier)<1-w=1-eRadaptedfromHartley&SAC:ComputedN(pRadaptedfromHartley&SAC:ComputedN(p=Proportionofoutlierss 10%20%25%30%40%2345678 s=2,s=2,s=4,s=2,s=2,s=4,s=4,s=8,s=8,=>=>=>=>=>=>N=f(e),notN=f(e),notthenumberofNincreasessteeplywithAdaptiveWhenethaisAdaptiveWhenethaisunknownStartwithetha=50%,Samples,fit->updateethaas->setTerminatewhenNsamplesRANSAC—RandomlyselectsRANSAC—RandomlyselectsInstantiateaGetconsensussetIf|Si|>T,terminateandreturnmodel.Otherwiserepeat.RANSAC—AboutThresholdRemember:RANSAC—AboutThresholdRemember:terminateifRuleofthumb:T»So,T=(1-RANSAC—ChooseasmallRANSAC—ChooseasmallsubsetuniformlyatLeastsquaresfittothatComputethefittingDeterminetheconsensuscomparingeacherrorwiththeAnythingclosetoresultisallothersareRepeattheabovestepsformanyChoosethefitthatagreedwithmostCanperformon

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论