Classes | Public Member Functions | Private Member Functions | Private Attributes
EigenFace Class Reference

#include <eigenfaces.h>

List of all members.

Classes

struct  LabelDist

Public Member Functions

 EigenFace ()
 ~EigenFace ()
 Destructor.
bool add_training_image (Image *im, const char *label)
 Add a training image to the list of training images.
bool calculate_eigenfaces ()
 calculate_eigenfaces.
vnl_vector< double > * get_eigenvector (int i)
 get_eigenvector.
double get_eigenvalue (int i)
 get_eigenvalue.
char * get_label (unsigned int i)
bool check_eigenvectors ()
 check_eigenvectors.
void save_as_images (int width, int height)
 save_as_images.
vnl_vector< double > * encode (Image *im)
 encode.
vnl_vector< double > * encode (vnl_vector< double > *im)
vnl_vector< double > * decode (vnl_vector< double > *wts)
 decode.
int num_vectors () const
char * classify (Image *im, double threshold=DBL_MAX, int k=3, int dim=10)
 decode.
void check_training ()
void output_xgobi (char *basefile)
 output_xgobi.

Private Member Functions

vnl_vector< double > * convert_image_to_vector (Image *im)
 convert_image_to_vector.
void encode_training_images ()
 encode_training_images.
void cleanup ()

Private Attributes

unsigned int image_size
vcl_vector< vnl_vector< double > * > training_images
vcl_vector< vnl_vector< double > * > encoded_training_images
vcl_vector< char * > training_labels
vcl_vector< vnl_vector< double > * > eigenvectors
vcl_vector< double > eigenvalues
vnl_vector< double > * average_training_image

Detailed Description

Definition at line 22 of file eigenfaces.h.


Constructor & Destructor Documentation

EigenFace::EigenFace ( ) [inline]

Definition at line 45 of file eigenfaces.h.

EigenFace::~EigenFace ( )

Destructor.

Scans through training_images and eigenvectors and deletes the elements thereof.

under development

Author:
Brendan McCane

Definition at line 24 of file eigenfaces.cxx.


Member Function Documentation

bool EigenFace::add_training_image ( Image im,
const char *  label 
)

Add a training image to the list of training images.

Converts the input training image into a vector first, then adds this vector to the list.

Parameters:
im: the image to add
label: the class label for the image
Returns:
bool: success or otherwise of the insertion procedure

under development

Author:
Brendan McCane

Definition at line 62 of file eigenfaces.cxx.

bool EigenFace::calculate_eigenfaces ( )

calculate_eigenfaces.

Actually perform the eigenfaces calculation. Returns true on success, false on failure. This will populate the eigenvectors and eigenvalues vectors.

under development

Author:
Brendan McCane

Definition at line 163 of file eigenfaces.cxx.

bool EigenFace::check_eigenvectors ( )

check_eigenvectors.

Check to see if the calculated vectors are in fact eigenvectors.

Returns:
bool: true if eigenvectors, false otherwise

under development

Author:
Brendan McCane

Definition at line 267 of file eigenfaces.cxx.

void EigenFace::check_training ( )

Definition at line 219 of file eigenfaces.cxx.

char * EigenFace::classify ( Image im,
double  threshold = DBL_MAX,
int  k = 3,
int  dim = 10 
)

decode.

Try to classify the given image using k-nearest neighbours

Parameters:
imthe image to classify
kthe number of nearest neighbours to use
dimthe number of dimensions of the eigenvectors to use
thresholddistances above this threshold are treated as not recognised
Returns:
the label of the recognised image or NULL if unsuccessful

under development

Author:
Brendan McCane

Definition at line 419 of file eigenfaces.cxx.

void EigenFace::cleanup ( ) [private]

Definition at line 130 of file eigenfaces.cxx.

vnl_vector< double > * EigenFace::convert_image_to_vector ( Image im) [private]

convert_image_to_vector.

Convert the input image to a 1d vector by stacking the rows of the image on top of each other (vertically).

Parameters:
im,:the image to convert
Returns:
vnl_vector<double> *: the resultant vector

under development

Author:
Brendan McCane

Definition at line 245 of file eigenfaces.cxx.

vnl_vector< double > * EigenFace::decode ( vnl_vector< double > *  wts)

decode.

Given an input set of weights, rebuild an image.

Parameters:
wts: the input set of weights
Returns:
vnl_vector<double>*: the reconstructed image in a vector

under development

Author:
Brendan McCane

Definition at line 395 of file eigenfaces.cxx.

vnl_vector< double > * EigenFace::encode ( Image im)

encode.

Given an input image, encode it as a vector of weights.

Parameters:
im,:the input image
Returns:
vnl_vector<double>*: the vector of weights

under development

Author:
Brendan McCane

Definition at line 354 of file eigenfaces.cxx.

vnl_vector< double > * EigenFace::encode ( vnl_vector< double > *  im)

Definition at line 369 of file eigenfaces.cxx.

void EigenFace::encode_training_images ( ) [private]

encode_training_images.

Encode all training images for later classification.

under development

Author:
Brendan McCane

Definition at line 334 of file eigenfaces.cxx.

double EigenFace::get_eigenvalue ( int  i)

get_eigenvalue.

Returns the requested eigenvalue if it exists, 0 if it doesn't.

Parameters:
i,:the index of the requested eigenvector
Returns:
double: the requested eigenvalue

under development

Author:
Brendan McCane

Definition at line 118 of file eigenfaces.cxx.

vnl_vector< double > * EigenFace::get_eigenvector ( int  i)

get_eigenvector.

Returns the requested eigenvector if it exists, NULL if it doesn't.

Parameters:
i,:the index of the requested eigenvector
Returns:
vnl_vector<double>: the requested eigenvector

under development

Author:
Brendan McCane

Definition at line 95 of file eigenfaces.cxx.

char* EigenFace::get_label ( unsigned int  i) [inline]

Definition at line 51 of file eigenfaces.h.

int EigenFace::num_vectors ( ) const [inline]

Definition at line 59 of file eigenfaces.h.

void EigenFace::output_xgobi ( char *  basefile)

output_xgobi.

Output the data into xgobi format files

Parameters:
basefilethe basename of the files

under development

Author:
Brendan McCane

Definition at line 492 of file eigenfaces.cxx.

void EigenFace::save_as_images ( int  width,
int  height 
)

save_as_images.

Save each of the eigenvectors as an image.

under development

Author:
Brendan McCane

Definition at line 299 of file eigenfaces.cxx.


Member Data Documentation

Definition at line 31 of file eigenfaces.h.

vcl_vector<double> EigenFace::eigenvalues [private]

Definition at line 30 of file eigenfaces.h.

vcl_vector<vnl_vector<double> *> EigenFace::eigenvectors [private]

Definition at line 29 of file eigenfaces.h.

vcl_vector<vnl_vector<double> *> EigenFace::encoded_training_images [private]

Definition at line 27 of file eigenfaces.h.

unsigned int EigenFace::image_size [private]

Definition at line 25 of file eigenfaces.h.

vcl_vector<vnl_vector<double> *> EigenFace::training_images [private]

Definition at line 26 of file eigenfaces.h.

vcl_vector<char *> EigenFace::training_labels [private]

Definition at line 28 of file eigenfaces.h.


The documentation for this class was generated from the following files: