Shapeworks Studio  2.1
Shape analysis software suite
itkPSMParticleEntropyFunction.h
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicabcle law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkPSMParticleEntropyFunction_h
19 #define __itkPSMParticleEntropyFunction_h
20 
21 #include "itkPSMCostFunction.h"
22 #include "itkPSMContainerArrayAttribute.h"
23 #include "itkPSMImageDomainWithGradients.h"
24 #include <vector>
25 
26 namespace itk
27 {
28 
83 template <class TGradientNumericType, unsigned int VDimension>
84 class PSMParticleEntropyFunction : public PSMCostFunction<VDimension>
85 {
86 public:
89  typedef SmartPointer<Self> Pointer;
90  typedef SmartPointer<const Self> ConstPointer;
91  typedef PSMCostFunction<VDimension> Superclass;
93 
95  typedef TGradientNumericType GradientNumericType;
96 
99 
102 
105  typedef typename ParticleSystemType::PointType PointType;
106  typedef vnl_vector_fixed<TGradientNumericType, VDimension> GradientVectorType;
107 
109  itkNewMacro(Self);
110 
112  itkStaticConstMacro(Dimension, unsigned int, VDimension);
113 
118  virtual VectorType Evaluate(unsigned int, unsigned int, const ParticleSystemType *,
119  double &) const;
120 
121  virtual VectorType Evaluate(unsigned int, unsigned int, const ParticleSystemType *,
122  double &, double &) const
123  {
124  itkExceptionMacro("This method not implemented");
125  return VectorType();
126  }
127  virtual double Energy(unsigned int, unsigned int, const ParticleSystemType *) const
128  {
129  itkExceptionMacro("This method not implemented");
130  return 0.0;
131  }
132 
133  virtual void ResetBuffers()
134  {
135  m_SpatialSigmaCache->ZeroAllValues();
136  }
137 
138 
141  virtual double EstimateSigma(unsigned int, const typename ParticleSystemType::PointVectorType &,
142  const std::vector<double> &,
143  const PointType &, double, double, int &err) const;
144 
148  TGradientNumericType AngleCoefficient(const GradientVectorType&,
149  const GradientVectorType&) const;
150 
161  { m_MinimumNeighborhoodRadius = s; }
162  double GetMinimumNeighborhoodRadius() const
163  { return m_MinimumNeighborhoodRadius; }
164 
174  { m_MaximumNeighborhoodRadius = s; }
175  double GetMaximumNeighborhoodRadius() const
176  { return m_MaximumNeighborhoodRadius; }
177 
189  void SetFlatCutoff(double s)
190  { m_FlatCutoff = s; }
191  double GetFlatCutoff() const
192  { return m_FlatCutoff; }
193 
204  { m_NeighborhoodToSigmaRatio = s; }
205  double GetNeighborhoodToSigmaRatio() const
206  { return m_NeighborhoodToSigmaRatio; }
207 
211  void SetSpatialSigmaCache( SigmaCacheType *s)
212  { m_SpatialSigmaCache = s; }
213  SigmaCacheType *GetSpatialSigmaCache()
214  { return m_SpatialSigmaCache.GetPointer(); }
215  const SigmaCacheType *GetSpatialSigmaCache() const
216  { return m_SpatialSigmaCache.GetPointer(); }
217 
221  void ComputeAngularWeights(const PointType &,
222  const typename ParticleSystemType::PointVectorType &,
224  std::vector<double> &) const;
225 
226 protected:
227  PSMParticleEntropyFunction() : m_MinimumNeighborhoodRadius(5.0),
228  m_MaximumNeighborhoodRadius(1024.0), m_FlatCutoff(0.3),
229  m_NeighborhoodToSigmaRatio(3.0) {}
230 
231  virtual ~PSMParticleEntropyFunction() {}
232  void operator=(const PSMParticleEntropyFunction &);
234 
235  double m_MinimumNeighborhoodRadius;
236  double m_MaximumNeighborhoodRadius;
237  double m_FlatCutoff;
238  double m_NeighborhoodToSigmaRatio;
239  typename SigmaCacheType::Pointer m_SpatialSigmaCache;
240 };
241 
242 
243 } //end namespace
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 #include "itkPSMParticleEntropyFunction.hxx"
247 #endif
248 
249 #endif
PSMContainerArrayAttribute< double, VDimension > SigmaCacheType
virtual VectorType Evaluate(unsigned int, unsigned int, const ParticleSystemType *, double &) const
itkStaticConstMacro(Dimension, unsigned int, VDimension)
void ComputeAngularWeights(const PointType &, const typename ParticleSystemType::PointVectorType &, const PSMImageDomainWithGradients< TGradientNumericType, VDimension > *, std::vector< double > &) const
TGradientNumericType AngleCoefficient(const GradientVectorType &, const GradientVectorType &) const
virtual double EstimateSigma(unsigned int, const typename ParticleSystemType::PointVectorType &, const std::vector< double > &, const PointType &, double, double, int &err) const
Superclass::ParticleSystemType ParticleSystemType
vnl_vector_fixed< double, VDimension > VectorType
This function returns an estimate of the gradient of the entropy of a particle distribution with resp...
PSMParticleSystem< VDimension > ParticleSystemType
Definition: Shape.h:14