



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In these Lecture notes, the following main points were discussed by the Lecturer : Application To Computer Vision, Representation, Pca To Find Patterns, Image Compression, Implementation Code, Dimensional, Vector, Digital Image Processing, Image Compression, Image Reconstruction
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




This chapter will outline the way that PCA is used in computer vision, firs showing how images are usually represented, and then showing what PCA can allow us to do with those images. The information in this section regarding facial recognition comes from âFace Recognition: Eigenface, Elastic Matching, and Neural Netsâ, Jun Zhang et al. Proceedings of the IEEE, Vol. 85, No. 9, September 1997. The representation infor- mation, is taken from âDigital Image Processingâ Rafael C. Gonzalez and Paul Wintz, Addison-Wesley Publishing Company, 1987. It is also an excellent reference for further information on the K-L transform in general. The image compression information is taken from http://www.vision.auc.dk/ sig/Teaching/Flerdim/Current/hotelling/hotelling.html , which also provides examples of image reconstruction using a varying amount of eigen- vectors.
When using these sort of matrix techniques in computer vision, we must consider repre-
-dimensional vector
where the rows of pixels in the image are placed one after the other to form a one-
the intensity values of the image, possibly a single greyscale value.
image we can create an image vector as described in the representation section. We can then put all the images together in one big image-matrix like this:
which gives us a starting point for our PCA analysis. Once we have performed PCA, we have our original data in terms of the eigenvectors we found from the covariance matrix. Why is this useful? Say we want to do facial recognition, and so our original images were of peoples faces. Then, the problem is, given a new image, whose face from the original set is it? (Note that the new image is not one of the 20 we started with.) The way this is done is computer vision is to measure the difference between the new image and the original images, but not along the original axes, along the new axes derived from the PCA analysis. It turns out that these axes works much better for recognising faces, because the PCA analysis has given us the original images in terms of the differences and simi- larities between them. The PCA analysis has identifie the statistical patterns in the data.
eigenvectors. In practice, we are able to leave out some of the less significan eigenvectors, and the recognition still performs well.
Using PCA for image compression also know as the Hotelling, or Karhunen and Leove
vectors, each with 20 dimensions. Each vector consists of all the intensity values from the same pixel from each picture. This is different from the previous example because before we had a vector for image , and each item in that vector was a different pixel, whereas now we have a vector for each pixel , and each item in the vector is from a different image. Now we perform the PCA on this set of data. We will get 20 eigenvectors because each vector is 20-dimensional. To compress the data, we can then choose to transform the data only using, say 15 of the eigenvectors. This gives us a fina data set with only 15 dimensions, which has saved us
of the space. However, when the original data is reproduced, the images have lost some of the information. This compression technique is said to be lossy because the decompressed image is not exactly the same as the original, generally worse.
cv(var,ct) = v; cv(ct,var) = v; // do the lower part of c also. end, end, c=cv;
// This a simple wrapper function to get just the eigenvectors // since the system call returns 3 matrices function [x]=justeigs (x) // This just returns the eigenvectors of the matrix
[a, eig, b] = bdiag(x);
x= eig;
// this function makes the transformation to the eigenspace for PCA // parameters: // adjusteddata = mean-adjusted data set // eigenvectors = SORTED eigenvectors (by eigenvalue) // dimensions = how many eigenvectors you wish to keep // // The first two parameters can come from the result of calling // PCAprepare on your data. // The last is up to you.
function [finaldata] = PCAtransform(adjusteddata,eigenvectors,dimensions) finaleigs = eigenvectors(:,1:dimensions); prefinaldata = finaleigsâ*adjusteddataâ; finaldata = prefinaldataâ;
// This function does the preparation for PCA analysis // It adjusts the data to subtract the mean, finds the covariance matrix, // and finds normal eigenvectors of that covariance matrix. // It returns 4 matrices // meanadjust = the mean-adjust data set // covmat = the covariance matrix of the data // eigvalues = the eigenvalues of the covariance matrix, IN SORTED ORDER // normaleigs = the normalised eigenvectors of the covariance matrix, // IN SORTED ORDER WITH RESPECT TO // THEIR EIGENVALUES, for selection for the feature vector.
// NOTE: This function cannot handle data sets that have any eigenvalues // equal to zero. Itâs got something to do with the way that scilab treats // the empty matrix and zeros. // function [meanadjusted,covmat,sorteigvalues,sortnormaleigs] = PCAprepare (data) // Calculates the mean adjusted matrix, only for 2 dimensional data means = mean(data,"r"); meanadjusted = meanadjust(data); covmat = cov(meanadjusted); eigvalues = spec(covmat); normaleigs = justeigs(covmat); sorteigvalues = sorteigvectors(eigvaluesâ,eigvaluesâ); sortnormaleigs = sorteigvectors(eigvaluesâ,normaleigs);
// This removes a specified column from a matrix // A = the matrix // n = the column number you wish to remove function [columnremoved] = removecolumn(A,n) inputsize = size(A); numcols = inputsize(2); temp = A(:,1:(n-1)); for var = 1:(numcols - n) temp(:,(n+var)-1) = A(:,(n+var)); end, columnremoved = temp;
// This finds the column number that has the // highest value in itâs first row. function [column] = highestvalcolumn(A) inputsize = size(A); numcols = inputsize(2); maxval = A(1,1); maxcol = 1; for var = 2:numcols if A(1,var) > maxval maxval = A(1,var); maxcol = var; end, end, column = maxcol