00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkPSquareQuantile_h
00018 #define __itkPSquareQuantile_h
00019
00020 namespace itk{
00021 namespace Statistics{
00022
00042 template< class TData >
00043 class PSquareQuantile
00044 {
00045 public:
00046 typedef TData DataContainerType ;
00047 typedef typename DataContainerType::Pointer DataContainerPointer ;
00048 typedef typename DataContainerType::MeasurementType ValueType ;
00049 typedef typename DataContainerType::InstanceIdentifier InstanceIdentifier ;
00050
00054 double operator() (DataContainerPointer data, long dimension,
00055 double p) ;
00056
00057 protected:
00061 ValueType GetValue(InstanceIdentifier id) const
00062 {
00063 return m_Data->GetMeasurement(m_Dimension, id) ;
00064 }
00065
00069 void SetValue(InstanceIdentifier id, ValueType value)
00070 {
00071 m_Data->SetMeasurement(m_Dimension, id, value) ;
00072 }
00073
00079 double ParabolicEstimate(InstanceIdentifier i, int direction) const
00080 {
00081 double estimate ;
00082 double p1 = double(direction) / double(n[i + 1] - n[i - 1]) ;
00083 double p2 = double(n[i] - n[i - 1] + direction) * double(q[i + 1] - q[i]) /
00084 double( n[i + 1] - n[i]) ;
00085 double p3 = double(n[i + 1] - n[i] - direction) * double(q[i] - q[i - 1]) /
00086 double(n[i] - n[i - 1]) ;
00087
00088 estimate = q[i] + p1 * (p2 + p3) ;
00089 return estimate ;
00090 }
00091
00095 double LinearEstimate(InstanceIdentifier i, int direction)
00096 {
00097 return q[i] + direction *
00098 (q[i + direction] - q[i]) / (n[i + direction] - n[i]) ;
00099 }
00100
00101 void PrintSelf(std::ostream& os, Indent indent) const;
00102
00103 private:
00104 DataContainerPointer m_Data ;
00105 long m_Dimension ;
00106
00107 std::vector< double > q ;
00108 std::vector< long > n ;
00109 std::vector< double > np ;
00110 std::vector< double > dn ;
00111 } ;
00112
00113 }
00114 }
00115
00116 #ifndef ITK_MANUAL_INSTANTIATION
00117 #include "itkPSquareQuantile.txx"
00118 #endif
00119
00120 #endif