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
00112 typedef Array< double > ParametersType ;
00113
00116
typedef FixedArray<
double,
00117
itkGetStaticConstMacro(MeasurementVectorSize) >
00118 CenterType ;
00119
00121 typedef double RadiusType ;
00122
00124
typedef Vector< double, itkGetStaticConstMacro(MeasurementVectorSize) >
00125 MeanType ;
00126
00128 typedef double StandardDeviationType ;
00129
00131
virtual void SetInputSample(TInputSample* sample) ;
00132 TInputSample*
GetInputSample() ;
00133
00135
virtual unsigned int GetNumberOfParameters() const = 0 ;
00136
00138 virtual
void SetParameters(const
ParametersType ¶meters) ;
00139
ParametersType* GetParameters()
00140 {
return m_Parameters ; }
00141
00144
void SetUseExpectedHistogram(
bool flag) ;
00145
00147
void SetHistogramNumberOfBins(
int numberOfBins) ;
00148
int GetHistogramNumberOfBins()
00149 {
return m_HistogramNumberOfBins ; }
00150
00154
void SetHistogramUseEquiProbableBins(
bool flag) ;
00155
bool GetHistogramUseEquiProbableBins()
00156 {
return m_HistogramUseEquiProbableBins ; }
00157
00159
void SetHistogramBinOverlap(
double overlap) ;
00160
double GetHistogramBinOverlap()
00161 {
return m_HistogramBinOverlap ; }
00162
00165
void SetHistogramExtent(
double extent) ;
00166
double GetHistogramExtent()
00167 {
return m_HistogramExtent ; }
00168
00170
virtual CenterType*
GetCenter() = 0 ;
00171
00173
virtual RadiusType*
GetRadius() = 0 ;
00174
00176
virtual MeanType*
GetMean() = 0 ;
00177
00179
virtual RadiusType*
GetStandardDeviation() = 0 ;
00180
00182
virtual void CreateHistograms() ;
00183
00185
virtual void Resample() ;
00186
00188
ResampledSampleType*
GetResampledSample()
00189 {
return m_Resampler->GetOutput() ; }
00190
00192
virtual unsigned int GetResampledSampleSize() ;
00193
00195
virtual void CalculateProjectionAxes() = 0 ;
00196
00199
virtual void Project(
int projectionAxisIndex) ;
00200
00203
virtual void UpdateExpectedHistogram() ;
00204
00206
double*
GetTotalObservedScale()
00207 {
return &m_TotalObservedScale ; }
00208
00210
virtual double GetCumulativeProbability(
double x)
00211
const = 0 ;
00212
00215
virtual double GetProbabilityDensity(
MeasurementVectorType &measurements)
00216
const = 0 ;
00217
00219
virtual double GetProportion()
const
00220
{
return m_Proportion ; }
00221
00223 HistogramPointer
GetObservedHistogram() ;
00224
00226 HistogramPointer
GetExpectedHistogram() ;
00227
00229
virtual void PrintParameters(std::ostream &os)
const = 0 ;
00230
00232
virtual ParametersType
GetFullParameters() const = 0 ;
00233
00234 protected:
00235
GoodnessOfFitComponentBase() ;
00236 virtual ~GoodnessOfFitComponentBase() ;
00237 virtual
void PrintSelf(std::ostream& os,
Indent indent) const ;
00238
00240 typedef
NeighborhoodSampler< TInputSample > ResamplerType ;
00241
00243 typedef
SampleToHistogramProjectionFilter< ResampledSampleType,
float >
00244 ProjectorType ;
00245
00249 typedef
FixedArray<
double,
00250 itkGetStaticConstMacro(MeasurementVectorSize) >
00251
ProjectionAxisType ;
00252 typedef
FixedArray< ProjectionAxisType,
00253 itkGetStaticConstMacro(MeasurementVectorSize) >
00254
ProjectionAxisArrayType;
00255
00256 ProjectionAxisArrayType* GetProjectionAxes()
00257 {
return &m_ProjectionAxes ; }
00258
00260 virtual void CreateEquiRangeBins() ;
00261
00264
virtual void CreateEquiProbableBins() ;
00265
00266
private:
00267 TInputSample* m_InputSample ;
00268
ParametersType m_Parameters ;
00269
00271
typename ResamplerType::Pointer m_Resampler ;
00272
typename ProjectorType::Pointer m_Projector ;
00273
00274
ProjectionAxisArrayType m_ProjectionAxes ;
00275
00277
unsigned int m_HistogramNumberOfBins ;
00278
bool m_HistogramUseEquiProbableBins ;
00279
double m_HistogramExtent ;
00280
double m_HistogramBinOverlap ;
00281
bool m_HistogramSizeChanged ;
00282
00284
double m_TotalObservedScale ;
00285
double m_HistogramMean ;
00286
double m_HistogramStandardDeviation ;
00287
00288
double m_Proportion ;
00289
00291
HistogramPointer m_ObservedHistogram ;
00292
HistogramPointer m_ExpectedHistogram ;
00293
bool m_UseExpectedHistogram ;
00294
00295 } ;
00296
00297 }
00298 }
00299
00300
#ifndef ITK_MANUAL_INSTANTIATION
00301
#include "itkGoodnessOfFitComponentBase.txx"
00302
#endif
00303
00304
#endif
00305