00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkGoodnessOfFitComponentBase_h
00018
#define __itkGoodnessOfFitComponentBase_h
00019
00020
#include "itkObject.h"
00021
#include "itkArray.h"
00022
#include "itkHistogram.h"
00023
#include "itkFunctionBase.h"
00024
#include "itkNeighborhoodSampler.h"
00025
#include "itkSampleToHistogramProjectionFilter.h"
00026
00027
namespace itk{
00028
namespace Statistics{
00029
00079
template<
class TInputSample >
00080 class GoodnessOfFitComponentBase
00081 :
public Object
00082 {
00083
public:
00085 typedef GoodnessOfFitComponentBase Self;
00086 typedef Object Superclass;
00087 typedef SmartPointer< Self > Pointer;
00088 typedef SmartPointer< const Self > ConstPointer;
00089
00091
itkTypeMacro(
GoodnessOfFitComponentBase,
Object) ;
00092
00094 typedef TInputSample
InputSampleType ;
00095
00097
itkStaticConstMacro(MeasurementVectorSize,
unsigned int,
00098 TInputSample::MeasurementVectorSize) ;
00099
00101 typedef typename TInputSample::MeasurementType
MeasurementType ;
00102 typedef typename TInputSample::MeasurementVectorType
MeasurementVectorType ;
00103
00105 typedef Subsample< TInputSample > ResampledSampleType ;
00106
00108 typedef Histogram< float, 1 > HistogramType ;
00109 typedef typename HistogramType::Pointer
HistogramPointer ;
00110 typedef typename HistogramType::ConstPointer
HistogramConstPointer ;
00111
00113 typedef Array< double > ParametersType ;
00114
00117
typedef FixedArray<
double,
00118
itkGetStaticConstMacro(MeasurementVectorSize) >
00119 CenterType ;
00120
00122 typedef double RadiusType ;
00123
00125
typedef Vector< double, itkGetStaticConstMacro(MeasurementVectorSize) >
00126 MeanType ;
00127
00129 typedef double StandardDeviationType ;
00130
00132
virtual void SetInputSample(
const TInputSample* sample) ;
00133
const TInputSample*
GetInputSample() const;
00134
00136 virtual
unsigned int GetNumberOfParameters() const = 0 ;
00137
00139 virtual
void SetParameters(const
ParametersType ¶meters) ;
00140
ParametersType* GetParameters()
00141 {
return m_Parameters ; }
00142
00145
void SetUseExpectedHistogram(
bool flag) ;
00146
00148
void SetHistogramNumberOfBins(
int numberOfBins) ;
00149
int GetHistogramNumberOfBins()
00150 {
return m_HistogramNumberOfBins ; }
00151
00155
void SetHistogramUseEquiProbableBins(
bool flag) ;
00156
bool GetHistogramUseEquiProbableBins()
00157 {
return m_HistogramUseEquiProbableBins ; }
00158
00160
void SetHistogramBinOverlap(
double overlap) ;
00161
double GetHistogramBinOverlap()
00162 {
return m_HistogramBinOverlap ; }
00163
00166
void SetHistogramExtent(
double extent) ;
00167
double GetHistogramExtent()
00168 {
return m_HistogramExtent ; }
00169
00171
virtual CenterType*
GetCenter() = 0 ;
00172
00174
virtual RadiusType*
GetRadius() = 0 ;
00175
00177
virtual MeanType*
GetMean() = 0 ;
00178
00180
virtual RadiusType*
GetStandardDeviation() = 0 ;
00181
00183
virtual void CreateHistograms() ;
00184
00186
virtual void Resample() ;
00187
00189
ResampledSampleType*
GetResampledSample()
00190 {
return m_Resampler->GetOutput() ; }
00191
00193
virtual unsigned int GetResampledSampleSize() ;
00194
00196
virtual void CalculateProjectionAxes() = 0 ;
00197
00200
virtual void Project(
int projectionAxisIndex) ;
00201
00204
virtual void UpdateExpectedHistogram() ;
00205
00207
double*
GetTotalObservedScale()
00208 {
return &m_TotalObservedScale ; }
00209
00211
virtual double GetCumulativeProbability(
double x)
00212
const = 0 ;
00213
00216
virtual double GetProbabilityDensity(
MeasurementVectorType &measurements)
00217
const = 0 ;
00218
00220
virtual double GetProportion()
const
00221
{
return m_Proportion ; }
00222
00224 HistogramType *
GetObservedHistogram();
00225
00227 HistogramType *
GetExpectedHistogram();
00228
00230
virtual void PrintParameters(std::ostream &os)
const = 0 ;
00231
00233
virtual ParametersType
GetFullParameters() const = 0 ;
00234
00235 protected:
00236
GoodnessOfFitComponentBase() ;
00237 virtual ~GoodnessOfFitComponentBase() ;
00238 virtual
void PrintSelf(std::ostream& os,
Indent indent) const ;
00239
00241 typedef
NeighborhoodSampler< TInputSample > ResamplerType ;
00242
00244 typedef
SampleToHistogramProjectionFilter< ResampledSampleType,
float >
00245 ProjectorType ;
00246
00250 typedef
FixedArray<
double,
00251 itkGetStaticConstMacro(MeasurementVectorSize) >
00252
ProjectionAxisType ;
00253 typedef
FixedArray< ProjectionAxisType,
00254 itkGetStaticConstMacro(MeasurementVectorSize) >
00255
ProjectionAxisArrayType;
00256
00257 ProjectionAxisArrayType* GetProjectionAxes()
00258 {
return &m_ProjectionAxes ; }
00259
00261 virtual void CreateEquiRangeBins() ;
00262
00265
virtual void CreateEquiProbableBins() ;
00266
00267
private:
00268
const TInputSample* m_InputSample ;
00269
ParametersType m_Parameters ;
00270
00272
typename ResamplerType::Pointer m_Resampler ;
00273
typename ProjectorType::Pointer m_Projector ;
00274
00275
ProjectionAxisArrayType m_ProjectionAxes ;
00276
00278
unsigned int m_HistogramNumberOfBins ;
00279
bool m_HistogramUseEquiProbableBins ;
00280
double m_HistogramExtent ;
00281
double m_HistogramBinOverlap ;
00282
bool m_HistogramSizeChanged ;
00283
00285
double m_TotalObservedScale ;
00286
double m_HistogramMean ;
00287
double m_HistogramStandardDeviation ;
00288
00289
double m_Proportion ;
00290
00292
HistogramPointer m_ObservedHistogram ;
00293
HistogramPointer m_ExpectedHistogram ;
00294
bool m_UseExpectedHistogram ;
00295
00296 } ;
00297
00298 }
00299 }
00300
00301
#ifndef ITK_MANUAL_INSTANTIATION
00302
#include "itkGoodnessOfFitComponentBase.txx"
00303
#endif
00304
00305
#endif
00306