Slicer 4.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
itkOtsuStatistics.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOtsuStatistics.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008/02/7 14:28:51 $
00007   Version:   $Revision: 0.0 $
00008 =========================================================================*/
00009 #ifndef __itkOtsuStatistics_h
00010 #define __itkOtsuStatistics_h
00011 
00012 #include "itkImageToImageFilter.h"
00013 #include "itkImage.h"
00014 
00015 namespace itk
00016 {
00021 template <class TInputImage, class TOutputImage>
00022 class ITK_EXPORT OtsuStatistics : public ImageToImageFilter<TInputImage, TOutputImage>
00023 {
00024 public:
00026   typedef TInputImage                            InputImageType;
00027   typedef typename InputImageType::Pointer       InputImagePointer;
00028   typedef typename InputImageType::ConstPointer  InputImageConstPointer;
00029   typedef TOutputImage                           OutputImageType;
00030   typedef typename OutputImageType::Pointer      OutputImagePointer;
00031   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
00032 
00034   typedef OtsuStatistics                                      Self;
00035   typedef ImageToImageFilter<InputImageType, OutputImageType> Superclass;
00036   typedef SmartPointer<Self>                                  Pointer;
00037   typedef SmartPointer<const Self>                            ConstPointer;
00038 
00040   itkNewMacro(Self);
00041 
00043   itkTypeMacro( OtsuStatistics, ImageToImageFilter );
00044 
00046   typedef typename InputImageType::PixelType  InputPixelType;
00047   typedef typename OutputImageType::PixelType OutputPixelType;
00048 
00049   typedef typename InputImageType::RegionType  InputImageRegionType;
00050   typedef typename OutputImageType::RegionType OutputImageRegionType;
00051 
00052   typedef typename InputImageType::SizeType InputSizeType;
00053 
00054   typedef itk::Array<unsigned int> IndicatorType;
00055 
00057   itkSetMacro( Radius, InputSizeType );
00058   itkGetConstReferenceMacro( Radius, InputSizeType );
00059   void SetRadius( unsigned int rad )
00060   {
00061     m_Radius.Fill( rad );
00062   }
00063 
00065   itkSetMacro( Channels, unsigned int );
00066   itkGetConstReferenceMacro( Channels, unsigned int );
00067   typedef enum OperationMode { USE_AVERAGED_BASELINES, USE_AVERAGED_GRADIENTS, USE_NEIGHBORHOOD_BASELINES,
00068                                USE_NEIGHBORHOOD_GRADIENTS } OperationMode;
00069   void SetUseAveragedBaselines(void)
00070   {
00071     m_Mode = USE_AVERAGED_BASELINES;
00072   }
00073   void SetUseAveragedGradients(void)
00074   {
00075     m_Mode = USE_AVERAGED_GRADIENTS;
00076   }
00077   void SetUseNeighborhoodBaselines(void)
00078   {
00079     m_Mode = USE_NEIGHBORHOOD_BASELINES;
00080   }
00081   void SetUseNeighborhoodGradients(void)
00082   {
00083     m_Mode = USE_NEIGHBORHOOD_GRADIENTS;
00084   }
00085 
00086   itkGetMacro( Min, double );
00087   itkGetMacro( Max, double );
00088   itkSetMacro( Indicator, IndicatorType );
00089   itkGetMacro( Indicator, IndicatorType );
00090 protected:
00091   OtsuStatistics();
00092   virtual ~OtsuStatistics()
00093   {
00094   }
00095   void PrintSelf(std::ostream& os, Indent indent) const;
00096 
00097   // Threaded filter!
00098   void BeforeThreadedGenerateData( void );
00099 
00100 #if ITK_VERSION_MAJOR < 4
00101   void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, int threadId );
00102 
00103 #else
00104   void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId );
00105 
00106 #endif
00107   void AfterThreadedGenerateData( void );
00108 
00109   virtual void GenerateInputRequestedRegion()
00110   throw (InvalidRequestedRegionError);
00111 
00112 private:
00113   OtsuStatistics(const Self &);  // purposely not implemented
00114   void operator=(const Self &);  // purposely not implemented
00115 
00116   // The size of the nieghbourhood to compute the statistics:
00117   InputSizeType m_Radius;
00118   // The number of DWI-channels to filter; we externaly set this parameter in
00119   // order to achieve a more general functionality with different vector types
00120   // than the one for VectorImage class:
00121   unsigned int m_Channels;
00122   // Min and max values to compute:
00123   double m_Min;
00124   double m_Max;
00125   // The mode of ooperation:
00126   OperationMode m_Mode;
00127   // Per thread max and min values:
00128   itk::Array<double> m_ThreadMin;
00129   itk::Array<double> m_ThreadMax;
00130   // The indicator to compute the baselines:
00131   IndicatorType m_Indicator;
00132 };
00133 
00134 } // end namespace itk
00135 
00136 #ifndef ITK_MANUAL_INSTANTIATION
00137 #include "itkOtsuStatistics.txx"
00138 #endif
00139 
00140 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines