Lecture 3 Optmzato Trt 04 P.H.S.Torr Least Squares Fttg Classc least squares Total least squares Robust Estmato
Fttg: Cocepts ad recpes
Least squares le fttg Data:,,,, Le equato: = m + b Fd m, b to mmze E m b, =m+b
Least squares le fttg Data:,,,, Le equato: = m + b Fd m, b to mmze 0 Y X XB X db de T T XB XB Y XB Y Y XB Y XB Y XB Y b m b m E T T T T Normal equatos: least squares soluto to XB=Y b m E, =m+b Y X XB X T T
Problem wth vertcal least squares Not rotato-varat Fals completel for vertcal les
Total least squares Dstace betwee pot, ad le a+b=d a +b =: a + b d Fd a, b, d to mmze the sum of squared perpedcular dstaces E a b E a b d d, a+b=d Ut ormal: N=a, b
Total least squares Dstace betwee pot, ad le a+b=d a +b =: a + b d Fd a, b, d to mmze the sum of squared perpedcular dstaces d b a E, a+b=d d b a E Ut ormal: N=a, b 0 d b a d E b a b a d UN UN b a b a E T 0 N U U dn de T Soluto to U T UN = 0, subject to N = : egevector of U T U assocated wth the smallest egevalue least squares soluto to homogeeous lear sstem UN = 0
Total least squares U T U U secod momet matr
Total least squares U T U U, N = a, b secod momet matr,
Least squares as lkelhood mamzato Geeratve model: le pots are corrupted b Gaussa ose the drecto perpedcular to the le u v a b ε u, v a+b=d, pot o the le ormal ose: drecto zero-mea Gaussa wth std. dev. σ
Least squares as lkelhood mamzato Geeratve model: le pots are corrupted b Gaussa ose the drecto perpedcular to the le b a v u, u, v ε d b a d b a P d b a P ep,,,,,, Lkelhood of pots gve le parameters a, b, d: d b a d b a L,,,, Log-lkelhood: a+b=d
Probablstc fttg: Geeral cocepts Lkelhood:,, P L P
Probablstc fttg: Geeral cocepts Lkelhood: Log-lkelhood: P P L,, P P L log,, log log
Probablstc fttg: Geeral cocepts Lkelhood: Log-lkelhood:,, P L P log L log P,, log P Mamum lkelhood estmato: ˆ arg ma L
Probablstc fttg: Geeral cocepts Lkelhood: Log-lkelhood:,, P L P log L log P,, log P Mamum lkelhood estmato: ˆ arg ma L Mamum a posteror MAP estmato: ˆ arg ma P,, arg ma L P pror
Least squares for geeral curves We would lke to mmze the sum of squared geometrc dstaces betwee the data pots ad the curve d,, C, curve C
Calculatg geometrc dstace closest pot u 0, v 0, curve taget: C v C u0, v0, u0, v0 u curve Cu,v = 0 The curve taget must be orthogoal to the vector coectg, wth the closest pot o the curve, u 0, v 0 : C v C u, v0 0 0 0 0 v u u, v [ v ] 0 0 C 0 u0, v 0 Must solve sstem of equatos for u 0, v 0
Least squares for cocs Equato of a geeral coc: Ca, = a = a + b + c + d + e + f = 0, a = [a, b, c, d, e, f], = [,,,,, ] Mmzg the geometrc dstace s o-lear eve for a coc Algebrac dstace: Ca, Algebrac dstace mmzato b lear least squares: 0 f e d c b a
Least squares for cocs Least squares sstem: Da = 0 Need costrat o a to prevet trval soluto Dscrmat: b 4ac Negatve: ellpse Zero: parabola Postve: hperbola Mmzg squared algebrac dstace subject to costrats leads to a geeralzed egevalue problem Ma varatos possble For more formato: A. Ftzgbbo, M. Plu, ad R. Fsher, Drect least-squares fttg of ellpses, EEE Trasactos o Patter Aalss ad Mache Itellgece, 5, 476--480, Ma 999
Least squares: Robustess to ose Least squares ft to the red pots:
Least squares: Robustess to ose Least squares ft wth a outler: Problem: squared error heavl pealzes outlers
Robust estmators Geeral approach: mmze r, θ resdual of th pot w.r.t. model parameters θ ρ robust fucto wth scale parameter σ r, ; The robust fucto ρ behaves lke squared dstace for small values of the resdual u but saturates for larger values of u
Choosg the scale: Just rght The effect of the outler s elmated
Choosg the scale: Too small The error value s almost the same for ever pot ad the ft s ver poor
Choosg the scale: Too large Behaves much the same as least squares
Robust estmato: Notes Robust fttg s a olear optmzato problem that must be solved teratvel Least squares soluto ca be used for talzato Adaptve choce of scale: magc umber tmes meda resdual
Optmzato has ma local mma
How ca we deal wth ma local mma?
Fttg a Le Least squares ft
RANSAC-Data drve starts! Select sample of m pots at radom
RANSAC Select sample of m pots at radom Calculate model parameters that ft the data the sample
RANSAC Select sample of m pots at radom Calculate model parameters that ft the data the sample Calculate error fucto for each data pot
RANSAC Select sample of m pots at radom Calculate model parameters that ft the data the sample Calculate error fucto for each data pot Select data that support curret hpothess
RANSAC Select sample of m pots at radom Calculate model parameters that ft the data the sample Calculate error fucto for each data pot Select data that support curret hpothess Repeat samplg
RANSAC Select sample of m pots at radom Calculate model parameters that ft the data the sample Calculate error fucto for each data pot Select data that support curret hpothess Repeat samplg
How Ma Samples? O average N I m umber of pot umber of lers sze of the sample Pgood = mea tme before the success Ek = / Pgood
How Ma Samples? Wth cofdece p
How Ma Samples? Wth cofdece p N I m umber of pot umber of lers sze of the sample Pgood = Pbad = Pgood Pbad k tmes = Pgood k
How Ma Samples? Wth cofdece p Pbad k tmes = Pgood k - p k log Pgood log p k log p / log Pgood
How Ma Samples I / N [%] Sze of the sample m
RANSAC k = log p I I- log - N N- k umber of samples draw N umber of data pots I tme to compute a sgle model p cofdece the soluto.95
RANSAC Robust fttg ca deal wth a few outlers what f we have ver ma? Radom sample cosesus RANSAC: Ver geeral framework for model fttg the presece of outlers Outle Choose a small subset uforml at radom Ft a model to that subset Fd all remag pots that are close to the model ad reject the rest as outlers Do ths ma tmes ad choose the best model M. A. Fschler, R. C. Bolles. Radom Sample Cosesus: A Paradgm for Model Fttg wth Applcatos to Image Aalss ad Automated Cartograph. Comm. of the ACM, Vol 4, pp 38-395, 98.
RANSAC for le fttg Repeat N tmes: Draw s pots uforml at radom Ft le to these s pots Fd lers to ths le amog the remag pots.e., pots whose dstace from the le s less tha t If there are d or more lers, accept the le ad reft usg all lers
Choosg the parameters Ital umber of pots s Tpcall mmum umber eeded to ft the model Dstace threshold t Choose t so probablt for ler s p e.g. 0.95 Zero-mea Gaussa ose wth std. dev. σ: t =3.84σ Number of samples N Choose N so that, wth probablt p, at least oe radom sample s free from outlers e.g. p=0.99 outler rato: e Source: M. Pollefes
Choosg the parameters Ital umber of pots s Tpcall mmum umber eeded to ft the model Dstace threshold t Choose t so probablt for ler s p e.g. 0.95 Zero-mea Gaussa ose wth std. dev. σ: t =3.84σ Number of samples N Choose N so that, wth probablt p, at least oe radom sample s free from outlers e.g. p=0.99 outler rato: e s N e p N p/ log e log s proporto of outlers e s 5% 0% 0% 5% 30% 40% 50% 3 5 6 7 7 3 3 4 7 9 9 35 4 3 5 9 3 7 34 7 5 4 6 7 6 57 46 6 4 7 6 4 37 97 93 7 4 8 0 33 54 63 588 8 5 9 6 44 78 7 77 Source: M. Pollefes
Choosg the parameters Ital umber of pots s Tpcall mmum umber eeded to ft the model Dstace threshold t Choose t so probablt for ler s p e.g. 0.95 Zero-mea Gaussa ose wth std. dev. σ: t =3.84σ Number of samples N Choose N so that, wth probablt p, at least oe radom sample s free from outlers e.g. p=0.99 outler rato: e s N e p N p/ log e log s Source: M. Pollefes
Choosg the parameters Ital umber of pots s Tpcall mmum umber eeded to ft the model Dstace threshold t Choose t so probablt for ler s p e.g. 0.95 Zero-mea Gaussa ose wth std. dev. σ: t =3.84σ Number of samples N Choose N so that, wth probablt p, at least oe radom sample s free from outlers e.g. p=0.99 outler rato: e Cosesus set sze d Should match epected ler rato Source: M. Pollefes
Adaptvel determg the umber of samples Iler rato e s ofte ukow a pror, so pck worst case, e.g. 50%, ad adapt f more lers are foud, e.g. 80% would eld e=0. Adaptve procedure: N=, sample_cout =0 Whle N >sample_cout Choose a sample ad cout the umber of lers Set e = umber of lers/total umber of pots Recompute N from e: N p/ log e log s Icremet the sample_cout b Source: M. Pollefes
RANSAC pros ad cos Pros Smple ad geeral Applcable to ma dfferet problems Ofte works well practce Cos Lots of parameters to tue Ca t alwas get a good talzato of the model based o the mmum umber of samples Sometmes too ma teratos are requred Ca fal for etremel low ler ratos We ca ofte do better tha brute-force samplg
Problem ; cost fucto Eamples of other cost fuctos Least Meda Squares;.e. take the sample that mmzed the meda of the resduals. MLESAC/MLESAC use the posteror or lkelhood of the data. MINPRAN Stewart, makes assumptos about radomess of data
LMS Repeat M tmes: Sample mmal umber of matches to estmate two vew relato. Calculate error of all data. Choose relato to mmze meda of errors.
Pros ad Cos LMS PRO CON Do ot eed a threshold for lers. Caot work for more tha 50% outlers. Problems f a lot of data belogs to a submafold e.g. domate plae the mage
Co: LMS, subspace problem Meda error s same for two solutos.
Co: LMS, subspace problem No good soluto f the umber of outlers >50%
Pros LMS Oe major advatage of LMS s that t ca eld a robust estmate of the varace of the errors. But care should be take to use the rght formula, as ths depeds o the dstrbuto of the errors, ad degrees of freedom the errors codmeso.
Robust Mamum Lkelhood Estmato Radom Samplg ca optmze a fucto: Better, robust cost fucto, MLESAC
Error fucto Red-mture, gree-uform, blue-gaussa.
MAPSAC/MLESAC Ths soluto
MLESAC/MLESAC Is better tha ths soluto
MLESAC Add pror to get to MAP soluto Iterestg thg s that wth MLESAC oe could sample less tha the mmal umber of pots to make a estmate usg pror as etra formato. A posteror ca be optmzed; radom samplg good for matchg AND FUNCTION OPTIMIZATION! e.g. MLESAC s a cheap wa to optmze objectve fuctos regardless of outlers or ot.
MLESAC Oce the beefts of MLESAC are see there s o reaso to cotue to use RANSAC; ma stuatos the mprovemet the soluto ca be marked Especall f wat to use pror formato e.g. the F matr chagg smoothl over tme. Gves a optmzed soluto AT NO EXTRA COST! P.H.S. Torr ad A. Zsserma. MLESAC: A New Robust Estmator wth Applcato to Estmatg Image Geometr. I Joural of Computer Vso ad Image Uderstadg, pages 38 56, 78, 000.