BIJ API

bijnum
Class BIJpca

java.lang.Object
  |
  +--bijnum.BIJpca
Direct Known Subclasses:
BIJgifa

public class BIJpca
extends java.lang.Object

Principal component analysis (PCA) on 2-D sequences (ie. image sequences). Image sequences are organized as matrix with each image as a column vector. This is how you do it (Snapshot method by Sirovich et al.):

 ' is transpose
 cov = a * a'
 eiv = eigen(cov)
 sort eiv system by eigenvalues, largest first.
 diag = diagonal matrix of eigevnvalues
 psi = a' * eigenvectors * diag
 eigenimages = psi'
 
(c) 2003 Michael Abramoff. All rights reserved.


Field Summary
 float[][] a
          The matrix of images.
protected  float[][] an
           
 float[][] eigenimages
          The matrix of eigenimages, i.e.
 float[] eigenvalues
          The eigenvalues of the transpose of the covariance matrix.
 float[][] eigenvectors
          The eigenvectors of the transpose of the covariance matrix.
 double totalVariance
          Total accumulative variance.
 
Constructor Summary
BIJpca()
          Set up PCA.
BIJpca(float[][] eigenimages, float[][] eigenvectors)
          Set up PCA for already computed coordinates and eigenimages.
 
Method Summary
 float[][] compute(float[][] a)
          Compute the PCA.
protected  float[][] computeEigenimages()
          Compute the spatial eigenimages, i.e.
 float[][] computeLinearCombination()
          Compute the linear combination of all eigenimages.
 float[][] computeLinearCombination(float[] factor)
          Compute a (compacted) linear combination of the imagevectors, using only with factor set to 1.
 float[] computeProjection(float[] v)
          Compute the projection of a vector v onto the set of eigenimages.
 float[][] getCoordinates()
          Get the eigenvector coordinate matrix an as a matrix.
 float[] getCoordinatesImage()
          Get the eigenvector coordinate matrix an as an image (a float []) of width x height = eigenvectors.length.
 float[] getEigenImage(int j)
          Compute the normalized image for eigenimage j so that it can be displayed with the same gray-scale as all others.
 double getTotalVariance()
           
 float[] varianceSpectrum()
          Compute the accumulated variance spectrum.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eigenimages

public float[][] eigenimages
The matrix of eigenimages, i.e. the eigenvectors of the covariance matrix. Each eigenimage is one of the columnvectors. In some literature, these are known as the psi(n), or column vectors of spatial principal components.

eigenvalues

public float[] eigenvalues
The eigenvalues of the transpose of the covariance matrix.

eigenvectors

public float[][] eigenvectors
The eigenvectors of the transpose of the covariance matrix.

an

protected float[][] an

a

public float[][] a
The matrix of images.

totalVariance

public double totalVariance
Total accumulative variance.
Constructor Detail

BIJpca

public BIJpca()
Set up PCA.

BIJpca

public BIJpca(float[][] eigenimages,
              float[][] eigenvectors)
Set up PCA for already computed coordinates and eigenimages.
Method Detail

compute

public float[][] compute(float[][] a)
                  throws java.lang.Exception
Compute the PCA. a is modified. a is a '3-D' array of images, organized as the columns of a 2-D matrix.
Parameters:
a - a matrix of float[][]. column size should be > row size.
Returns:
psi, the eigenimages in corrected format (sorted by eigenvalue).

computeEigenimages

protected float[][] computeEigenimages()
Compute the spatial eigenimages, i.e. the eigenvectors that belong to a, from the eigenvectors/eigenvalues from the eigensystem of a'. Uses at, eigenvectors and eigenvalues as computed in compute(). In some literature, the eigenimages (eigenvectors) are know as the psi(n)(x).
Returns:
the eigenimages (eigenvectors) as a float[][].

computeProjection

public float[] computeProjection(float[] v)
                          throws java.lang.Exception
Compute the projection of a vector v onto the set of eigenimages.
Parameters:
v - a float[] vector (an image).

computeLinearCombination

public float[][] computeLinearCombination()
Compute the linear combination of all eigenimages. Should be the same as original sequence. f = SUM(an-i psi-i)

getEigenImage

public float[] getEigenImage(int j)
Compute the normalized image for eigenimage j so that it can be displayed with the same gray-scale as all others.

getCoordinates

public float[][] getCoordinates()
Get the eigenvector coordinate matrix an as a matrix. The coordinates are not the same as the eigenvectors of a' because internally a different format is used to save time for computations.
Returns:
the coordinates matrix as a float[][]

getCoordinatesImage

public float[] getCoordinatesImage()
Get the eigenvector coordinate matrix an as an image (a float []) of width x height = eigenvectors.length. The coordinates are not the same as the eigenvectors of a' because internally a different format is used to save time for computations.
Returns:
the coordinates matrix as a float[][]

computeLinearCombination

public float[][] computeLinearCombination(float[] factor)
Compute a (compacted) linear combination of the imagevectors, using only with factor set to 1. f = SUM(factor-i an-i psi-i)
Parameters:
an - the eigenvector coordinates (an) for the desired linear combination.
Returns:
the linear combination as a vector.

varianceSpectrum

public float[] varianceSpectrum()
Compute the accumulated variance spectrum. The values are the additional variance that each component explains.
Returns:
the variance spectrum as a float[].

getTotalVariance

public double getTotalVariance()

BIJ API

Submit a bug or feature

Copyright (c) 1997-2003 Michael Abramoff
Licensing available. All Rights Reserved.