Вы находитесь на странице: 1из 15

SingularValueDecompositionApplied ToDigitalImageProcessing

LijieCao DivisionofComputingStudies ArizonaStateUniversityPolytechnicCampus Mesa,Arizona85212 EmailLijie.cao@asu.edu

ABSTRACT This project has applied theoryof linear algebra called singular value decomposition (SVD) to digital imageprocessing. Two specificareasofdigitalimageprocessingare investigatedandtested. Oneisdigitalimagecompression,andotherisfacerecognition. SVDmethodcantransformmatrixA into product USVT , which allows us to refactoring a digital image in three matrices. The using of singularvaluesofsuchrefactoringallowsustorepresenttheimagewithasmallersetofvalues,which can preserve useful features of the original image, but use less storage space in the memory, and achievetheimagecompressionprocess.Theexperimentswithdifferentsingularvalueareperformed, andthecompressionresultwasevaluatedbycompressionratioandqualitymeasurement. Toperform face recognitionwith SVD, we treatedthe setof known faces as vectors in a subspace, called face space, spanned by a small group of basefaces. The projection of a new image onto the baseface is thencomparedtothesetofknownfacestoidentifytheface. Alltestsandexperimentsarecarriedout byusingMATLABascomputingenvironmentandprogramminglanguage. KEY WORDS: Imageprocessing,ImageCompression,Facerecognition,Singularvaluedecomposition.

1.INTRODUCTION Image processing is any form of information processing, in which the input is an image. Image processing studies how to transform, store, retrieval the image. Digital image processingistheuseofcomputeralgorithmsto performimageprocessingondigitalimages. Many of the techniques of image processing were developed with application to satellite imagery, medical imaging, object recognition, and photo enhancement. With the fast computersandsignalprocessorsavailableinthe

the2000s,digitalimageprocessinghasbecome the most common form of image processing, and isgenerallyused because it is notonlythe mostversatilemethod,butalsothecheapest[6]. 1.1 DigitalImageProcessing An image can be defined as a twodimension functionf(x,y)(2Dimage),wherexandyare spatial coordinates, and the amplitude of f at any pair of (x, y) is gray level of the image at thatpoint.Forexample,agreylevelimagecan berepresentedas:

fij Where

fij f (x ,yj ) i

When x, y and the amplitude value of f are finite,discretequantities,theimageiscalleda digitalimage.Thefinitesetofdigitalvaluesis calledpictureelementsorpixels.Typically,the pixelsarestoredincomputermemoryasatwo dimensionalarrayormatrixof realnumber. Color images are formed by a combination of individual 2D images. Many of the image processing techniques for monochrome images can be extend to color image (3D) by processing the three components image individually [2]. Digital Image Processing (DIP) refers to processingadigital image by meanofadigital computer, andthe study of algorithms fortheir transformation. Since the data of digital image is in the matrix form, the DIP can utilize a number of mathematical techniques. The essential subject areas are computational linear algebra, integraltransforms,statisticsandother techniques of numerical analysis. Many DIP algorithms can be written in term of matrix equation,hence,computationalmethodinlinear algebra become an important aspect of the subject[3]. Digital Image processing encompasses a wide and varied field of application, such as area of image operation and compression, computer vision, and image analysis (also called image understanding). There is the consideration of three types of computerized processing: low levelprocessingischaracterizedbythatbothits inputs and outputs are images midlevel processing on images is characterized by the fact that its inputs are images, but outputs are attributes extracted from those images, while higherlevel processing involves making senseofanensembleofrecognizedobjectsas inimageanalysis,andperformingthecognitive functionassociatedwithhumanvision [3].

In particular, digital image processing is the practicaltechnologyforareaof: Imagecompression Classification Featureextraction Patternrecognition Projection Multiscalesignalanalysis 1.2Objectiveofthe Project The objective of this project is to apply linear algebra Singular Value Decomposition (SVD) to midlevel image processing, especially to areaofimagecompressionandrecognition.The method is factoring a matrix A into three new matrices U, S, and V, in such way T thatA =USV .WhereUandVareorthogonal matricesandSisadiagonalmatrix. The experiments are conducted under different term kof singular value, and the outer product expansion of image matrix A for image compression this project also demonstrates howtouseSVDapproachforimageprocessing inareaof FaceRecognition (FR). In this project, we assume a matrix A with m lines and n columns, m n, this assumption is made for convenience only, all the result will alsoholdifn m [8]. MATLAB is used as a platform of programming and experiments in this project, since MATLAB is a highperformance in integrating computation, visualization and programming. The reminder of this project is organized as follows: section2 describes the theory of SingularValueDecompositionthesection3 is methodology for applying SVD to image processing, section4 shows the experimentationsandresultsobtained.Section5 explains my own contribution to this project. Finally, section6 presents the conclusion and thefurtherworkproposed. 2

2THEORYOFSINGULARVALUE DECOMPOSITION 2.1ProcessofSingularValueDecomposition SingularValueDecomposition(SVD)issaidto beasignificanttopicinlinearalgebrabymany renowned mathematicians. SVD has many practical and theoretical values special feature ofSVD isthatitcan beperformedonanyreal (m, n) matrix. Lets say we have a matrix A withmrowsandncolumns,withrankrandr n m. Then the A can be factorized into three matrices: A =USVT (Seethefigure1forillustration) (1)

, 1,,i = j vTvj =dij = i , 0 ,,i j

(5)

Here, S is an m n diagonal matrix with singular values (SV) on the diagonal. The matrix Scanbeshowedinfollowing s1 0 0 s 2 M M 0 0 S= 0 0 M M 0 0 0 0 L L O L L O L L 0 0 M 0 0 M 0 L 0 L 0 O M L 0 L 0 O M L s n L 0

s r

0 s r+1 M M 0 0 0 0

(6)

For i = 1, 2, , n, s are called Singular Values i (SV)ofmatrixA.Itcanbeprovedthat

s s 2 L sr > 0,and 1 s r +1 = s r+ 2 = L= s N = 0.
T

(7)

Figure1.IllustrationofFactoringAtoUSV

WhereMatrix Uisan mm orthogonalmatrix

For i = 1, 2, , n, s are called Singular i Values(SVs)ofmatrixA.Thev sandu sare i i calledrightandleftsingularvectorsof A[1].

U =[ 1 ,u2,... r ,ur+1,...,um] u u

(2)

2.2Propertiesof theSVD There are many properties and attributes of SVD, here we just present parts of the propertiesthatweusedinthisproject. 1. Thesingularvalue s1 , 2, , n areunique, s s however, the matrices U and V are not unique T 2. Since A A = VSTSVT , so V diagonalizes T A A , it follows that the vj s are the T eigenvector of A A.

columnvectors u ,fori=1,2,,m,forman i orthonormalset:

1,,,i= j T u uj =dij = i , 0 ,,i j


Andmatrix Visan nn orthogonalmatrix

(3)

(4) column vectorsv for i = 1, 2, , n, form an i orthogormalset:

V =[v ,v2,... r ,vr+1,...,vn] v 1

T 3. Since AA =USSTUT ,soitfollowsthat U T diagonalizes AA and that theui s are the T eigenvectorsof AA . 4. IfAhasrankofrthenvj,vj,,vr forman T orthonormal basis for range space of A , T R(A ), and uj, uj, , ur form an orthonormalbasisfor.rangespaceA, R(A). 5. The rank of matrix A is equal to the numberofitsnonzerosingularvalues[4].

That is A can be represented by the outer productexpansion:


A=s 1 u v + s 2u2v2 + + s rurvr 1 1
T T T

(12)

3.

METHODOLOGYOFSVDAPPLIED TOIMAGEPROCESSING

When compressing the image, the sum is not performed to the very last SVs, the SVs with small enough values are dropped. (Remember thattheSVsareorderedonthediagonal.) The closet matrix of rank k is obtained by truncatingthosesumsafterthefirstk terms:
A =s 1 u1v + s 2u2v2 + + s kukvk k 1
T T T

3.1SVD Approachfor ImageCompression Image compression deals with the problem of reducing the amount of data required to represent a digital image. Compression is achieved by the removal of three basic data redundancies: 1) coding redundancy, which is present when less than optimal 2) interpixl redundancy, which results from correlations between the pixels 3) psychovisual redundancies, which is due to data that is ignoredbythehumanvisual [2]. Theproperty 5ofSVDinsection2tellsusthe rank of matrix A is equal to the number of its nonzerosingularvalues. Inmanyapplications, thesingularvaluesofamatrixdecreasequickly with increasing rank. This propriety allows us toreducethenoiseorcompressthematrixdata by eliminating the small singular values or the higherranks. When an image is SVD transformed, it is not compressed, but the data take a form in which thefirstsingularvaluehasagreatamountofthe imageinformation.Withthis,wecanuseonlya fewsingularvaluestorepresenttheimagewith littledifferencesfromtheoriginal. To illustrate the SVD image compression process,weshowdetailprocedures:
T A =USV =
r

(13)

Thetotalstoragefor A willbe k k(m+n+ 1) (14)

The integer k can be chosen confidently less then n, and the digital image corresponding to A still have very close the original image. k However, the chose the different k will have a differentcorrespondingimageandstorageforit. For typical choices of the k, the storage required for A will be less the 20 percentage. k In this project, experiment and testing for different k are carried out and the result will showin section 4. 3.2ImageCompressionMeasures TomeasuretheperformanceoftheSVDimage compression method, we can computer the compression factor and the quality of the compressed image. Image compression factor canbecomputedusingtheCompressionratio: CR =m*n/(k(m+n+1)) (15)

s u v
i= 1

T i i i

(11)

Tomeasurethequality betweenoriginal image A and the compressed image A , the k measurementofMeanSquareError(MSE)[10] canbecomputed:

MSE= 1

n A A k

(f (x,y)- f mn
y=1 x 1 =

(x y (16) , ))

f =

1 N fi N i=1

(18)

3.3 SVD ApproachforFaceRecognition Overthepastdecades,faceimagecompression, representation and recognition has drawn wide attention from researchers in arrears of computer vision, neural network, pattern recognition, machine learning, and so on. The applicationoffacerecognitionincludes: Access Control based on the face recognition, Computer human interaction, Information Security,Lawenforcement,SmartCaretc.[11] Several approaches to face recognition have been proposed for the 2dimensional facial recognition. Muchoftheworkhas focusedon detectingindividualfeaturessuchaseyes,nose, mouth, and head outline, and defining a face model by the position, size, and relationships amongthesefeatures[12][13]. SVD approach treats a set of known faces as vectors in a subspace, called face space, spannedbyasmallgroupofbasefaces[1].It likesPrincipalComponentAnalysis(PCA)[14], recognition is performed by projecting a new imageontothefacespace,andthenclassifying thefacebycomparingitscoordinates(position) infacespacewiththecoordinates(positions)of known faces. However, the SVD approach has betternumericalpropertiesthanPCA. Inthiscase,weredefinedthematrixAassetof the training face. Assume each face image has mn=Mpixels,andisrepresentedasanM 1 column vectorf , a training set S with N i number of face images of known individuals formsan MNmatrix: S =[ 1,f ,......, N ] f 2 f Themeanimage f ofsetS,isgivenby (17)

Subtracting f fromtheoriginalfacesgives
a =f - f, ,,i= 12 N , ,... i i

(19)

ThisgivesanotherMN matrix A: A=[ 1,a ,..., N ] a 2 a (20)

Since{u ,u ,...,u }formanorthonormalbasis 1 2 r forR(A),therange(column)subspaceofmatrix A. SincematrixAisformedfromatrainingset S with N face images, R(A) is called a face subspaceintheimagespaceofmnpixels, and eachu , i=1, ,...,r, can be called a base 2 i face.
T Let x (= [x ,x ,...,x ] ) be the coordinates 1 2 r (position)ofanymnfaceimagefintheface subspace. Then it is the scalar projection of f -f ontothebasefaces:

x =[u , u ,, u] (f -f) 1 2 r

(21)

This coordinate vector x is used to find which ofthetrainingfacesbestdescribesthe face f. That is to find some training facef , i i=1, ,...,N ,thatminimizesthedistance: 2
T 1 ei = x -xi 2 = [(x- xi) (x- xi)] /2

(22)

wherex isthecoordinatevectorof f ,whichis i i the scalar projection of fi -f onto the base faces: x =[u ,u ,,u] (fi -f) i 1 2 r
T

(23)

A face f is classified as face f when the i minimum ei is less than some predefined

thresholde0 . Otherwise the face f is classified asunknownface. If f is not a face, its distance to the face subspacewillbegreaterthan0.Sincethevector projection of f -f ontothe face space is given by
fp = [ 1,u ,... r]x u 2 u

ReadImage Data

FromTraining Set? Yes Computethemean face f

(24)

wherexisgivenin(21). The distance of f to the face space is the distance between f -f and the projection fp ontothefacespace:

a i = fi - f
CreateA

No

ef = (f - f - fp 2 = [( - f- fp) ( - f - fp)] ) f f

1 2 /

(25) If ef isgreaterthansomepredefinedthreshold

CalculatetheSVD of A

e ,then fisnotafaceimage. 1
3.4 StepstoConduct FRwithSVD TheflowchartforfacerecognitionwithSVDis showed in the Figure2. The explanations of eachstepasfollowing: 1. Obtain a training set S with N face imagesofknownindividuals. 2. Computethemeanface f of Sby(18)

Compute the vectorxi inbase space

Compute the vectorx inbase space

ei = x-xi

ei e0 ?
Yes No

3. Forms a matrix A in (20) with the computed f. 4. CalculatetheSVDof Aasshownin(1) 5. Foreachknownindividual,computethe coordinatevectorx from(23).Choosea i threshold e that defines the maximum 1 allowable distance from face space. Determine a threshold e0 that defines the maximum allowable distance from anyknownfaceinthetrainingsetS.

Face INthe trainingset

Face NOTIN thetrainingset

Figure2.FlowchartofFaceRecognition withSVD 6. Foranewinputimageftobeidentified, calculate its coordinate vector x from (21), the vector projection fp , the

distance ef tothefacespacefrom(25). If ef > e theinputimageisnotaface. 1 7. If ef < e , compute the distance ei to 1 each known individual. If all ei > e0 , the input image may be classified as unknown face, and optionally used to beginanewindividualface.If ef < e , 1 and some ei < e0 , classify the input image as the known individual associated with the minimum ei (x), i and this image may optionally added to the original training set. Steps 15 may berepeated.Thiscanupdatethesystem withmoreinstancesofknownfaces[1]. 4.EXPERIMENTATIONSANDRESULTS 4.1ResultofExperimentationsfor Image Compression Figure3showsexamplesofimagesusedforthe system tests under different K terms. i) shows theoriginalimageswhereasa)showstheresults of the reconstruction image using 10 singular values,andc)showstheresultsusing20values andsoon. Theobservationonthoseexamples, we found when k1 20, the images are blurry and with the increase of singular values we have a better approach to the original image. Table1showsasummaryoftheresultsobtained with the measure ofthe storage space, and the errormeasuresforthetestedimages. d) K=25 e) K=30 f) K=40

g) Original Figure3. Examples of a Image Used to Test ImageCompressing Table1. Summery of the Result for Image Compression K Storage CR MSE Space (bytes) Comp (Quality) 10 2050 5.03 108.11 15 3075 3.35 63.15 20 4100 2.51 40.39 25 5125 2.01 27.22 30 6150 1.68 15.64 40 8200 1.26 9.07 original 10304 1 Withtheresultsfromtable1,wehavecoupleof theobservations: 1. Usinglesssingularvalue(smallerK),the. better compressionratioisachieved 2. However,themoresingularvalueisused (largerK),qualitymeasurementMSE is smaller(betterimagequality),andthe reconstructedimagesaremoreequalto theoriginal,butusingmorestorage space. 3. Forthetestingimage,theacceptable imagequality isaboutwithk=25,and compressionratioisCR =2.01. 4. Theimageclosetooriginal imagewhen k=40.AtthispointCR=1.26,and MSE=9.07. 7

a) K=10

b)K=15

c) k=20

4.2ResultsforFaceRecognitionwithSVD The test is under the training set with image Size: M = 92 x 112 = 10,304, the number of known individuals: N = 20, Different Conditions:Allfrontalandslighttiltofthehead, differentfacialexpressions. Essentially,afaceimageisof M(say10,000) dimension.Buttherankrofmatrix Aisless thanorequalsN.Formostapplications,a smallernumberofbasefacesthan rare sufficientforidentification.Inthisway,the amountofcomputationisgreatlyreduced.The followingfiguresshowthebasefaceimage, theaverageoftrainingsetimage,andthe trainingsetimageweusedforthisexperiment.

5MYCONTRIBUTIONTOTHIS PROJECT Thispartisaspecialsectionwhichemphasizes mycontributiontothisproject. Asummeryof mycontributionislistfollowing: 1. testedandevaluatedthedigitalimage compressionunderdifferentktermsby usingSVDtheory 2. Recodedtheprogramofface recognitionbyapplyingmatrices operationintheMATLABandreduced thelinesofthecode, testeditwith20 faceimages 3. Investedthecharacteristicsofsingular valuesandsingularvectorsintheimage processing. Moredetailexplanationswillbegivenbelow 5.1ExperimentsonCharacteristicsofSVD Indigitalimageprocessing,imagefeaturesare dividedintofourgroups:visualfeatures, statisticalpixelfeatures,transformcoefficient features,andalgebraicfeatures.SVDtechnique canbeconsideredasan algebraicfeature[16]. Thealgebraicfeaturesusuallyrepresent intrinsicproperties. Refertosection2.2thefirstpropertyofSVDis that: thesingularvalues s1 , 2, , n are s s unique,butthematricesUandV arenotunique

Figure4.TrainingSetImages

Dr.Zengwasinterestedinthatthesingular valuesaremoreimportantsinceitsuniqueness itisnaturallythinkingthatSVsisthemost importantattributeofimagematrix.Itcouldbe usedforrecognition. However,withexperimentsonexchangethe SVsoftwoimages,theresultisveryinteresting anditshowsthatthesingularvectors(leftand right)aremoreimportantforreconstructionof theoriginalimage. Thefirstexperimentwasdesignedtousetwo personsfaceimages,onwhichweperformed 8

Figure5. A Computed Mean Face Image of TrainingSetImages

SVDdecomposition.Forexample,theface imagesofJanet(A1)andAndy(A2)was decomposedintoU,S,V sothat: A1=U1* S1*V1T A2=U2*S2*V2T Thenwedidthecombinationofthesingular valuesandsingularvectors,theresultshowsin theFigure7.

Infigure6,a)showsthecombinationof U1* S1*V1T,whichisanoriginalimageofJanet. However,whenwecombinedJanetsSVswith Andyssingularvector,itshowsAndysface image(seefigure6d)).Theimagehasdifferent brightnesswithAndysoriginalimage. e) showsJanetsface,butitisacombinationof AndysSVsandJanetssingularvectors. Whenwecombinedtwopairofsingularvectors UandV,whicharefromtwoimages respectively,theoutcomeimageslooklikea ghost.Theresultshowinb),c),f)andg), Wealsotestedthetwoimages,oneisaface imageandotherisnotafaceimage(e.g. flower).Theexperimentation showedthesame resultastwofaceimages. Fromtheresultweseethat, thoughthesingular valuesareuniqueinSVDdecomposition,but thesingularvictorsaremoreimportantfor imagerecognition. Thisfactindicatesthat deeply research andfurtherinvestigation on characteristicsofSVDinimageprocessingare necessary. 5.2CodingWith MATLAB MATLABisanumericalcomputing environmentandallowseasymatrix manipulation.Manybuiltinfunctionsarefor imageprocessing.Itisusedtotestnewimage processingtechniquesandalgorithms.Almost everythingin MATLABisdonethrough programmingandmanipulationofrawimage data [6] MATLABdoesincludestandard"for"and "while"loops,butusingMATLAB'svectorized notationoftenproducescodethatiseasierto readandfastertoexecute.

a.)Combinationof U1*S1*V1

b.)Combinationof U1*S1*V2

c.)Combinationof U2*S1*V1

d).Combinationof U2*S1*V2

e).Combinationof U1*S2*V1

f.)Combinationof U1*S2*V2

g).Combinationof U2*S2*V1

h).Combinationof U2*S2*V2

Figure6.ResultofExchangedSingularValue withSingularVectors 9

Inthisproject,facerecognitionusingSVD werecodedwithMATLAB.Theprograms utilizematricesoperation tomanipulatedatato reduceforloops,whichreducelinesofthe

code. ThesourcecodeisinAppendix,for comparisonpurpose,theoldprogramforface recognitionalsoisattachedinAppendix. Followingispartialdemonstrationofusing matricesoperationinmyprogram: function [ef,d]= svdRecognition0(newName,


r,N,A,U,S,V,fbar,e0,e1) %newName='janet1.tiff'r=#ofsv chosen Ur=U(:,1:r) X=Ur'*A fnew=imread(newName) fnew=imresize(fnew,[112,92]) f=reshape(fnew,10304,1) f0=double(f)fbar x=Ur'*f0fp=Ur*x ef=norm(f0fp) ifef<e1 D=Xx*ones(1,N) d=sqrt(diag(D'*D)) [dmin,indx]=min(d) ifdmin<e0 fprintf(['Thisimageisface #',num2str(indx)]) else fprintf('Theinputimageisan unknownface') end else fprintf('Theinputimageisnota face') end

x1

x x 11 21 x x 12 22 = ,x2 = , ... ... x r 1 x r 2 x 1 x x = 2 ... x r

xN1 x xN = N2 ... xNr

and

When computing the distance of each points betweenthetrainingsetandtestingimage, D=X x*ones(1,N) Inordertohaveagreeddimensionstooperate thematrixXandvector x ,weneedtotransfer thevectorx tothematrixformbyoperation x*ones(1,N), x 1 x x*ones(1,N) = 2 [1,1,1] ... x r x x ... x 1 1 1 x x ... x 2 = 2 2 ... ... ... ... x x ... x r r r (rxN) Sothatthecoordinatesdistancematrixbetween thetestingimageandeachimageinthetraining set D= [D1,D2, ,DN] Where x -x 1 11 12 2 x - x D1= ... xr - x 1 r 10

Theconsiderationforusingmatrixoperationsis thattheinnermatrixdimensionsmustagree,In theprogramabove,UisaMxMrightmatrixof singularvaluedecompositionofA(MxN),Ur is M x r matrix that are formfromU (r is the number of singular values we chosen). X=Ur*A is the coordinates (position) matrix thatistherxNdimensionsfortrainingsetA. x isacoordinatesvectorintherxN subspacefor testing image. Here: X=Ur*A =[Ur*a1,Ur*a2,,Ur*aN] =[x1, x2, , xN] Where

xN1 -x 1 2 xN2 - x DN = ... xNr - x r

Theminimizeddistancebetweentrainingface andtestingimage: d=sqrt(diag(D'*D)) Where


D 1 D D'*D= 2 [D1,D2, ,DN] ... DN D 'DN D 'D 1 1 1 ... D 'D 2 2 = ... ... DN 'DN DN 'D 1

SVD has the advantage of providing a good compressionratio,andthatcanbewelladapted to the statistical variation of the image but it hasthedisadvantagethatitis notfastfromthe computational point of view, and the problem of which its application is strongly conditional due to the excessive work of associate calculations. The result obtained for image compressing has satisfactory of image compression ratio comparewithimagequalitytheresultsforface recognition with a small error percentage compare recognition using the original image dimensions. The face recognition test performed using the image that project into facebase show that it is necessary to improve thealgorithmtoworkwithcomplexobjects. Someofimagesaresimplesothatonlyneedsa fewsingularvaluestoobtaintheapproximation, andthecomplexpartsneedstousemorevalues tomaintaintheirquality.Wecanconcludethat the image does not require a same k in its totality. Overall, The SVD approach is robust, simple, easy and fast to implement. It works well in a constrainedenvironment.Itprovidesapractical solution to image compression and recognition problem. Instead of searching a large database of faces, by using basefaces, this small set of likely matches for given images can be easily obtained. Future work consists three aspects, one is to work on more complex image such as vary large size 2D image or 3D images with SVD technique for image compression and recognition second, deeply to study and investigate the roles of singular values and singularvectorsinimageprocessing.Third,this application is completed on the MATLAB, in the future the application can be performed with programming of Java or C++, so that the realtimeimageprocessingcanbeachieved.

diag(D'*D)= [D 'D , D 'D , ... D 'D ] 1 1 2 2 N N Therefore d=sqrt(diag(D'*D)) is a vector of the minimized distance between trainingfaceimagesandtestingimage. Thecodeforimagecompressionandcomputing theMSEforimagecompressionarealsointhe Appendix.

6. CONCLUSIONANDFUTUREWORK This project has applied technique of linear algebra singular value decomposition (SVD) todigitalimageprocessing. Twospecificareas of imageprocessingareinvestigatedandtested. Basis on the theory and result of experiments, we found that SVD is a stable and effective methodtosplitthesystemintoasetoflinearly independent components, each of them is carrying own data (information ) to contribute tothe system, Thus, both rankof the problem andsubspaceorientationcanbedetermined.

11

REFERENCES [1]GuoliangZeng, FaceRecognitionwith SingularValueDecomposition.,CISSE Proceeding,2006 [2] RafaelC.Gonzalez,RichardE.Woods, StevenL.Eddins,DigitalImage ProcessingUsingMatLab,PrenticeHall, 2006 [3] BerndJahne,DigitalImageProcession, Springer,2002 [4] SteveJ.LeonLinearAlgebrawith Applications, Macmillan Publishing Company,NewYork1996 [5] S.G.Kong,J.Heo,B.R.Abidi,J.Paik,and M.A.Abidi.Recentadvances invisualandinfraredfacerecognitiona review.ComputerVisionandImage Understanding,97(1):103{135,2005. [6] Wickpidia,.DigitalImageprocessing, availableat http://en.wikipedia.org/wiki/Digital_image_p rocessing [7] L.Wiskott,J.Fellous,N.Kruger,andC. vonderMalsburg.Facerecognitionby elasticbunchgraphmatching.IEEETrans. PatternAnal.Mach.Intelligence, 19(7):775{779,1997. [8] MandeM.,SingularValueDecomposition, Department of computer science of the Technological Institute of Bombay India, august2003. [9] A.M.MartinezandA.C.Kak.Pcaversus lda.IEEETrans.PatternAnal. Mach.Intelligence,23(2):228{233,2001 [10] MrakM.,GrgicS.andGrgicM.,Picture Quality Measures in image compression systems, IEEE EUROCON, Ljubljana, Eslovenia,September2003.

[11] S.G. Kong, J. Heo, B.R. Abidi, J. Paik, and M. A. Abidi. Recent advances in visual and infrared face recognitiona review. Computer Vision and Image Understanding,97(1):103{135,2005. [12] T.Kanade,PictureProcessingSystem byComputerComplexandRecognition of Human Faces, Department of Information Science, Kyoto University, Nov.1973. [13] A. L. Yuille, D. S. Cohen, and P. W. Hallinan,FeatureExtractionfromFaces Using Deformable Templates, Proc. CVPR,SanDiego,CAJune1989. [14] MatthewA.Turk,PentlandP. Alex(1991), Face Recognition using Eigenface method, IEEE Conference on ComputerVisionandPatternRecognition, pp.586591,1991. Appendix PartialSourcecode: 1.codeforfacerecognition
function[ef,d]= svdRecognition0(newName,r,N,A,U,S, V,fbar,e0,e1) %newName='janet1.tiff'r=#ofsv choosed Ur=U(:,1:r)X=Ur'*A fnew=imread(newName) fnew=imresize(fnew,[112,92]) f=reshape(fnew,10304,1) f0=double(f)fbar x=Ur'*f0 fp=Ur*x ef=norm(f0fp) ifef<e1 D=Xx*ones(1,N)d= sqrt(diag(D'*D))[dmin, indx] = min(d) ifdmin<e0 fprintf(['Thisimageisface #',num2str(indx)]) else

12

fprintf('Theinputimageisan unknownface') end else fprintf('Theinputimageisnota face') end function[A,U,S,V,fbar,basefi]= svdDecomp(fileName,N) %fileName='imageset.txt' fid=fopen(fileName) S=zeros(10304,N) fori=1:N face=fgetl(fid) fi=imread(face) subplot(ceil(sqrt(N)),ceil(sqrt(N)),i) fprintf(1,'%s.\n',face) figure(1)imshow(fi) fi= double(reshape(fi,10304,1)) S(:,i)=fi end fbar=(mean(S'))' figure(2)imshow(reshape(uint8(fbar), 112,92)) A=Sfbar*ones(1,N) [U,S,V]=svd(A,0)

[u1,s1,v1]=svd(double(A1)) [u2,s2,v2]=svd(double(A2)) combinf1=uint8(u1*s1*v1') figure(1)imshow(combinf1) title('combinationofu1*s1*v1') combinf2=uint8(u1*s1*v2') figure(2)imshow(combinf2) title('combinationofu1*s1*v2') combinf3=uint8(u2*s1*v1') figure(3)imshow(combinf3) title('combinationofu2*s1*v1') combinf4=uint8(u2*s1*v2') figure(4)imshow(combinf4) title('combinationofu2*s1*v2') combinf5=uint8(u1*s2*v1') figure(5)imshow(combinf5) title('combinationofu1*s2*v1') combinf6=uint8(u1*s2*v2') figure(6)imshow(combinf6) title('combinationofu1*s2*v2') combinf7=uint8(u2*s2*v1') figure(7)imshow(combinf7) title('combinationofu2*s2*v1') combinf8=uint8(u2*s2*v2') figure(8)imshow(combinf8) title('combinationofu2*s2*v2')

3. CodeforImageCompressionandMSE
functionAK=svdPartSum(A,K) A=double(A) [u,s,v]=svd(A) AK=u(:,1:K)*s(1:K,1:K)*v(:,1:K)' AK=uint8(AK) imshow(AK) function[MSE,MSEA,m,n]=ComputMse(A, AK) m=size(A,1) n=size(A,2) e=0.0 MSEA=0.0 A=double(A) AK=double(AK) for i=1:m forj=1:n e=(A(i,j)AK(i,j))^2 MSEA=MSEA+e end end MSE=MSEA/(m*n)

2. Codefor ExchangeSingularValueand SingularVectors


function [A1,A2]=SVDExchange(Image1,Image2) A1=imresize(imread(Image1),[112,92]) A2=imresize(imread(Image2),[112,92]) s1=size(A1)%findoutthesize oftheimage s2=size(A2) ss1=size(s1) ss2=size(s2) ifss1(:,2)==3%ifthe imageisacolorimageinjpegorjog formatnitwillcoverttothegrey scale A1=rgb2gray(A1) end ifss2(:,2)==3%ifthe imageisacolorimageinjpegorjog formatnitwillcoverttothegrey scale A2=rgb2gray(A2) end

4 OldProgramforFaceRecognition
clear clc

13

Filename='trainingset.txt' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%vv %thisfunctiongetrsthetraining faceswhichisstoredinatextfile %andstoretheminanarray'face'% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% num=25 fid=fopen(Filename)%openafile images=zeros(10304,num) fori=1:num face=fgetl(fid) readface=imread(face)% readimagefromgraphicfileand returnimagedatainarray s=size(readface)%findout thesizeoftheimagearrey ss=size(s) ifss(:,2)==3%ifthe imageisacolorimageinjpegorjog formatnitwillcoverttothegrey scale readface= rgb2gray(readface) end readface=imresize(readface, [112,92]) readface =(reshape(readface,10304,1))% reshapethe92*112vectorasasingle columnof10304 images(:,i)=readface% facescontain"num"numberofimages end faces=images S=size(faces,2)%Determin thenumberoffacesselected,2isdem ofthefaces,returnsthesizeofthe dimensionoffaceindim2 %psi=(mean(faces'))'% deturminetheavgfaceofallthe trainingfaces psi=mean(faces,2) fori=1:S phi(:,i)=faces(:,i)psi %substructeachofthetraining facesfromavgface end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %

%[U,S,V]=svd(X,'econ')also producesthe"economysize" decomposition. %IfXismbynwithm>=n,it isequivalenttosvd(X,0). %Form<n,onlythefirstm columnsofVarecomputedandSism bym %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%% [usigvt]=svd(phi,'econ') %[usigvt]=svd(phi) si=svd(sig) tol= max(size(sig))*eps(max(si)) r=sum(si>tol) %r=rank(sig) %tol= max(size(A))*eps(max(s)) %r=sum(s>tol) [rowcol]=size(sig) new_u=u(:,1:r) fclose(fid) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% %projectofimageontothe facespace %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% fid=fopen(Filename) images=zeros(10304,num) fori=1:num face=fgetl(fid) readface=imread(face) s=size(readface) ss=size(s) ifss(:,2)==3%iftheimage isacolorimageinjpegorjog formatnitwillcoverttothegrey scale readface= rgb2gray(readface) end readface=imresize(readface,[112,92]) readface= double(reshape(readface,10304,1)) proj=new_u'*(readface psi) proj_matrix(:,i)=proj' end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%% %Testtheimage

14

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%% test=imread('test3.tif') TestFace= imresize(test,[11292]) TestFace= double(reshape(TestFace,10304,1)) ProjTestFace=new_u' *(TestFacepsi) fori=1:num TestMatrix(:,i)= proj_matrix(:,i)ProjTestFace DistanceMatrix(:,i)= sqrtm(TestMatrix(:,i)'* TestMatrix(:,i)) end [rowcol]= size(DistanceMatrix) for i=1:row evalMatrix(1,i)= DistanceMatrix(i,i) end [miindex]= min(evalMatrix)%Minimumelementsof anarray fid=fopen(Filename) fori=1:index face=fgetl(fid) end figure(3) subplot(2,2,1) imshow(test) title('Input Image', 'fontsize', 10) subplot(2,2,2) imshow(face) title('Retrived Image','fontsize',10) i=1:size(evalMatrix,2) subplot(2,2,3) stem(i,evalMatrix) functionfaces= getfaces(Filename,num) fid=fopen(Filename) images=zeros(10304,num) fori=1:num face=fgetl(fid) readface=imread(face)% readimagefromgraphicfileand returnimagedatainarray

subplot(ceil(sqrt(num)),ceil(sqrt(num) ),1) fprintf(1,'%s.\n',face) readface= (reshape(readface,10304,1)) figure=readface end face=images readface= double(reshape(readface,10304,1))

15

Вам также может понравиться