{VERSION 3 0 "APPLE_PPC_MAC" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 }{PSTYLE " Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading \+ 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 3" 4 5 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 0 1 0 0 0 0 0 0 0 0 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 }{PSTYLE " Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE " " -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Plot" 0 13 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {SECT 0 {PARA 3 "" 0 "" {TEXT -1 12 "Introduction" }}{PARA 0 " " 0 "" {TEXT -1 312 "This worksheet demonstrates some of the key conce pts associated with recognizing images based upon nearest neighbor com parisons in the Eigenspace associated with a set of training images. \+ This has been prepared to go with CS510 and the text \"Introductory Te chniques for 3-D Computer Vision\" by Trucco and Verri." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 605 "A series of these w orksheets have been made available showing slightly different test cas es. This is the fourth in the series. This worksheet shows a three di fferent patterns, one per image class, which are unchanging at the cen ter of an image. However, the background of the image is selected at r andom from one of the three patterns used in the earlier worksheets. \+ Two significant facts are brought to light by this example. First, the first two priniciple components provid little or no information relev ant to classification. However, the third and four principle componets do separate the classes. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Ross Beveridge April 27, 1999" }}} {SECT 0 {PARA 3 "" 0 "" {TEXT -1 15 "Initializations" }}{PARA 0 "" 0 " " {TEXT -1 20 "Libraires used here." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "with(linalg):\nwith(stats):\nwith(plots):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 7 "" 1 "" {TEXT -1 32 "Warning, new defi nition for norm" }}{PARA 7 "" 1 "" {TEXT -1 33 "Warning, new definitio n for trace" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 240 "Here are some glo bal variables used to adjust how this worksheet behaves. It is thus p ossible to change the size of the test images, the low and high values in these images, the number of instances of each class in the trainin g data, etc. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 269 "imageSize := 9; # The row and column dimension of the images\nimageLow \+ := 2.0; # The low value in the test imagery\nimageHigh := 7.0; # The high value in the test imagery\ntrainingSize := 15; # The \+ number of training images. Should be a multiple of 3." }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*imageSizeG\"\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%)imageLowG$\"#?!\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*ima geHighG$\"#q!\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%-trainingSizeG \"#**" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 23 "Some Library Procedure s" }}{PARA 0 "" 0 "" {TEXT -1 238 "The followling procedures are helpf ul for working viewing images and vectors in this worksheet. They are \+ not by themselves interesting. At the end is commented out expression \+ which will display all the images together, one row per class. " }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 400 "displayMatrixAsImage := pro c(A,maxVal)\n local rs, cs, i, j, Poly, val:\n Poly := [];\n for i from 1 to rowdim(A) do\n for j from 1 to coldim(A) do\n \+ val := convert(A[i,j] / maxVal,float):\n Poly := [op(Poly), \n POLYGONS([[i, j, A[i,j]], [i, j+1, A[i,j]], [i+1, j+1, A[i ,j]], [i+1, j, A[i,j]]],\n COLOR(RGB,val,val,val))]: \n od:\n od:\n Poly:\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 503 "displayMatrixAsImageAppend := proc(Lst, A, maxVal, o ffr, offc)\n local rs, cs, i, j, ri, ci, val, Poly:\n Poly := Lst: \n for i from 1 to rowdim(A) do\n for j from 1 to coldim(A) do \n val := convert(A[i,j] / maxVal,float):\n ri := i + offr:\n ci := j + offc:\n Poly := [op(Poly), \n \+ POLYGONS([[ri, ci, A[i,j]], [ri, ci+1, A[i,j]], [ri+1, ci+1, A[i,j]], [ri+1, ci, A[i,j]]],\n COLOR(RGB,val, val,val))]:\n od:\n od:\n Poly:\nend:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 846 "displayImages := proc(imageList,maxVal,Class) \n local i, samples, ims, offr, offc:\n ims := []:\n samples := floor(trainingSize/3):\n if (Class = 1) then\n offr := 0: \n offc := 0:\n for i from 1 to samples do\n ims := \+ displayMatrixAsImageAppend(ims,imageList[i],maxVal,offr, offc):\n \+ offc := offc + imageSize + 2:\n od:\n elif (Class = 2) then\n offr := imageSize+2:\n offc := 0:\n for i from samp les + 1 to 2*samples do\n ims := displayMatrixAsImageAppend(ims, imageList[i],maxVal,offr, offc):\n offc := offc + imageSize + 2: \n od:\n else\n offr := 2*(imageSize+2):\n offc := 0:\n for i from 2*samples+1 to 3*samples do\n ims := displa yMatrixAsImageAppend(ims,imageList[i],maxVal,offr, offc):\n offc := offc + imageSize + 2:\n od:\n fi:\n ims:\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 85 "#display(displayImages(trainImages, 20,3),orientation=[0.0,0.0],scaling=CONSTRAINED);\n" }}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 23 "Fix Precision of Floats" }}{PARA 0 "" 0 "" {TEXT -1 281 " Maple is awkward in its display of floats. Unless one \+ actually changes the precision, it appears impossible to change the wa y the pretty printer does display. The following routine is used to re duce the precision of elements in arrays so they print in a relatively compact form. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 192 "roundSig Digits := proc(x,d)\n local val, saveDigits:\n saveDigits := Digit s:\n Digits := d:\n val := convert(round(x*10^d)/10^d,f loat):\n Digits := saveDigits:\n val:\nend:" }}}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 24 "Generate Training Images" }}{PARA 0 "" 0 "" {TEXT -1 426 "Let us create a vector of training images based upon \+ three random image generators. Each of these will generate an image b ased upon a particular pattern plus noise. The noise is Gaussian with \+ zero mean and sigma 1.0. The images are four pixels on a side. The fir st class has a bright square in the center, the second class is altern ating bright and dark vertical bars, class 3 is alternating bright and dark horizontal bars. " }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 21 "Add No ise to an Image" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 175 "addNoise := proc(A,n)\n local noise, i, j:\n for i from 1 to n do\n f or j from 1 to n do\n A[i,j] := A[i,j] + random[normald]():\n \+ od:\n od:\n eval(A):\nend:" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 17 "Image Backgr ounds" }}{PARA 0 "" 0 "" {TEXT -1 99 "Use the three patterns that had \+ been image classes in earlier worksheets as changeable backgrounds." } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 190 "imageBack1 := proc(n,low,high)\n local A, i, j:\n A := matrix (n, n, low):\n for i from 2 to n-1 do \n for j from 2 to n-1 do\n A[i,j] := high:\n od:\n od:\n addNoise(A,n):\n end:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 191 "imageBack2 := proc(n,low,h igh)\n local A, i, j:\n A := matrix(n, n, low):\n for i from 1 to n do \n for j from 1 to n by 2 do\n A[i,j] := high:\n od :\n od:\n addNoise(A,n):\n end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 191 "imageBack3 := proc(n,low,high)\n local A, i, j:\n \+ A := matrix(n, n, low):\n for j from 1 to n do \n for i from 1 to n by 2 do\n A[i,j] := high:\n od:\n od:\n addNoise(A,n): \n end:" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 24 "Image Classes 1, 2 \+ and 3" }}{PARA 0 "" 0 "" {TEXT -1 177 "The first image class is a rand om background with a T shape. The second class is a random background with a + shape, and class three is a random background with updside d own T." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 868 "imageClassInstanc e := proc(n,l,h,class,brighter)\n local A, i, j, randBack, Backs, hig h, low:\n randBack := rand(1..3):\n Backs := [imageBack1(9,imageL ow,imageHigh), imageBack2(9,imageLow,imageHigh), imageBack3(9,imageLow ,imageHigh)]:\n A := Backs[randBack()];\n high := h + brighte r:\n low := l + brighter:\n if (class = 1) then\n A[4,4] := low: A[4,5] := low: A[4,6] := low:\n A[5,4] := high: A[5,5] := low: A[5,6] := high:\n A[6,4] := high: A[6,5] := low: A[6,6] := high :\n elif (class =2) then\n A[4,4] := high: A[4,5] := low: A[4,6] := high:\n A[5,4] := low: A[5,5] := low: A[5,6] := low:\n A[ 6,4] := high: A[6,5] := low: A[6,6] := high:\n else\n A[4,4] := \+ high: A[4,5] := low: A[4,6] := high:\n A[5,4] := high: A[5,5] := low: A[5,6] := high:\n A[6,4] := low: A[6,5] := low: A[6,6] := low:\n fi:\n eval(A):\n end:" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 35 "Procedure to create Training Images" }}{PARA 0 "" 0 "" {TEXT -1 124 "As currently setup, this procedcure produces 9 training images , 3 from each class. The are ordered from class 1 to class 3. " }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 495 "trainingImages := proc(size ,n,low,high)\n local samples, data, k, s:\n samples := floor(size/ 3):\n data := vector(3*samples):\n k := 1:\n for s from 1 to samples do\n data[k] := imageClassInstance(n,low,high,1,10) :\n k := k + 1:\n od:\n for s from 1 to samples do\n dat a[k] := imageClassInstance(n,low,high,2,10):\n k := k + 1:\n od :\n for s from 1 to samples do\n data[k] := imageClassInstance( n,low,high,3,10):\n k := k + 1:\n od:\n eval(data):\nend:" }} }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 37 "Global call to create Training \+ Images" }}{PARA 0 "" 0 "" {TEXT -1 197 "Here we bind T to the vector o f training images. Note that the precision is alterred so that there a re only 2 digits right of the decimal. Also note that the default sett ing is saved and restored. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 150 "saveDigits := Digits:\nDigits := 3:\ntrainImages := t rainingImages(trainingSize,imageSize,imageLow,imageHigh):\nDigits \+ := saveDigits:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "#eva l(trainImages);" }}}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 17 "Images to V ectors" }}{PARA 0 "" 0 "" {TEXT -1 73 "Go down the list of training im ages and convert these to column vectors. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 503 "This procedure takes advantage of some nice features of Maple. First, if you convert an nxn matrix t o a vector, it automatically unrolls the elements in exactly the manne r we want. The result is a true Maple vector. Next, you can normalize \+ the vector to be of unit length with one comand. Next, when you conve rt that vector to a matrix, it assumes you want a column vector, which in this case works out well for display purposes. At this step, we wi ll also subtract off the mean from each image vector." }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 36 "Procedure to Compute the Mean Vector" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 95 "meanXcv := proc(size,X)\n \+ local i:\n scalarmul(evalm(sum(eval(X)[i],i=1..size)),1/size):\nend: " }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 45 "Procedure to Map images to \+ normalized vectors" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 300 "mapIm agesToVectors := proc(size,n,Images)\n local s, X, Xmu:\n X := vec tor(size):\n for s from 1 to size do\n X[s] := convert(normaliz e(convert(Images[s],vector)),matrix):\n od:\n Xmu := meanXcv(size, X):\n for s from 1 to size do\n X[s] := evalm(X[s] - Xmu):\n \+ od:\n eval(X):\nend:\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 35 "Actually Perform Mapping to Vectors" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "Xcvs := mapIm agesToVectors(trainingSize,imageSize,trainImages):\n" }}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 43 "Make a version which is better for printi ng" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 130 "Xcvsr := vector(train ingSize):\nfor i from 1 to trainingSize do\n Xcvsr[i] := map(roundSi gDigits,Xcvs[i],3):\nod:\n#X = eval(Xcvsr);" }}}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 32 "Brute \+ Force, Look at Correlation" }}{PARA 0 "" 0 "" {TEXT -1 163 "Let us com pute the cross correlation between all pairs of images. Note that we w ill go back to original images, do the normalization, but do NOT remov e the mean. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 363 "imageCross Correlations := proc(size,n,Images)\n local s1, s2, X, CC:\n CC := matrix(size,size):\n for s1 from 1 to size do\n for s2 from 1 \+ to size do\n CC[s1,s2] := roundSigDigits(dotprod(normalize(con vert(Images[s1],vector)),\n \+ normalize(convert(Images[s2],vector))),3):\n od:\n od:\n ev al(CC):\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "CC := imag eCrossCorrelations(trainingSize,imageSize,trainImages):\n#CC = eval(CC );" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 30 "Covariance for Training I mages" }}{PARA 0 "" 0 "" {TEXT -1 148 "Now we are ready to compute the actual numeric covariance matrix for our training images. To start, w e want to create the X matrix defined in trucco" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 29 "Procedure to create X matrix." }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 230 "mapVectorsToX := proc(size,n,Xcvs)\n local \+ X, V, col, i:\n X := matrix((n*n),size):\n for col from 1 to size \+ do\n V := Xcvs[col]:\n for i from 1 to (n*n) do\n X[ i,col] := V[i,1]:\n od:\n od:\n eval(X):\nend:" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 37 "Actually create the Covariance Matrix" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 246 "saveDigits := Digits:\nDigi ts := 10:\nXm := mapVectorsToX(trainingSize,imageSize,Xcvs ):\ncoVar := evalm(Xm &* transpose(Xm)):\nDigits := saveDigit s:\n#X = map(roundSigDigits,eval(Xm),3);\n#Omega = map(roundSigDigits, eval(coVar),3);" }}}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 33 "Eigen Vecto rs for Training Images" }}{PARA 0 "" 0 "" {TEXT -1 101 "Using Single V alue Decomposition, compute the Eigen Vectors and Eigen Values for the training images." }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 53 "Use SVD to g enerate rotation matrix and eigen values" }}{PARA 0 "" 0 "" {TEXT -1 184 "The call to Svd will perform singular value decomposition on the \+ covariance matrix. The result are the elements of the diagonal matrix, as well as the pre- and post-multiply matrices: " }{XPPEDIT 18 0 "Um; " "6#%#UmG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "Vm;" "6#%#VmG" }{TEXT -1 3 ". " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 109 "Um := matrix(i mageSize*imageSize,imageSize*imageSize):\nVm := matrix(imageSize*image Size,imageSize*imageSize):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 176 "Lambda := evalf(Svd(coVar,Um,Vm)):\nDm := matrix(imageSize*imageS ize,imageSize*imageSize,0.0):\nfor i from 1 to imageSize*imageSize do \+ Dm[i,i] := roundSigDigits(Lambda[i],3): od:" }}}{SECT 0 {PARA 5 "" 0 " " {TEXT -1 25 " Show the diagonalization" }}{PARA 0 "" 0 "" {TEXT -1 51 "Show the diagonalization as well as the check that " }{XPPEDIT 18 0 "Omega = U*D*U^T;" "6#/%&OmegaG*(%\"UG\"\"\"%\"DGF')F&%\"TGF'" } {TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 244 "coVar3 := \+ map(roundSigDigits,eval(coVar),2):\nUm3 := map(roundSigDigits,eval( Um),2):\nDm3 := map(roundSigDigits,eval(Dm),2):\n#eval(Um3) * eval( Dm3) * transpose(Um3);\n#eval(coVar3) = map(roundSigDigits,evalm(Um3 & * Dm3 &* transpose(Um3)),3);" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 44 "Do projection by using first 3 eigenvectgors" }}{PARA 0 "" 0 "" {TEXT -1 315 " Here we consider what the distribution of images looks like when projecting into a 3-dimensional subspace associated with th e first three (largest three) eigenvectors. This will culminate in a 3 D point plot where the class 1 images are shown in red, the class two \+ images in greeen and the class 3 images in blue. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 120 "projMat := submatrix(Um,1..(imageSize*image Size),1..3):\nprojMat3 := map(roundSigDigits,projMat,3):\n#S = eval(pr ojMat3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 142 "pts := evalm(t ranspose(projMat) &* Xm):\nXm3 := map(roundSigDigits,Xm,3):\n#P = tran spose(Xm3) * eval(projMat3);\n#P = map(roundSigDigits,pts,3);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 560 "subspacePts := proc(pts)\n \+ local i, samples, dpts:\n dpts := []:\n samples := floor(cold im(pts)/3):\n for i from 1 to samples do\n dpts := [op(dpts),PO INTS([pts[1,i], pts[2,i], pts[3,i]],SYMBOL(BOX),COLOR(RGB,1.0,0.0,0.0) )]:\n od:\n for i from samples + 1 to 2*samples do\n dpts := \+ [op(dpts),POINTS([pts[1,i], pts[2,i], pts[3,i]],SYMBOL(BOX),COLOR(RGB, 0.0,1.0,0.0))]:\n od:\n for i from 2*samples+1 to 3*samples do\n \+ dpts := [op(dpts),POINTS([pts[1,i], pts[2,i], pts[3,i]],SYMBOL(BOX ),COLOR(RGB,0.0,0.0,1.0))]:\n od:\n eval(dpts):\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 114 "display(subspacePts(pts),axes=BOXE D,labels=[\"PC 1\", \"PC 2\", \"PC 3\"],scaling=CONSTRAINED,font=[HELV ETICA,BOLD,14]);" }}{PARA 13 "" 1 "" {GLPLOT3D 400 300 300 {PLOTDATA 3 "6cq-%'POINTSG6%7%$!+:JN1s#F)$!+ %=(4i&)F.F/F3-F$6%7%$!+TGyQ6F)$\"+'o_OJ#F)$!+zBBQ&*F.F/F3-F$6%7%$\"+$[ 5Pnn#F)$!+f[!f6*F.F/F3-F$6%7%$!+)zni(=F)$!+\"\\ &fb>F)$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 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 46 "Do projection by using eigenvectgors 3, 4 & 5." }}{PARA 0 "" 0 "" {TEXT -1 311 " Here we consider what the d istribution of images looks like when projecting into a 3-dimensional \+ subspace associated with the third, fourth and fifth eigenvectors. Thi s will culminate in a 3D point plot where the class 1 images are shown in red, the class two images in greeen and the class 3 images in blue . " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 120 "projMat := submatrix (Um,1..(imageSize*imageSize),3..5):\nprojMat3 := map(roundSigDigits,pr ojMat,3):\n#S = eval(projMat3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 142 "pts := evalm(transpose(projMat) &* Xm):\nXm3 := map(roundSigD igits,Xm,3):\n#P = transpose(Xm3) * eval(projMat3);\n#P = map(roundSig Digits,pts,3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 560 "subspace Pts := proc(pts)\n local i, samples, dpts:\n dpts := []:\n sa mples := floor(coldim(pts)/3):\n for i from 1 to samples do\n d pts := [op(dpts),POINTS([pts[1,i], pts[2,i], pts[3,i]],SYMBOL(BOX),COL OR(RGB,1.0,0.0,0.0))]:\n od:\n for i from samples + 1 to 2*samples do\n dpts := [op(dpts),POINTS([pts[1,i], pts[2,i], pts[3,i]],SYM BOL(BOX),COLOR(RGB,0.0,1.0,0.0))]:\n od:\n for i from 2*samples+1 \+ to 3*samples do\n dpts := [op(dpts),POINTS([pts[1,i], pts[2,i], p ts[3,i]],SYMBOL(BOX),COLOR(RGB,0.0,0.0,1.0))]:\n od:\n eval(dpts): \nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 114 "display(subspace Pts(pts),axes=BOXED,labels=[\"PC 3\", \"PC 4\", \"PC 5\"],scaling=CONS TRAINED,font=[HELVETICA,BOLD,14]);" }}{PARA 13 "" 1 "" {GLPLOT3D 400 300 300 {PLOTDATA 3 "6cq-%'POINTSG6%7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