contrib/mul/mcal/mcal_extract_mode.h
Go to the documentation of this file.
00001 #ifndef mcal_extract_mode_h_
00002 #define mcal_extract_mode_h_
00003 //:
00004 // \file
00005 // \brief Functions to learn modes from subsets of data
00006 // \author Tim Cootes
00007 
00008 #include <vnl/vnl_vector.h>
00009 #include <vnl/vnl_matrix.h>
00010 #include <vcl_vector.h>
00011 
00012 //: Computes one mode from used elements of each \p dv
00013 //  Compute a mode which only uses a subset of the elements,
00014 //  all other elements are set to zero.
00015 //  Effectives computes the first eigenvector of the
00016 //  covariance matrix formed from selecting the used elements
00017 //  of each \p dv[i], ie \p dv[i][used[j]].
00018 //  Resulting vector is returned as a full length vector
00019 //  (the same size as \p dv[i]).
00020 //  \param dv is assumed to be zero mean.
00021 //
00022 //  The contribution of this vector is removed from each \p dv,
00023 //  \p dv[i]-=mode*b, where \p b=dv[i].mode
00024 void mcal_extract_mode(vcl_vector<vnl_vector<double> >& dv,
00025                        const vcl_vector<unsigned>& elements_used,
00026                        vnl_vector<double>& mode,
00027                        double& var);
00028 
00029 //: Computes one mode by applying PCA to \p dv
00030 //  Effectives computes the first eigenvector of the
00031 //  covariance matrix.
00032 //  The contribution of this vector is removed from each \p dv,
00033 //  \p dv[i]-=mode*b, where \p b=dv[i].mode
00034 void mcal_extract_mode(vcl_vector<vnl_vector<double> >& dv,
00035                        vnl_vector<double>& mode,
00036                        double& var);
00037 
00038 //: Compute modes and associated variance of supplied data
00039 //  \param elements_used[i] indicates the set of elements to be used for
00040 //  mode i.  Modes beyond \p used.size() will use all elements.
00041 void mcal_extract_modes(vcl_vector<vnl_vector<double> >& dv,
00042                         const vcl_vector<vcl_vector<unsigned> >& elements_used,
00043                         unsigned max_modes, double var_prop,
00044                         vnl_matrix<double>& modes,
00045                         vnl_vector<double>& mode_var);
00046 
00047 #endif //mcal_extract_mode_h_