ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkSparseFrequencyContainer2.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkSparseFrequencyContainer2_h
00019 #define __itkSparseFrequencyContainer2_h
00020 
00021 #include <map>
00022 #include "itkObjectFactory.h"
00023 #include "itkObject.h"
00024 #include "itkNumericTraits.h"
00025 #include "itkMeasurementVectorTraits.h"
00026 
00027 namespace itk
00028 {
00029 namespace Statistics
00030 {
00040 class ITK_EXPORT SparseFrequencyContainer2:public Object
00041 {
00042 public:
00044   typedef SparseFrequencyContainer2  Self;
00045   typedef Object                     Superclass;
00046   typedef SmartPointer< Self >       Pointer;
00047   typedef SmartPointer< const Self > ConstPointer;
00048 
00050   itkTypeMacro(SparseFrequencyContainer2, Object);
00051   itkNewMacro(Self);
00053 
00055   typedef MeasurementVectorTraits::InstanceIdentifier InstanceIdentifier;
00056 
00058   typedef MeasurementVectorTraits::AbsoluteFrequencyType AbsoluteFrequencyType;
00059 
00061   typedef MeasurementVectorTraits::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType;
00062 
00064   typedef MeasurementVectorTraits::RelativeFrequencyType RelativeFrequencyType;
00065 
00067   typedef MeasurementVectorTraits::TotalRelativeFrequencyType TotalRelativeFrequencyType;
00068 
00070   typedef std::map< InstanceIdentifier, AbsoluteFrequencyType > FrequencyContainerType;
00071   typedef FrequencyContainerType::const_iterator
00072   FrequencyContainerConstIterator;
00073 
00075   void Initialize(SizeValueType length);
00076 
00079   void SetToZero();
00080 
00083   bool SetFrequency(const InstanceIdentifier id, const AbsoluteFrequencyType value);
00084 
00087   bool IncreaseFrequency(const InstanceIdentifier id,
00088                          const AbsoluteFrequencyType value);
00089 
00092   AbsoluteFrequencyType GetFrequency(const InstanceIdentifier id) const;
00093 
00094   TotalAbsoluteFrequencyType GetTotalFrequency()
00095   {
00096     return m_TotalFrequency;
00097   }
00098 
00099 protected:
00100   SparseFrequencyContainer2();
00101   virtual ~SparseFrequencyContainer2() {}
00102   void PrintSelf(std::ostream & os, Indent indent) const;
00103 
00104 private:
00105   SparseFrequencyContainer2(const Self &); //purposely not implemented
00106   void operator=(const Self &);            //purposely not implemented
00107 
00108   // Container of histogram
00109   FrequencyContainerType     m_FrequencyContainer;
00110   TotalAbsoluteFrequencyType m_TotalFrequency;
00111 };  // end of class
00112 } // end of namespace Statistics
00113 } // end of namespace itk
00114 
00115 #endif
00116