00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSparseFrequencyContainer2.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-02 05:43:58 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkSparseFrequencyContainer2_h 00018 #define __itkSparseFrequencyContainer2_h 00019 00020 #include <map> 00021 #include "itkObjectFactory.h" 00022 #include "itkObject.h" 00023 #include "itkNumericTraits.h" 00024 #include "itkMeasurementVectorTraits.h" 00025 00026 namespace itk { 00027 namespace Statistics { 00028 00037 class ITK_EXPORT SparseFrequencyContainer2 : public Object 00038 { 00039 public: 00041 typedef SparseFrequencyContainer2 Self; 00042 typedef Object Superclass; 00043 typedef SmartPointer<Self> Pointer; 00044 typedef SmartPointer<const Self> ConstPointer; 00045 00047 itkTypeMacro(SparseFrequencyContainer2, Object); 00048 itkNewMacro(Self); 00050 00052 typedef MeasurementVectorTraits::InstanceIdentifier InstanceIdentifier; 00053 00055 typedef MeasurementVectorTraits::AbsoluteFrequencyType AbsoluteFrequencyType; 00056 00058 typedef MeasurementVectorTraits::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType; 00059 00061 typedef MeasurementVectorTraits::RelativeFrequencyType RelativeFrequencyType; 00062 00064 typedef MeasurementVectorTraits::TotalRelativeFrequencyType TotalRelativeFrequencyType; 00065 00067 typedef std::map< InstanceIdentifier, AbsoluteFrequencyType > FrequencyContainerType; 00068 typedef FrequencyContainerType::const_iterator 00069 FrequencyContainerConstIterator; 00070 00072 void Initialize(unsigned long length); 00073 00076 void SetToZero(); 00077 00080 bool SetFrequency(const InstanceIdentifier id, const AbsoluteFrequencyType value); 00081 00084 bool IncreaseFrequency(const InstanceIdentifier id, 00085 const AbsoluteFrequencyType value); 00086 00089 AbsoluteFrequencyType GetFrequency(const InstanceIdentifier id) const; 00090 00091 TotalAbsoluteFrequencyType GetTotalFrequency() 00092 { 00093 return m_TotalFrequency; 00094 } 00095 00096 protected: 00097 SparseFrequencyContainer2(); 00098 virtual ~SparseFrequencyContainer2() {} 00099 void PrintSelf(std::ostream& os, Indent indent) const; 00100 00101 private: 00102 SparseFrequencyContainer2(const Self&); //purposely not implemented 00103 void operator=(const Self&); //purposely not implemented 00104 00105 // Container of histogram 00106 FrequencyContainerType m_FrequencyContainer; 00107 TotalAbsoluteFrequencyType m_TotalFrequency; 00108 }; // end of class 00109 00110 } // end of namespace Statistics 00111 } // end of namespace itk 00112 00113 #endif 00114