LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiPointDistributionModel.h

00001 /*
00002  * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 /*----------------------------------------------------------------
00024  * project ....: LTI Digital Image/Signal Processing Library
00025  * file .......: ltiPointDistributionModel.h
00026  * authors ....: Benjamin Winkler
00027  * organization: LTI, RWTH Aachen
00028  * creation ...: 12.6.2001
00029  * revisions ..: $Id: ltiPointDistributionModel.h,v 1.8 2006/02/08 11:37:34 ltilib Exp $
00030  */
00031 
00032 #ifndef _LTI_POINT_DISTRIBUTION_MODEL_H_
00033 #define _LTI_POINT_DISTRIBUTION_MODEL_H_
00034 
00035 
00036 #include "ltiIoObject.h"
00037 #include "ltiPointList.h"
00038 #include "ltiVector.h"
00039 #include "ltiMatrix.h"
00040 
00041 namespace lti {
00042   /**
00043    * This class is the data structure for a Point Distribution Model (PDM).
00044    *
00045    * A PDM allows to represent a shape and its possible deformations, by a
00046    * mean shape and the eigenvectors and eigenvalues of the shape set. It is
00047    * estimated by the pdmGenerator and can be used to regularize the
00048    * deformations of an activeShapeModel (ASM).
00049    *
00050    * For a description of PDMs see: Sonka, "Image Processing, Analysis, and
00051    * Machine Vision", p380ff.
00052    *
00053    * Additional Remark:
00054    *
00055    * In ASMs a shape x is described as the sum of mean shape and the weighted
00056    * eigenvectors.
00057    * Note that in common a subset of all eigenvectors is chosen (i.e. the
00058    * eigenvectors with the first n largest eigenvalues) for data compression
00059    * reasons.
00060    *
00061    * <code>
00062    * x = xMean + eigenVectors*w
00063    * </code>
00064    *
00065    */
00066   class pointDistributionModel : public ioObject {
00067   public:
00068 
00069     /**
00070      * default constructor
00071      */
00072     pointDistributionModel();
00073 
00074     /**
00075      * copy constructor
00076      * @param other the object to be copied
00077      */
00078     pointDistributionModel(const pointDistributionModel& other);
00079 
00080     /**
00081      * destructor
00082      */
00083     virtual ~pointDistributionModel();
00084 
00085     /**
00086      * copy data of "other" pointDistributionModel.
00087      * Please note that the status string will _NOT_ be copied!
00088      */
00089     pointDistributionModel& copy(const pointDistributionModel& other);
00090 
00091     /**
00092      * assigment operator (alias for copy(other)).
00093      * @param other the pointDistributionModel to be copied
00094      * @return a reference to the actual pointDistributionModel
00095      */
00096     pointDistributionModel& operator=(const pointDistributionModel& other);
00097 
00098     /**
00099      * returns the name of this type ("pointDistributionModel")
00100      */
00101     const char* getTypeName() const;
00102 
00103 
00104     /**
00105      * write the pointDistributionModel in the given ioHandler
00106      * @param handler the ioHandler to be used
00107      * @param complete if true (the default) the enclosing begin/end will
00108      *        be also written, otherwise only the data block will be written.
00109      * @return true if write was successful
00110      */
00111     virtual bool write(ioHandler& handler, const bool complete=true) const;
00112 
00113     /**
00114      * read the pointDistributionModel from the given ioHandler
00115      * @param handler the ioHandler to be used
00116      * @param complete if true (the default) the enclosing begin/end will
00117      *        be also written, otherwise only the data block will be written.
00118      * @return true if write was successful
00119      */
00120     virtual bool read(ioHandler& handler,const bool complete=true);
00121 
00122 #   ifdef _LTI_MSC_6
00123     /**
00124      * this function is required by MSVC only, as a workaround for a
00125      * very awful bug, which exists since MSVC V.4.0, and still by
00126      * V.6.0 with all bugfixes (so called "service packs") remains
00127      * there...  This method is public due to another bug!, so please
00128      * NEVER EVER call this method directly
00129      */
00130     bool readMS(ioHandler& handler,const bool complete=true);
00131 
00132     /**
00133      * this function is required by MSVC only, as a workaround for a
00134      * very awful bug, which exists since MSVC V.4.0, and still by
00135      * V.6.0 with all bugfixes (so called "service packs") remains
00136      * there...  This method is public due to another bug!, so please
00137      * NEVER EVER call this method directly
00138      */
00139     bool writeMS(ioHandler& handler,const bool complete=true) const;
00140 #   endif
00141 
00142 
00143     //
00144     // data
00145     //
00146 
00147     /**
00148      * Typedef for a single PDM shape. A shape is an ordered list of
00149      * landmark points of a 2D object. Generally this will be created
00150      * by sampling a fixed number of N points along the boundary.
00151      */
00152     typedef tpointList<float> shape;
00153 
00154 
00155     /**
00156      * The mean (average) shape of the model.
00157      */
00158     shape meanShape;
00159 
00160     /**
00161      * The matrix of all eigenvectors computed over a set of shapes.
00162      * Eigenvectors are sorted in descending order of magnitude of
00163      * their corresponding eigenvalues.
00164      */
00165     matrix<double> eigenVectorMatrix;
00166 
00167     /**
00168      * The eigenvalues, that belong to the eigenvectors, stored in a vector.
00169      * The eigenvalue is the variance of the set of shapes along the direction
00170      * of the eigenvector, that it belongs to.
00171      */
00172     vector<double> varianceVector;
00173 
00174   };
00175 
00176 
00177   /**
00178    * write a pointDistributionModel
00179    */
00180   bool write(ioHandler& handler, const pointDistributionModel& p,
00181              const bool complete=true);
00182 
00183   /**
00184    * read a pointDistributionModel
00185    */
00186   bool read(ioHandler& handler, pointDistributionModel& p,
00187             const bool complete=true);
00188 
00189 }
00190 
00191 #endif

Generated on Sat Apr 10 15:25:58 2010 for LTI-Lib by Doxygen 1.6.1