**********************************************
* ROBUST ESTIMATION OF SUBSPACE COEFFICIENTS *
**********************************************

------------------------------------------------------------------
|  Cognitive Vision Systems - CogVis, IST-2000-29375              |
|  Deliverable D.1.6: Algorithms for robust subspace recognition  |
|  Danijel Skocaj, Ales Leonardis, Sanja Fidler                   |
|  University of Ljubljana, UOL, 21 May 2003                      |
------------------------------------------------------------------

This package contains matlab functions, which perform robust estimation of subspace coefficients in 
PCA, CCA and LDA methods. It contains the following files (matlab functions):
- PCA  Principal Component Analysis. Creates the principal subspace.
- IS2FS  Maps images from image space to feature space.
- FS2IS  Maps vectors of subspace coefficients from feature space to image space.
- IS2FSROB  Maps vectors of subspace coefficients from feature space to image space in a robust manner.
- CCA  Canonical Correlation Analysis. Computes canonical correlation vectors.
- CCAAPCA  CCA-after-PCA. Calculates CCA of augmented PCA coefficient vectors.
- LDA  Linear Discriminant Analysis. Computes LDA eigenvectors.
- LDAAPCA  LDA-after-PCA. Calculates LDA of augmented PCA coefficient vectors.
- DISPIMGS  Displays images.
- DEMOPCA  Demo of robust estimation of principal components.
- DEMOCCA  Demo of robust estimation of canonical correlation coefficients.

The comments in functions should provide sufficient information on their functionalities. 
The inputs and outputs of the functions are the following:

%PCA  Principal Component Analysis.
%   [Xm,U,L] = pca(X) creates an eigenspace from data matrix X.
%   It returns mean image Xm, eigenvectors in columns of U and eigenvalues L.
%   Each column of X is a vector representing an image.
%   [Xm,U,L] = pca(X,K) returns only the first K eigenvectors and eigenvalues.

%IS2FS  Map from image space to feature space.
%   A = is2fs(X,Xm,U) maps image(s) in X from the image space to the feature space.
%   Xm is the mean image, U are the basis vectors of the feature space.
%   Each column of X is a vector representing an image and each column in A is 
%   a corresponding coefficient vector in the feature space.

%FS2IS  Map from feature space to image space.
%   X = fs2is(A,Xm,U) reconstructs image(s) X from the coefficient vector(s) A.
%   Xm is the mean image, U are the basis vectors of the feature space.
%   Each column of A is a vector in the feature space and each column in X is a
%   corresponding vector representing a reconstructed image.

%IS2FSROB  Robust maping from image space to feature space.
%   A = is2fsRob(X,Xm,U,k,r,s,nh) maps the image(s) in the vector(s) X from 
%   the image space to the feature space in a robust manner. Xm is the mean image, 
%   U are the basis vectors of the feature space. k,r, and s are the parameters
%   of the robust method. nh is the number of hypotheses to perform.
%   A is the calculated vector(s) in the feature space. 

%CCA  Canonical Correlation Analysis.
%  [Wx,Wy,Xm,Ym]=cca(X,Y) calculates canonical correlation vectors Wx and Wy from
%  two sets of observations X and Y. It returns also the mean values 
%  of X and Y (Xm and Ym). The number of observations in X and in Y has to be equal.
%  All vectors are given in columns of corresponding matrices.
%  As a result min(p,q,N) pairs of canonical correlation vectors are returned, 
%  where p and q are the sizes of vectors in X and Y and N is the number of observations.
%  Where p>N or q>N the dual formulation of CCA is used to speed up calculation.
%  This is a basic procedure for CCA, without regularization.

%CCAAPCA  Calculate CCA of augmented PCA coefficient vectors.
%  [U,Vx,Wy,Xm,Ym] = ccaApca(X,Y,K) calculates K+c dimensional augmented
%  principal subspace of input images given in columns of X, where c is dim(Y).
%  This subspace is determined by K+c basis vectors U and by the origin (mean vector) Xm.
%  It also performs CCA on vectors of principal components and it returns c
%  canonical correlation vectors Vx of dimension K+c (the origin of this subspace is in 0),
%  and c canonical vectors Wy of dimension c with the origin of the subspace in Ym.

%LDA  Linear Discriminant Analysis.
%  [W,Ms]=lda(A,c,n) calculates LDA eigenvectors W from the training images arranged
%  in columns of X in c groups of n images, thus c is the number of classes and
%  n is the number of images in each class. It returns also the matrix Ms, which
%  contains c (c-1)-dimensional means of all c classes in LDA subspace.

%LDAAPCA  Calculate LDA of augmented PCA coefficient vectors.
%  [U,Xm,W,Ms] = ldaApca(X,c,n,K) calculates K+c-1 dimensional augmented
%  principal subspace of input images given in columns of X, where c is the number 
%  of classes and n the number of training images in each class.
%  This subspace is determined by K+c-1 basis vectors U and by the origin (mean vector) Xm.
%  It also performs LDA on vectors of principal components and it returns c-1
%  LDA eigenvectors W of dimension K+c-1 and c (c-1)-dimensional means of all c classes
%  in LDA subspace.

DEMOPCA and DEMOCCA programs demonstrate the usage of the algorithms for estimation of 
principal components and canonical correlation coefficients. data and data1 contain necessary images.

The functions are based on the following papers:

A. Leonardis and H. Bischof. Robust recognition using eigenimages.
Computer Vision and Image Understanding, 78:99--118, 2000.

D. Skocaj, A. Leonardis, and S. Fidler. Robust estimation of CCA coefficients by subsampling.
Technical report TR-LRV-05/03, University of Ljubljana, Faculty of Computer and Information Science, May 2003.

S. Fidler and A. Leonardis. Robust LDA classification by subsampling.
In CVPR Workshop on Statistical Analysis in Computer Vision, in  press, 2003.