struct CAAMOptState
-
Stores interates from the optimization process.
- Author:
- Mikkel B. Stegmann
- Version:
- 4-10-2000
CAAMOptState( double e, const CAAMShape &s, const CDVector &_c, int d )
- Constructor
CAAMOptState& operator=(const CAAMOptState &os)
- Assignment operator
CAAMDeformPCA m_ShapePCA
- The shape PCA
CAAMDeformPCA m_TexturePCA
- The texture PCA
CAAMDeformPCA m_CombinedPCA
- The combined PCA
CDMatrix m_mShape2PixelWeights
- The shape-to-pixel weights
double m_dAMFVersion
- The AMF format version
CDMatrix m_mQsEV
- The shape part of the combined eigenvectors
CDMatrix m_mQgEV
- The texture part of the combined eigenvectors
CDVector m_vMeanTexture
- The mean texture
CAAMShape m_sMeanAShape
- Cached mean shape
CDMatrix m_mShapeInstance
- Cache matrix
CDMatrix m_mTextureInstance
- Cache matrix
CDVector m_vTextureVar
- The variance of each normalized pixel in the texture model
int m_iTextureSamples
- The number of texture samples in the model
CDMatrix m_R_c
- The parameter prediction matricies
CAAMTransferFunction* m_pTextureTF
- The texture transfer function
const CDMatrix& Rc() const
- Texture parameter update prediction matrix
const CDMatrix& Rt() const
- Pose parameter update prediction matrix
const CDMatrix& Qg() const
- The texture part of the combined PCA eigenvectors
const CDMatrix& Qs() const
- The shape part of the combined PCA eigenvectors
const CAAMReferenceFrame& ReferenceFrame() const
- Returns the reference frame of the model
inline int NBands() const
- Returns the number of bands in the model
int NTextureSamples() const
- Returns the number of samples in the texture model
inline bool IsConvexHullUsed() const
- Returns true if the texture model is based on the convex hull
inline double AddExtents() const
- Returns the amount shape extents added (warning: shape extents will be remove in later versions)
inline const CAAMShape& MeanShape() const
- Returns the mean shape
inline const CDVector& MeanTexture() const
- Returns the mean texture
inline int ReductionFactor() const
- Returns the reduction factor of the training set that this model was built on
inline const CAAMDeformPCA& ShapePCA() const
- Returns the shape PCA
inline const CAAMDeformPCA& TexturePCA() const
- Returns the texture PCA
inline const CAAMDeformPCA& CombinedPCA() const
- Returns the combined PCA
inline double MeanShapeSize() const
- Returns the mean shape size, ie. the size of the reference shape.
CAAMModel()
-
Constructor. Set up the default settings.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 5-16-2000
~CAAMModel()
-
Destructor.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 5-16-2000
bool ApproxExample( const CString &filename, CDMultiBand<TAAMPixel> &outImg ) const
-
Synthesizes an unseen example by projecting the shape and
(normalized) texture into c-parameter space, generating a
model instance and assigning it the appropriate pose
(incl. denormalization).
- Parameters:
- filename - The base filename of an annotation. Ex. "scan.asf"
outImg - The output image where the model approximation has
been overlaid.
- Returns:
- true on success, false if the image and/or annotation could not be read.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-6-2000
void SetPoseParameterUpdateConstraints( const CDVector &pc )
-
Sets constraints on the pose parameter updates.
NOTICE: Currently, these are *not* saved along
with the model and thus must be set each
time a model is loaded.
- Parameters:
- pc - Parameter constraints (in absolute numbers).
- Returns:
- Nothing
- Author:
- Mikkel B. Stegmann
- Version:
- 10-30-2002
- See Also:
- ConstrainSearchParameters
void SetShapeParameterUpdateConstraints( const CDVector &mean, const CDVector &sd )
-
Sets user-specified shape parameter update constraints.
NOTICE: These are currently not saved with the model.
- Parameters:
- mean - Some shape parameter configuration.
sd - The standard diviations of the 'mean'.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 11-4-2002
void ConstrainSearchParameters( CDVector &c, CDVector &pose ) const
-
Constrain the pose and model parameters to be within some
reasonable limits.
- Parameters:
- c - The model parameters.
pose - The pose parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 7-20-2000
bool EstimatePose( const CDMultiBand<TAAMPixel> image, const CAAMShape &shape, CDVector &pose ) const
-
Estimate the pose of a shape using the pose regression
matrix.
- Parameters:
- image - The image to search in.
shape - The shape to determine the pose from.
pose - The output pose vector.
- Returns:
- True is ok, false if the shape is outside the image.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-27-2000
- See Also:
void ModelImage( const CDVector &c, CDMultiBand<TAAMPixel> &outImg, const CAAMShape* matchPose, const bool fitTexture ) const
-
Generates a model image based on the parameters in 'c'
with various options.
- Parameters:
- c - A set of model parameters.
outImg - The output imge.
matchPose - A pointer to a shape. If not NULL the model
generated by the set of c-parameters will be
aligned wrt. pose to this shape.
fitTexture - If matchPose is not NULL, the de-mapped and
de-normalized texture will be fitted in a
least squares sense to the texture in outImg
given by the shape. Default true.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-29-2000
void ModelImageEx( const CAAMShape &shape, const CDVector &texture, CDMultiBand<TAAMPixel> &outImg, const bool renderImage, const bool fitTexture ) const
-
Generates a synthetic image from the AAM using the model
parameters in 'c'.
- Parameters:
- shape - The shape the texture vector should be mapped to.
textureSamples - The texture vector to be warped into an image.
Will be de-mapped and de-normalized.
outImg - The output image (sized correctly inside this
method, if renderInImage is false).
renderImage - If true:
1) outImg is expected to be allocated.
2) the model is rendered with it's
pose unchanged, thus the shape is
expected to lie within the outImg
This option is used for drawing the final
optimization into the image or to draw a
model approximation into the image 'outImg'.
Default false.
fitTexture - If renderImage is true, the de-mapped and
de-normalized texture will be fitted in a
least squares sense to the texture in outImg
given by the shape. Default true.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-24-2000
- See Also:
void ShapeFreeImage( const CDVector &textureSamples, CDMultiBand<TAAMPixel> &outImg, const bool deMap ) const
-
Generates a shape free image (that is; a mean shape image)
using a vector of texture samples.
- Parameters:
- textureSamples - The texture vector to be warped into an image.
De-normalizes (and demaps) inside this method.
outImg - A reference to an output image. Resize of the
image is done inside this method.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-21-2000
- See Also:
- ModelImage
void ShapeFreeImage( const CDVector &textureSamples, CDMatrix &m, const bool deMap, const bool normalize ) const
-
Generates a shape free image (that is; a mean shape image)
using a vector of texture samples.
- Parameters:
- textureSamples - The texture vector to be warped into an image.
De-normalizes (and demaps) inside this method.
m - A reference to an output image on matrix form.
Resize of the matrix is done inside this method.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-21-2000
- See Also:
- ModelImage
double ModelEstimateTexDiff( const CDMultiBand<TAAMPixel> &image, const CDVector &c, CAAMShape &estimate, CDVector &diff, const int similaritym, const bool useInterpolation ) const
-
Calculates the pixel difference from a model instance and an image.
- Parameters:
- image - The image (input)
c - Model parameters (in/output).
estimate - The shape estimate (in/output).
diff - The pixel difference vector (output) Resized inside.
similaritym - Set the used similarity measure:
0 Non-normalised L_2 norm (default)
1 The "Mahalanobis" distance (texture samples are
regarded independent to increase performance).
2 The Lorentzian error norm.
3 Absolute auto correlation of the residuals.
- Returns:
- The similarity measure.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-27-2000
void NormalizeTexture(CDVector &texture) const
-
Normalizes a texture vector.
- Parameters:
- texture - Texture to be normalized.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-6-2000
CAAMModel::CAAMOptRes OptimizeModel( const CDMultiBand<TAAMPixel> &image, CAAMShape &s, CDVector &c, const int maxIterations, std::vector<CAAMOptState>* pOptStates, bool disableDamping ) const
-
Performs AAM optimization of a shape containing initial pose and
a set of model parameters (c).
- Parameters:
- image - The image to search in.
s - The initial shape (also containing the inital pose, thus;
not a normalized shape). Actually only the pose of 's' is
used (to align the reference shape as the initial shape).
NOTE: The optimal shape is returned in 's' after execution.
c - The initial model parameters. If this vector is empty, it is
resized correctly and set equal to zero, thus the mean model.
NOTE: The optimal model parameters are returned in 'c' after
execution.
maxIterations - The maximum iterations allowed.
pOptStates - Optional parameter all convergence info can be returned in.
See CAAMOptState.
disableDamping - Disables the damping steps (default false).
- Returns:
- The results of the optimization in the form of a 'CAAMOptRes'
instance.
- Author:
- Mikkel B. Stegmann
- Version:
- 5-7-2002
CAAMModel::CAAMOptRes OptimizeModelByFineTuning( const CDMultiBand<TAAMPixel> &image, CAAMShape &s, CDVector &c, const int maxIterations, const int similaritym, const int optimizer ) const
-
Perform general-purpose optimization of the AAM using
simulated annealing, conjugate gradient, steepest
descent, BGFS or pattern search.
- Parameters:
- image - The image beeing searched in.
s - The inital shape pose.
c - The initial model parameters.
maxIterations - The maximum allowed number of iterations.
similaritym - The used similarity measure for the optimization:
0 Non-normalized L_2 norm (default).
1 The "Mahalanobis" distance (texture samples are
regarded independent to increase performance).
2 The Lorentzian error norm.
optimizer - Sets the optimer to use:
1 Steepest Descent (default)
2 Conjugate Gradient
3 Quasi-Newton, BFGS
4 Pattern search
5 Simulated annealing
- Returns:
- The final fit.
- Author:
- Mikkel B. Stegmann
- Version:
- 7-7-2000
bool ReadModel( const CString &filename )
-
Reads the complete AAMModel from disk.
- Parameters:
- filename - Input filename without any extension.
E.g. if the files on disk are
'model.txt' & 'model.amf'
-> filename = 'model'
- Returns:
- true on success, false on file errors.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-10-2000
- See Also:
- WriteModel
int SampleShape( const CDMultiBand<TAAMPixel> &image, const CAAMShape &shape, CDVector &textureSamples, const bool normalize, const bool useInterpolation, const bool map ) const
-
Builds a texture vector from an image and a shape.
- Parameters:
- image - The image to sample in.
textureSamples - The normalized destination texture vector.
shape - The shape to sample from (in image coordinates).
normalize - Perform normalization after sampling.
Default true.
map - Perform mapping after sampling.
Default true.
- Returns:
- The number of samples done (zero if the shape is outside the image).
- Author:
- Mikkel B. Stegmann
- Version:
- 2-21-2000
void ShapeInstance( const CDVector &c, CAAMShape &outShape ) const
-
Generates a shape based on a set of model parameters.
- Parameters:
- c - Input model parameters.
outShape - The generated shape (resizing are done inside this method).
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-24-2000
void TextureInstance( const CDVector &c, CDVector &outTexture ) const
-
Generates a texture based on a set of model parameters.
- Parameters:
- c - Input model parameters.
outShape - The generated texture (resizing are done inside this method).
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-24-2000
void ShapePCAInstance( const CDVector &b_s, CAAMShape &outShape ) const
-
Generates a shape based on a set of shape b-parameters.
- Parameters:
- b_s - Shape parameters
outShape - Output shape (resized inside method).
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-28-2000
void ShapeTex2Combined( const CAAMShape &shape, const CDVector &texture, CDVector &c ) const
-
Projects the shape and texture into c-space i.e. the
combined model parameters.
- Parameters:
- shape - The input shape aligned to the (aligned) mean shape.
texture - The corresponding normalized texture.
c - The resulting model parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-27-2000
void ShapeTex2Param( const CAAMShape &shape, const CDVector &texture, CDVector &b ) const
-
Extract the b-parameters from a shape and corresponding texture by
inverting the shape and texture pca projection.
Assumes that the shape and texture PCA are done beforehand.
- Parameters:
- shape - The input shape aligned to the (aligned) mean shape.
texture - The corresponding normalized texture.
b - The resulting concatenated b vector.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-6-2000
void ShapeTexParam2Combined( const CDVector &b, CDVector &c ) const
-
Transforms the concatenated b-parameters into combined model
parameters.
- Parameters:
- b - Concatenated shape (weighted) and texture parameters
c - Combined model parameters (resized inside function).
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 2-28-2000
- See Also:
- ShapeTex2Param
bool WriteModel( const CString &filename, const bool txt_only ) const
-
Writes the complete AAMModel to disk as a .txt and an .amf file.
- Parameters:
- filename - Output filename without any extension.
txt_only - If true binary model data is not written.
- Returns:
- true on success, false on file errors.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-10-2000
- See Also:
- ReadModel
void WriteVarianceMap( const CString &filename ) const
-
Plots the variance of each pixel in the model over
the training set into the mean shape and saves the
image.
- Parameters:
- filename - Output image filename.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 5-4-2000
const CAAMShape& ReferenceShape() const
-
Returns the reference shape where all texture sampling
and comparison should be done.
The reference shape is defined as the mean shape size to
mean size and moved to the fourth quadrant.
- Returns:
- The reference shape.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-27-2000
void ShapeTexParam2Combined( const std::vector<CDVector> &bVectors, std::vector<CDVector> &cVectors ) const
-
Converts a set of b-vectors to combined model parameters (c-vectors).
- Parameters:
- bVectors - The input b-vectors.
cVectors - The output c-vectors.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 3-22-2000
CAAMModel( const CAAMModel &m )
-
Copy constructor.
- Parameters:
- m - Object to copy from.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 10-27-2000
CAAMModel& operator=(const CAAMModel &m)
-
Assignment operator.
- Parameters:
- m - Object to copy from.
- Returns:
- This;
- Author:
- Mikkel B. Stegmann
- Version:
- 10-30-2000
void Shape2Combined( const CAAMShape &shape, const CDMultiBand<TAAMPixel> &image, CDVector &c ) const
-
Projects a shape into a set of c parameters.
- Parameters:
- shape - The input shape (assumed to be in abs coordinates).
image - The image where the shape is placed.
c - The output combined model parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 12-5-2000
void Shape2Param( const CAAMShape &shape, CDVector &b_s ) const
-
Projects a shape into a set of shape parameters,
- Parameters:
- shape - The input shape (assumed to be in abs parameters).
b - The output shape model parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 12-5-2000
void Combined2ShapeParam( const CDVector &c, CDVector &b_s ) const
-
Converts combined model parameters to shape parameters.
- Parameters:
- c - Combined model parameters.
b_s - Output non-weighted shape parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 11-4-2002
void Combined2TexParam( const CDVector &c, CDVector &b_g ) const
-
Converts combined model parameters to texture parameters.
- Parameters:
- c - Combined model parameters.
b_g - Output texture parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 11-4-2002
void ShapeTexParam2Combined( const CDVector &b_s, const CDVector &b_g, CDVector &c ) const
-
Projects shape and texture parameters into the combined eigenspace.
- Parameters:
- b_s - Input shape parameters.
b_g - Input texture parameters.
c - Resulting combined model parameters.
- Returns:
- Nothing.
- Author:
- Mikkel B. Stegmann
- Version:
- 11-4-2002
- See Also:
- Combined2TexParam, Combined2ShapeParam