17 #ifndef __itkHistogram_h
18 #define __itkHistogram_h
30 namespace Statistics {
38 template <
typename THistogram>
80 template <
class TMeasurement = float,
unsigned int VMeasurementVectorSize = 1,
83 :
public Sample < FixedArray< TMeasurement, VMeasurementVectorSize > >
102 itkStaticConstMacro(MeasurementVectorSize,
unsigned int,
103 VMeasurementVectorSize);
140 void Initialize(
const SizeType &size);
170 itkGetMacro(ClipBinsAtEnds,
bool);
174 itkSetMacro(ClipBinsAtEnds,
bool);
178 bool IsIndexOutOfBounds(
const IndexType &index)
const;
186 unsigned int Size()
const;
195 return m_Size[dimension];
200 const unsigned long nbin)
const
201 {
return m_Min[dimension][nbin]; }
205 const unsigned long nbin)
const
206 {
return m_Max[dimension][nbin]; }
209 void SetBinMin(
const unsigned int dimension,
const unsigned long nbin,
211 { m_Min[dimension][nbin] = min; }
214 void SetBinMax(
const unsigned int dimension,
216 { m_Max[dimension][nbin] = max; }
220 const MeasurementType& GetBinMinFromValue(
const unsigned int dimension,
221 const float value )
const;
225 const MeasurementType& GetBinMaxFromValue(
const unsigned int dimension,
226 const float value )
const;
230 {
return m_Min[dimension]; }
234 {
return m_Max[dimension]; }
245 MeasurementVectorType& GetHistogramMinFromIndex(
const IndexType &index);
248 MeasurementVectorType& GetHistogramMaxFromIndex(
const IndexType &index);
252 {
return m_FrequencyContainer->GetFrequency(
id); }
255 FrequencyType GetFrequency(
const IndexType &index)
const;
258 void SetFrequency(
const FrequencyType value);
263 {
return m_FrequencyContainer->SetFrequency(
id, value); }
267 bool SetFrequency(
const IndexType &index,
268 const FrequencyType value);
272 bool SetFrequency(
const MeasurementVectorType &measurement,
273 const FrequencyType value);
281 {
return m_FrequencyContainer->IncreaseFrequency(
id, value); }
286 bool IncreaseFrequency(
const IndexType &index,
287 const FrequencyType value);
292 bool IncreaseFrequency(
const MeasurementVectorType &measurement,
293 const FrequencyType value);
298 const MeasurementVectorType & GetMeasurementVector(
const InstanceIdentifier &
id)
const;
301 const MeasurementVectorType & GetMeasurementVector(
const IndexType &index)
const;
305 MeasurementType GetMeasurement(
const unsigned long n,
306 const unsigned int dimension)
const;
309 TotalFrequencyType GetTotalFrequency()
const;
312 FrequencyType GetFrequency(
const unsigned long n,
313 const unsigned int dimension)
const;
330 double Quantile(
const unsigned int dimension,
const double &p)
const;
333 void PrintSelf(std::ostream& os,
Indent indent)
const;
346 m_Histogram = histogram;
350 : m_Id(id), m_Histogram(histogram) {}
354 return m_Histogram->GetFrequency(m_Id);
359 return m_Histogram->SetFrequency(m_Id, value);
367 return m_Histogram->GetMeasurementVector(m_Id);
377 {
return (m_Id != it.
m_Id); }
380 {
return (m_Id == it.
m_Id); }
412 m_Histogram = histogram;
416 : m_Id(id), m_Histogram(histogram) {}
420 return m_Histogram->GetFrequency(m_Id);
428 return m_Histogram->GetMeasurementVector(m_Id);
438 {
return (m_Id != it.
m_Id); }
441 {
return (m_Id == it.
m_Id); }
472 return Iterator(m_OffsetTable[VMeasurementVectorSize],
this);
483 return ConstIterator(m_OffsetTable[VMeasurementVectorSize],
this);
488 if( s!= VMeasurementVectorSize )
490 itkExceptionMacro( <<
"This Histogram class is meant to be used only for "
491 <<
"fixed length vectors of length " << VMeasurementVectorSize <<
492 ". Cannot set this to " << s);
497 return VMeasurementVectorSize;
509 void operator=(
const Self&);
516 std::vector< std::vector<MeasurementType> >
m_Min;
519 std::vector< std::vector<MeasurementType> >
m_Max;
531 #ifndef ITK_MANUAL_INSTANTIATION