Document Sample
openCvPart04.pdf Powered By Docstoc
					Seeing OpenC With
Face Recognition Eigenface With
tion algorithm that's easy to mple i tacepaper is measured the as ment lts the fifst face,recognitiontcpornt distance This is also methodthat computer visionstudents Euclidean distance. two dime In earn,and ts a standard, wo*horse (2D),the Euclidean dirtance method n the computer vision po nts Pj and P, rs feld. next,* s seri€s p!blished paper conddes by Turkand Pentand the that describes ther Eigenface method t , showingyou how to use n 1991(Reference beow).Citeseer d r z = s q f =( A x 2 + A y 2 )y = 3, whereAx x2- xr, and y, yr. OpenCV!implementation sts 223 c(ationsfor thir paper- an of of + l n 3D, lt's sqrt(Ax' Ay' + eigenface facerecognition. average 16 citationsper yearstnce for publlcationl Figure I showsEuclidean dista The neps used in eigenface are in 2D ce recognition the process i5 of also usedin manyadvanced methods. ln a 2D plotsuch Figurc a5 1, Puttinga nameto a face.Once ln fact, f you're nterestedn learning d mensions the X and Y axes. are you've detected a face, face computer vision fundamentals,I get3D,throwin a Z axis. what But recogn on meansfigurng out whose recommendyou earn about and t thedimensons a facemage? for lace it is. You won't seesecurity level implement eigenface, even f you dont The simple answer is recognitionfrom works plan to incorporate face recogntion eigeniace consders eachpixel ocataon wel enough,howevef, makea fun to Into a prolectlOne reason eigenface is to be a separate dimension, there't But enhancement a hobbyistrobotics to mportant s that the basic nciples a catch to pr behind it PCA and distance,based The catchis that we're first going r,r s month's article gives a matchrng appearover and over in to do sor.eth n9 caled dimensionality r.:: ed expanaton how egenface numerou5 computer vision and of reductlo, Eefore expainingwhat that .Jor<s a^d the theorybehind Next machine it. learning ications. app is, lefs look at why we needh. montn artce \4/i concldethislopic t Hefe'show recognition works: Evena rmall face imagehar a lot by takrngyo! throughrhe program G veneramplefaceimages eachof for of pixels.A common image 5ize for mingsteps mpem€nt genface. to e severapeople,plus an unknownface face recognitions 50 x 50. An image imageto recognize, (ompute rnrssrze 2,5urJ nas the Eucideandistancebetween iro 1) Computea "distance" betweenthe ol these images, using pixes as Egenlacet d 5imple face recogni. new rmageand each of the example dimensions, d sum the squareof you taces the brightness difference eachof the at FI6URE . €uclid..n dlstnca d& for two 2,500 pixel ocations,then take the 2) Select the example imagethafs square root of that sLlm. closestto the new one as the most There are severalproblemswith I kelyknown pe6on. this approach.Let's ook at one of them signal-to-noise o. fat 3) lf ihe d stance that face image s to above a threshold, "recognize"the rmage that person, as otherwtse. classtfy the faceas an "unknown"person. By computng distancebetween Jace mages, we've replaced2,500 drfferences betweenpixelvaueswith a s ngle value. The question want to we Dstance in the orgina eigen- consder s, "What effect does noise


a arrt G -Fr
-' Et ta

Whatis Eigenface?

rnJ : 5a




Noise Times 2,500 is a lot of Noise

How'Far Apart" AreIheselmages?

Di| Re

36 sEnvo sooz o+

a9.aE 9. Righ! Fitthg 3 b ttrrec poht! 6 . c.s. of PCA- Lcft: aFd t ror..t points from thc in D onto thc lD 3 ld!i? thc Polnt on -. tr thrt's closast lo ! 9D Polnt. Sottoml t lo subsp6cq and th? t b?t\ i?an Polnts Pt6

'4. :n thisvalue? -:r's define noise a5 r.- .9 - other than an _'-':/ di{ference that ',:'s . Pixel bnghtness . 'ra images exactly are .._:.aI, and small,inci

t E ,rO I a'e thal Ie5

on9 atrty tnal



wth ? o l

,500 rlra

a lf we position rectangular QqY) uses is called ., : nfluences In one that eigenface causechanges b - PCA coordinate so system that its origin Anarsis lf : ,' Drghtness. eachone ol these Pincipal Components on somewhere thisline,we canwlhe ':,: pxelscontributes a small Jorshort. even as the lineequation simPlY _ -nt of noise, sheer ol number , the level Line Fitting and PCA the means totalnoise :, pixels for To get an intuition what PcA Y = m x , hlgh. .e very case let'slookat noisecontnbu' does. "least a special of PCA Amdst all these ' AY/lx. s m line squares fit The where isthe line slope: '!, whatever is information uSelul calleda this when it's described way,the showsan 2 - dentifying side of Figure faces i5 lefthand individual of the 2D space of son or example fitting a line to three line is a subspace some contributing lr.imably system coordinate by defined the(x,y) for -rBtent the But signal. with2,500pxels ooints: 2D mao locations Los the NewYork (To This description emPhasizes and ingeles,Chicago, to of amount noise some ::r adding in of simple, l've aspect the datawe'reinterested -. answel keep the explanation is signal hardto thatsmall these that the suchas elevatlon namely direction keeps _r andharder measure. 3D ignored factors to points most separatedlrom one of the Eadh andthe curvature ) o{ very often, the information are maP three _'€rest a muchlowerdimension_ These Points almost another. has line i f than the numberof measure - but not qLlite on a single a lf Youwere Planning tnp, The PCASublPe(e -.nts. ln the case an image, each already. of This dire(tion ol maximum would be useiul Most that relationshiP : (el'svalueis a measurement the i5 line separation called first principal a In rePresent information. thatsense. single <ely,we can (somehow) datasetThedirection of about component a essential '-e informationthat would allow expresses something i5 separation the A theirrelationship.linehasonlyone with the nextlarqest from faces between -r to distinguish to perpendicular this Thafs the the so with a much dimension, if we rcplace points' one r fferentindividuals In principal component. a 2D second alonga with locations than 2D locations :naller numberof Parameters dataset,we can hav€ at most two their is that number 10o; singleline, we'll havereduced :500. Maybe principal comPonents -raybe 12.we don'tclaim know dimensionalitY. to it's for Since the dimensionality they'realmostlineduP Because . advance what it i5, only that it's is images muchhighetwe can.have a much smallerthan the akeady, linecan be fitted to them srobably In comPonents a more princiPal with littleerrorTheerrorin the linefit .umberof pixels. made ol lmagesuP the dataset by sum- is measured addingtogether 15 lf thisassumpt|oncorrecl. ol the However, number Principal polnt from of pixeldifferences square thedistance each T ng all the squared limited we lineis the one components canfindis also r,/ouldcreatea noise contribution to the line.Thebest_fit To of by the number dataPoints. see error' the to high extremely compared the that has smallest rhat's that why that is, think of a dataset Lrsefulinformation one goal of the point What's of consists just one a is reduction to tone Defining Subspace Cmensionality lor separatpn of Althouqhthe line found above direction maximum so level, the important downthe noise because isn'tone There is a 1D ;biect, it's locatedinside thisdataset? through can Information come 2D space,and nas an there's nothing to separate Now a larger, with a considerdataset justtlvo points (its The slopeot orientation slope). two points these the line expressessomethlng Thelineconnecting component is the first Principal aboutthe thrce points lt important indi.ates the direction in which But there's no second Principal There are many methoos s there nothlng because component, out spread the most. reduction.The they're for dimensionalitY

Dimensionality bY Reduction PCA

37 o+.qooz senvo

ProiectingData Onto a Sub5pa(e Meanwhile. let's flnish the description of ity dimenslona reduction by PCA. we're almost therel coing back to the map in Fgure 2, now that weve folnd a lD subspace, we need a way to convert 2D points 1D points. The to process doing thal is for caled projection. When you projecra po nr onro you rr a suospace, assrgn the subspacelocation that's closest to its iore to separate: locationin the higher dimensiona both polntsare fully space. That sounds me5sy and We canextendth s ideaindeflnite- complicated,but it's nether. To projecta 2D map point onto the line whichis ly.Threepointsdef ne a plane, in Figure you'd find the point on 2, a 2D object, so a datasetwith three the line that's closest to that 2D data pointscan neverhavemorethan point. Thats ts projection. two principal components, even if its in a 3D. or higher,coordinate systern. There'sa function in Opencv for pointsonto a subspace, projectlng so In e genface, each 50 x 50 again. you only need a conceptual You can leave the fare mage s treated as one data understanding. po nt ( n a 2,500 dimens to onal algoithmicdetails the library. "space') The blue tic marks n Figure2 so the number princpal of be show the subspace ocation of components canfind wil never we morethan the numberoi face irnages the three cties that defined th€ line. Other 2D point5can aso be projected Althoughit's importantto havea onto this line The righthand conceptual understanding what of side of Figure2 showsthe prolected principalcomponents locationsfor Phoenix,Albuquerque, are, you won't need to know the detais of how to and Boston. find them to implement eigenface. That part has been done for you Computing DistancesBetween Fa<6 In eigenface. the distance already in OpenCV.l l take you throLrgh the API for that in next between two face images s the month'9 cle. art Eucldean distance between their projected points in a


FIGURE F6c. lm.sEs 3. ior 10 p.oplc. Righi Thc PcA subspace,rather than firstsh prlnclprlcomponants d stance in the or ginal 2 vlcwrd 6r cigcnf.c6. imagespace. Com dimensional


the distance betweenfacesin lower dimensional subspace i!
techniquethat eigenfaceuset the noiseratio. improve signal'to face Many advanced techniques are exten5ron5 ol

The man basicconcept. between eigenface and is advanced techniques the for definng the subspace. I
of usng PCA, the sLrbspace m be based on Inde ComponentAnalysis(lCA)

ysis Linear Discrim nant Ana andsoon.
As mentioned above, this

idea -

reducti dimensronality

in fo lowed by dstance calculation subspace is wldelyusedln com vison work. lt's also lsed in of branches Al. In fact. it's one of primarytoolsfor manaqn9 complexi9 and for findng the patterns hidden within massi\eamountsof real worH data.

IF -

Picturing Principal the Components
ln our definition a line as a of lD subspace, used both x and y we coordinates define m, its 2D slope. to componentfor When m is a principal a set of points,it has another name, As It s an eigenvector. yolr no doubt guessed, is the basis the name for this "eigenface." Eigenvectors are a linearagebra concept.That concept is lmportant to us here only as an a ternative name for prinopal For face recognitionon 50 x 50 imag€s,each eigenvectorrepresents the slopeof a linein a 2.500dimensionalspace,As n the 2D case,we need all 2,500 d mensionsto detine the sope of each line. While its impossible visualize line n that to a we can vrew the many dimensions, eigenvectorsn a different way. We can convert their 2,500 dimensional "slope to an image smplyby placing pixel each value in its cofiesponding location.When we do that, we get facelke lmages called guess whateigenlacesl




38 sERVo 9oo7 oa

FIGIJRE F.c€ im.s€s 4. Elch trom two individuals, f.c. lsdisplo€d indivdu.l3 undcr four ditferentlighting Tha v.rl.blllty condltlons, dueto liShting isgffit r her€ thrn thc vlrilbillty b€tw€.n indivldu.h. Eig€nfaca tands to confusc individu.13 when lighting



to are l8enfaces interesting look 3nd give us gomeintuition about t for our tq pnncipalcomponenls fhe lelthand side of Figure ]riet for faceimages 10 People. ! ;-ol/vs -6e face imageSare from the 4 ,.. FaceDatabase (Re{erences B ,',: 5). lt contains images ol 'xes under a range ol lighting for images -ro,tions. I usedseven to ..:.l of these l0 PeoPle createa 'CA subspace. ft€ ghthandside ot Figure3 compc the r-!:\^/s first six pdncipal _..ts of this dataset,displayed as often The r:enfaces. eigenfaces hav€ they r :.osily look,b€cause comblne .inents from severalfaces. The an :.ghtest and the darkestPixel5 ma* the face regions .'.+ eiqenface -:i co;tributed to most that principal

limitationsof Eigenface

F A tldv Dpe. I for tme. )ubt l a aept :rpal r50

!trne rts tnar the

Kng prxel

you hop€r4,on't happen.In thb Penel, tor each individual contaan images a great deal ol vadability So much so. that thdv€ skewed the rcA subspacein a way that makes rt to for impossible eigen{ace tell these apart.Theirfaceimages two people ln are plojectingonlo the 5ameplaces the PcAsubspace. find In practice, You'llProbably for that the data distributions face in imagesfall somewhere between The bottom panel in theseextremes. distribution a 5 Figure shows realistic tor eigenface. Since the eigenvectorsare determinedonly by data varjability, in that youle limited what Youcando to The principalcomponents t{A finds are the directionsof control how eigenlace behaves you However, can take stepsto limit, in variation the of .r€ate5t envircnmenmanage, is eigenface that or to olherwise in :.e assumptions it that mightconfuse images tal conditions underlying .ariability the in at the Placing camera to :crrespond5 differencesbetween For example, in is, face level will reducevariability .dividualfaces.This assumption ang|e, ,nfortunately, not always valid. cameta @nditions suchasside .rgure 4 shows Iaces from two Lighting -are harderfor trornwindows face is lighting ndividuals. Eachindividual's lighting a mobib robot to control.8ut You fourdifferent under I splayed on intelligence adding mightconsider aonditaons, to recognition compensate are images alsofrom the top ot face The5e if B. Yale Database In fact,they're for that. For example, Yourrobot Face and whereit'5located, roughly knows faceimages two of the 10 PeoPle for directionit's fa<ing, it can 3. in shown Figure Canyoutell which which faceimageonly the can'l Eigenface When compard current are ones which? previously a similar in it's seen llghtingis highlyva able,eigenface to ones often does no better than random situation. Even highly'tunedcommercial "stretch" face recognitionsystems subied are othlr factorsthat may identity.In tact, of thattend to cases mistaken in mage variability directions of include partof the challenge incorporating in to blur identity rcA space appliinto angle, facerecognition anyrobotics camera in changes expression, to ways accommodate is cation finding andheadpose. howdatadistribu- these. 5 Figure shows performance tionsalfecteigenface's is for eigen{ace at the Thebestcase Figure 5. Here, rmage5 top of this concludes article monlh's Next are from two individuals clumped stePby-step into tight clustersthat are well series by taking You that irnplements Thats througha program from one anolherseparated with what you hope will hapPen.The eigenface OPenCV. youl SV Beseeing what panel Figure shows 5 in middle

Up Coming

39 servoo+.loor