Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
itk::PSMTwoCostFunction< VDimension > Class Template Reference

#include <itkPSMTwoCostFunction.h>

+ Inheritance diagram for itk::PSMTwoCostFunction< VDimension >:
+ Collaboration diagram for itk::PSMTwoCostFunction< VDimension >:

Public Types

typedef PSMTwoCostFunction Self
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef PSMCostFunction< VDimension > Superclass
 
typedef Superclass::ParticleSystemType ParticleSystemType
 
typedef Superclass::VectorType VectorType
 
- Public Types inherited from itk::PSMCostFunction< VDimension >
typedef PSMCostFunction Self
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef LightObject Superclass
 
typedef PSMParticleSystem< VDimension > ParticleSystemType
 
typedef vnl_vector_fixed< double, VDimension > VectorType
 

Public Member Functions

 itkTypeMacro (PSMTwoCostFunction, PSMCostFunction)
 
 itkNewMacro (Self)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
virtual VectorType Evaluate (unsigned int idx, unsigned int d, const ParticleSystemType *system, double &maxmove) const
 
virtual VectorType Evaluate (unsigned int idx, unsigned int d, const ParticleSystemType *system, double &maxmove, double &energy) const
 
virtual double Energy (unsigned int idx, unsigned int d, const ParticleSystemType *system) const
 
virtual void BeforeEvaluate (unsigned int idx, unsigned int d, const ParticleSystemType *system)
 
virtual void AfterIteration ()
 
virtual void BeforeIteration ()
 
virtual void SetParticleSystem (ParticleSystemType *p)
 
void SetDomainNumber (unsigned int i)
 
void SetFunctionA (PSMCostFunction< VDimension > *o)
 
void SetFunctionB (PSMCostFunction< VDimension > *o)
 
void SetAOn ()
 
void SetAOff ()
 
void SetAOn (bool s)
 
bool GetAOn () const
 
void SetBOn ()
 
void SetBOff ()
 
void SetBOn (bool s)
 
bool GetBOn () const
 
void SetRelativeEnergyScaling (double r)
 
double GetRelativeEnergyScaling () const
 
void SetRelativeGradientScaling (double r)
 
double GetRelativeGradientScaling () const
 
double GetAverageGradMagA () const
 
double GetAverageGradMagB () const
 
double GetAverageEnergyA () const
 
double GetAverageEnergyB () const
 
- Public Member Functions inherited from itk::PSMCostFunction< VDimension >
 itkTypeMacro (PSMCostFunction, LightObject)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
virtual void ResetBuffers ()
 
virtual ParticleSystemTypeGetParticleSystem () const
 
virtual int GetDomainNumber () const
 

Protected Member Functions

void operator= (const PSMTwoCostFunction &)
 
 PSMTwoCostFunction (const PSMTwoCostFunction &)
 
- Protected Member Functions inherited from itk::PSMCostFunction< VDimension >
void operator= (const PSMCostFunction &)
 
 PSMCostFunction (const PSMCostFunction &)
 

Protected Attributes

bool m_AOn
 
bool m_BOn
 
double m_RelativeGradientScaling
 
double m_RelativeEnergyScaling
 
double m_AverageGradMagA
 
double m_AverageGradMagB
 
double m_AverageEnergyA
 
double m_AverageEnergyB
 
double m_Counter
 
PSMCostFunction< VDimension >::Pointer m_FunctionA
 
PSMCostFunction< VDimension >::Pointer m_FunctionB
 
- Protected Attributes inherited from itk::PSMCostFunction< VDimension >
ParticleSystemTypem_ParticleSystem
 
unsigned int m_DomainNumber
 

Detailed Description

template<unsigned int VDimension>
class itk::PSMTwoCostFunction< VDimension >

This class combines two PSMCostFunction objects into a single PSMCostFunction that is the linear combination of the two. The second function (FunctionB) can be scaled relative to the first function (SetRelativeGradientScaling), and evaluation of both functions may be toggled on and off.

An example of how to use this class is given by itkPSMEntropyModelFilter, which combines an itkPSMParticleEntropyFunction (FunctionA) with an itkPSMShapeEntropyFunction (Function B) to perform simultaneous maximization of entropy on the surfaces of a collection of shapes with minimization of the entropy of the collection's distribution in shape space.

See also
itkPSMEntropyModelFilter
Author
Josh Cates

Definition at line 51 of file itkPSMTwoCostFunction.h.

Member Typedef Documentation

template<unsigned int VDimension>
typedef Superclass::ParticleSystemType itk::PSMTwoCostFunction< VDimension >::ParticleSystemType

Type of particle system.

Definition at line 62 of file itkPSMTwoCostFunction.h.

template<unsigned int VDimension>
typedef PSMTwoCostFunction itk::PSMTwoCostFunction< VDimension >::Self

Standard class typedefs.

Definition at line 55 of file itkPSMTwoCostFunction.h.

template<unsigned int VDimension>
typedef Superclass::VectorType itk::PSMTwoCostFunction< VDimension >::VectorType

Vector type.

Definition at line 65 of file itkPSMTwoCostFunction.h.

Member Function Documentation

template<unsigned int VDimension>
virtual void itk::PSMTwoCostFunction< VDimension >::AfterIteration ( )
inlinevirtual

This method is called by a solver after each iteration. Subclasses may or may not implement this method.

Reimplemented from itk::PSMCostFunction< VDimension >.

Definition at line 96 of file itkPSMTwoCostFunction.h.

97  {
98  if (m_AOn) m_FunctionA->AfterIteration();
99  if (m_BOn) m_FunctionB->AfterIteration();
100  }
template<unsigned int VDimension>
virtual void itk::PSMTwoCostFunction< VDimension >::BeforeEvaluate ( unsigned int  ,
unsigned int  ,
const ParticleSystemType  
)
inlinevirtual

This method may be called to set up the state of the function object before a call to Evaluate. It is necessary in order to initialize certain constants and variables that may be used for calculating the Energy as well as the Gradients. Typically this is only necessary for the adaptive gradient descent algorithm.

Reimplemented from itk::PSMCostFunction< VDimension >.

Definition at line 87 of file itkPSMTwoCostFunction.h.

89  {
90  if (m_AOn) m_FunctionA->BeforeEvaluate(idx, d, system);
91  if (m_BOn) m_FunctionB->BeforeEvaluate(idx, d, system);
92  }
template<unsigned int VDimension>
virtual void itk::PSMTwoCostFunction< VDimension >::BeforeIteration ( )
inlinevirtual

This method is called by a solver before each iteration. Subclasses may or may not implement this method.

Reimplemented from itk::PSMCostFunction< VDimension >.

Definition at line 104 of file itkPSMTwoCostFunction.h.

105  {
106  if (m_AOn) m_FunctionA->BeforeIteration();
107  if (m_BOn) m_FunctionB->BeforeIteration();
108 
109  m_AverageGradMagA = 0.0;
110  m_AverageGradMagB = 0.0;
111 
112  m_AverageEnergyA = 0.0;
113  m_AverageEnergyB = 0.0;
114 
115  m_Counter = 0.0;
116  }
template<unsigned int VDimension>
PSMTwoCostFunction< VDimension >::VectorType itk::PSMTwoCostFunction< VDimension >::Evaluate ( unsigned int  idx,
unsigned int  d,
const ParticleSystemType system,
double &  maxmove 
) const
virtual

The first argument is a pointer to the particle system. The second argument is the index of the domain within that particle system. The third argument is the index of the particle location within the given domain.

Implements itk::PSMCostFunction< VDimension >.

Definition at line 28 of file itkPSMTwoCostFunction.hxx.

31 {
32  double maxA, maxB;
33  maxA = 0;
34  maxB = 0;
35  VectorType ansA;
36  ansA.fill(0.0);
37  VectorType ansB;
38  ansB.fill(0.0);
39 
40  const_cast<PSMTwoCostFunction *>(this)->m_Counter = m_Counter + 1.0;
41 
42  // Evaluate A if it is turned on
43  if (m_AOn)
44  {
45  ansA = m_FunctionA->Evaluate(idx, d, system, maxA);
46  const_cast<PSMTwoCostFunction *>(this)->m_AverageGradMagA = m_AverageGradMagA + ansA.magnitude();
47  }
48 
49  // Evaluate B if it is turned on
50  if (m_BOn)
51  {
52  ansB = m_FunctionB->Evaluate(idx, d, system, maxB);
53  const_cast<PSMTwoCostFunction *>(this)->m_AverageGradMagB = m_AverageGradMagB + ansB.magnitude();
54  }
55 
56  // Compute maximum move and return the predicted move for current configuration
57  if (m_BOn)
58  {
59  if (m_AOn) // both A and B are active
60  {
61  if (maxA > maxB) maxmove = maxB;
62  else maxmove = maxA;
63  return (ansA + m_RelativeGradientScaling * ansB);
64  }
65  else // B is active, A is not active
66  {
67  maxmove = maxB;
68  return ansB;
69  }
70  }
71  else // only A is active
72  {
73  maxmove = maxA;
74  return ansA;
75  }
76 
77  // If nothing is turned on, then return a max time
78  // step of 0 and a bogus vector.
79  maxmove = 0.0;
80  return ansA;
81 }
Superclass::VectorType VectorType
template<unsigned int VDimension>
itk::PSMTwoCostFunction< VDimension >::itkNewMacro ( Self  )

Method for creation through the object factory.

template<unsigned int VDimension>
itk::PSMTwoCostFunction< VDimension >::itkStaticConstMacro ( Dimension  ,
unsigned  int,
VDimension   
)

Dimensionality of the domain of the particle system.

template<unsigned int VDimension>
void itk::PSMTwoCostFunction< VDimension >::SetAOn ( )
inline

Turn each term on and off.

Definition at line 149 of file itkPSMTwoCostFunction.h.

149 { m_AOn = true; }
template<unsigned int VDimension>
virtual void itk::PSMTwoCostFunction< VDimension >::SetParticleSystem ( ParticleSystemType p)
inlinevirtual

Some subclasses may require a pointer to the particle system and its domain number. These methods set/get those values.

Reimplemented from itk::PSMCostFunction< VDimension >.

Definition at line 120 of file itkPSMTwoCostFunction.h.

121  {
123  if (m_FunctionA.GetPointer() != 0) m_FunctionA->SetParticleSystem(p);
124  if (m_FunctionB.GetPointer() != 0) m_FunctionB->SetParticleSystem(p);
125  }
virtual void SetParticleSystem(ParticleSystemType *p)
template<unsigned int VDimension>
void itk::PSMTwoCostFunction< VDimension >::SetRelativeEnergyScaling ( double  r)
inline

The relative scaling scales the gradient B relative to A. By default this value is 1.0.

Definition at line 160 of file itkPSMTwoCostFunction.h.

161  {
162  m_RelativeEnergyScaling = r;
163  }

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