Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkListSampleToHistogramGenerator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkListSampleToHistogramGenerator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/08/24 15:16:48 $
00007   Version:   $Revision: 1.13 $
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 __itkListSampleToHistogramGenerator_h
00018 #define __itkListSampleToHistogramGenerator_h
00019 
00020 #include "itkObject.h"
00021 #include "itkListSampleBase.h"
00022 #include "itkHistogram.h"
00023 #include "itkStatisticsAlgorithm.h"
00024 #include "itkDenseFrequencyContainer.h"
00025 
00026 namespace itk{
00027 namespace Statistics{
00028 
00066 template< class TListSample, 
00067           class THistogramMeasurement,  
00068           class TFrequencyContainer = DenseFrequencyContainer, 
00069           unsigned int TMeasurementVectorLength = 1 >
00070 class ITK_EXPORT ListSampleToHistogramGenerator :
00071     public Object
00072 {
00073 public:
00075   typedef ListSampleToHistogramGenerator Self;
00076   typedef Object Superclass;
00077   typedef SmartPointer<Self>   Pointer;
00078   typedef SmartPointer<const Self> ConstPointer;
00079   
00081   itkTypeMacro(ListSampleToHistogramGenerator, Object) ;
00082   
00084   itkNewMacro(Self) ;
00085 
00087   itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00088                       TMeasurementVectorLength);
00089 
00090   typedef Histogram< THistogramMeasurement, 
00091                      itkGetStaticConstMacro(MeasurementVectorSize),
00092                      TFrequencyContainer > HistogramType ;
00093 
00094   typedef typename HistogramType::SizeType HistogramSizeType ;
00095   typedef typename HistogramType::MeasurementVectorType  MeasurementVectorType;
00096 
00098   void SetListSample(const TListSample* list)
00099     { 
00100     // Throw exception if the length of measurement vectors in the list is not
00101     // equal to the dimension of the histogram.
00102     if( list->GetMeasurementVectorSize() != MeasurementVectorSize )
00103       {
00104       itkExceptionMacro(<< "Length of measurement vectors in the list sample is "
00105         << list->GetMeasurementVectorSize() << " but histogram dimension is "
00106         << MeasurementVectorSize);
00107       }
00108     m_List = list ; 
00109     }
00110 
00111   void SetMarginalScale(float scale)
00112   { m_MarginalScale = scale ; }
00113 
00114   void SetNumberOfBins(HistogramSizeType sizes)
00115   { m_Sizes = sizes ; }
00116 
00117   const HistogramType* GetOutput() const
00118   { return m_Histogram ; }
00119 
00120   void Update() 
00121   { this->GenerateData() ; }
00122 
00123   itkSetMacro(AutoMinMax,bool);
00124   itkGetConstReferenceMacro(AutoMinMax,bool);
00125 
00126   void SetHistogramMin(const MeasurementVectorType & histogramMin)
00127     {
00128     m_HistogramMin = histogramMin;
00129     m_AutoMinMax = false;
00130     
00131     // Sanity check.. Check to see that container m_HistogramMin has the same
00132     // length as the length of measurement vectors in the list sample. And the
00133     // same length as the container over which the list sample is instantiated,
00134     // if fixed.
00135     MeasurementVectorTraits::Assert(m_HistogramMin, MeasurementVectorSize, 
00136         "Length Mismatch: ListSampleToHistogramGenerator::SetHistogramMin");
00137     if( m_List )
00138       {
00139       if( m_List->GetMeasurementVectorSize() != MeasurementVectorSize )
00140         {
00141         itkExceptionMacro( << "Length Mismatch: ListSampleToHistogramGenerator::SetHistogramMin" );
00142         }
00143       }
00144     }
00145 
00146   void SetHistogramMax(const MeasurementVectorType & histogramMax)
00147     {
00148     m_HistogramMax = histogramMax;
00149     m_AutoMinMax = false;
00150     
00151     // Sanity check.. Check to see that container m_HistogramMax has the same
00152     // length as the length of measurement vectors in the list sample. And the
00153     // same length as the container over which the list sample is instantiated,
00154     // if fixed.
00155     MeasurementVectorTraits::Assert(m_HistogramMax, MeasurementVectorSize, 
00156         "Length Mismatch: ListSampleToHistogramGenerator::SetHistogramMin");
00157     if( m_List )
00158       {
00159       if( m_List->GetMeasurementVectorSize() != MeasurementVectorSize )
00160         {
00161         itkExceptionMacro( << "Length Mismatch: ListSampleToHistogramGenerator::SetHistogramMin" );
00162         }
00163       }
00164     }
00165 
00166 
00167 protected:
00168   ListSampleToHistogramGenerator() ;
00169   virtual ~ListSampleToHistogramGenerator() {}
00170   void GenerateData() ;
00171   void PrintSelf(std::ostream& os, Indent indent) const;
00172 
00173 private:
00174   const TListSample* m_List ;
00175   typename HistogramType::Pointer m_Histogram ;
00176   HistogramSizeType m_Sizes ;
00177   float m_MarginalScale ;
00178   MeasurementVectorType m_HistogramMin;
00179   MeasurementVectorType m_HistogramMax;
00180   bool m_AutoMinMax;
00181 
00182 } ; // end of class
00183 
00184 } // end of namespace Statistics 
00185 } // end of namespace itk 
00186 
00187 #ifndef ITK_MANUAL_INSTANTIATION
00188 #include "itkListSampleToHistogramGenerator.txx"
00189 #endif
00190 
00191 #endif

Generated at Wed May 24 23:37:01 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000