00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSparseFrequencyContainer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/09/30 14:14:19 $ 00007 Version: $Revision: 1.11 $ 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 __itkSparseFrequencyContainer_h 00018 #define __itkSparseFrequencyContainer_h 00019 00020 #include <map> 00021 #include "itkObjectFactory.h" 00022 #include "itkObject.h" 00023 #include "itkNumericTraits.h" 00024 00025 namespace itk{ 00026 namespace Statistics{ 00027 00036 class ITK_EXPORT SparseFrequencyContainer : public Object 00037 { 00038 public: 00040 typedef SparseFrequencyContainer Self; 00041 typedef Object Superclass; 00042 typedef SmartPointer<Self> Pointer; 00043 typedef SmartPointer<const Self> ConstPointer; 00044 00046 itkTypeMacro(SparseFrequencyContainer, Object); 00047 itkNewMacro(Self); 00048 00050 typedef unsigned long InstanceIdentifier ; 00051 00053 typedef float FrequencyType ; 00054 00056 typedef NumericTraits<FrequencyType>::AccumulateType TotalFrequencyType ; 00057 00059 typedef std::map< InstanceIdentifier, FrequencyType > FrequencyContainerType ; 00060 typedef FrequencyContainerType::const_iterator 00061 FrequencyContainerConstIterator ; 00062 00064 void Initialize(unsigned long length) ; 00065 00068 void SetToZero() ; 00069 00072 bool SetFrequency(const InstanceIdentifier id, const FrequencyType value) ; 00073 00076 bool IncreaseFrequency(const InstanceIdentifier id, 00077 const FrequencyType value); 00078 00081 FrequencyType GetFrequency(const InstanceIdentifier id) const ; 00082 00083 TotalFrequencyType GetTotalFrequency() 00084 { return m_TotalFrequency ; } 00085 00086 protected: 00087 SparseFrequencyContainer() ; 00088 virtual ~SparseFrequencyContainer() {} 00089 void PrintSelf(std::ostream& os, Indent indent) const; 00090 00091 private: 00092 SparseFrequencyContainer(const Self&) ; //purposely not implemented 00093 void operator=(const Self&) ; //purposely not implemented 00094 00095 // Container of histogram 00096 FrequencyContainerType m_FrequencyContainer ; 00097 TotalFrequencyType m_TotalFrequency ; 00098 } ; // end of class 00099 00100 } // end of namespace Statistics 00101 } // end of namespace itk 00102 00103 #endif