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

itkBinaryThresholdProjectionImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryThresholdProjectionImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-28 18:14:36 $
00007   Version:   $Revision: 1.3 $
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 __itkBinaryThresholdProjectionImageFilter_h
00018 #define __itkBinaryThresholdProjectionImageFilter_h
00019 
00020 #include "itkProjectionImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 #include "itkConceptChecking.h"
00023 
00024 namespace itk {
00049 namespace Function {
00050 template <class TInputPixel, class TOutputPixel>
00051 class BinaryThresholdAccumulator
00052 {
00053 public:
00054   BinaryThresholdAccumulator( unsigned long ) {}
00055   ~BinaryThresholdAccumulator(){}
00056 
00057   inline void Initialize()
00058     {
00059     m_IsForeground = false;
00060     }
00061 
00062   inline void operator()( const TInputPixel &input )
00063     {
00064     if( input >= m_ThresholdValue )
00065       {
00066       m_IsForeground = true; 
00067       }
00068     }
00069 
00070   inline TOutputPixel GetValue()
00071     {
00072     if( m_IsForeground )
00073       {
00074       return (TOutputPixel)m_ForegroundValue; 
00075       }
00076     else
00077       {
00078       return m_BackgroundValue; 
00079       }
00080     }
00081 
00082   bool m_IsForeground;
00083 
00084   TInputPixel                 m_ThresholdValue;
00085   TInputPixel                 m_ForegroundValue;
00086   TOutputPixel                m_BackgroundValue;
00087 };
00088 } // end namespace Function
00089 
00090 
00091 template <class TInputImage, class TOutputImage>
00092 class ITK_EXPORT BinaryThresholdProjectionImageFilter :
00093     public ProjectionImageFilter<TInputImage, TOutputImage, 
00094       Function::BinaryThresholdAccumulator< 
00095         typename TInputImage::PixelType, 
00096         typename TOutputImage::PixelType > >
00097 {
00098 public:
00099   typedef BinaryThresholdProjectionImageFilter Self;
00100   typedef ProjectionImageFilter<TInputImage, TOutputImage, 
00101     Function::BinaryThresholdAccumulator< 
00102       typename TInputImage::PixelType, 
00103       typename TOutputImage::PixelType > > Superclass;
00104 
00105   typedef SmartPointer<Self>        Pointer;
00106   typedef SmartPointer<const Self>  ConstPointer;
00107 
00109   itkTypeMacro(BinaryThresholdProjectionImageFilter, ProjectionImageFilter);
00110 
00112   itkNewMacro(Self);
00113 
00115   typedef TInputImage           InputImageType;
00116   typedef TOutputImage          OutputImageType;
00117 
00119   typedef typename InputImageType::PixelType  InputPixelType;
00120   typedef typename OutputImageType::PixelType OutputPixelType;
00121 
00122   typedef typename Superclass::AccumulatorType AccumulatorType;
00123 
00126   itkSetMacro(ForegroundValue, InputPixelType);
00127   itkGetConstMacro(ForegroundValue, InputPixelType);
00129 
00132   itkSetMacro(BackgroundValue, OutputPixelType);
00133   itkGetConstMacro(BackgroundValue, OutputPixelType);
00135 
00138   itkSetMacro(ThresholdValue, InputPixelType);
00139   itkGetConstMacro(ThresholdValue, InputPixelType);
00141 
00142 #ifdef ITK_USE_CONCEPT_CHECKING
00143 
00144   itkConceptMacro(InputPixelTypeGreaterThanComparable,
00145     (Concept::GreaterThanComparable<InputPixelType>));
00146   itkConceptMacro(InputHasNumericTraitsCheck,
00147     (Concept::HasNumericTraits<InputPixelType>));
00148 
00150 #endif
00151 
00152 
00153 protected:
00154   BinaryThresholdProjectionImageFilter()
00155     {
00156     m_ForegroundValue = NumericTraits<InputPixelType>::max();
00157     m_BackgroundValue = NumericTraits<OutputPixelType>::NonpositiveMin();
00158     m_ThresholdValue = NumericTraits<InputPixelType>::Zero;
00159     }
00160   virtual ~BinaryThresholdProjectionImageFilter() {}
00161 
00162   void PrintSelf(std::ostream& os, Indent indent) const
00163     {
00164     Superclass::PrintSelf(os,indent);
00165 
00166     typedef typename NumericTraits<InputPixelType>::PrintType
00167                                               InputPixelPrintType;
00168 
00169     os << indent << "ForegroundValue: " 
00170                     << static_cast< InputPixelPrintType > (m_ForegroundValue) 
00171                     << std::endl;
00172  
00173     typedef typename NumericTraits<OutputPixelType>::PrintType
00174                                               OutputPixelPrintType;
00175 
00176     os << indent << "BackgroundValue: " 
00177                     << static_cast< OutputPixelPrintType > (m_BackgroundValue) 
00178                     << std::endl;
00179 
00180     os << indent << "ThresholdValue: " 
00181                     << static_cast< InputPixelPrintType > (m_ThresholdValue) 
00182                     << std::endl;
00183     }
00184 
00185 
00186   virtual AccumulatorType NewAccumulator( unsigned long size ) const
00187     {
00188     AccumulatorType accumulator( size );
00189     accumulator.m_ForegroundValue = m_ForegroundValue;
00190     accumulator.m_BackgroundValue = m_BackgroundValue;
00191     accumulator.m_ThresholdValue = m_ThresholdValue;
00192     return accumulator;
00193     }
00194 
00196   InputPixelType m_ForegroundValue;
00197 
00199   OutputPixelType m_BackgroundValue;
00200 
00202   OutputPixelType m_ThresholdValue;
00203 
00204 private:
00205   BinaryThresholdProjectionImageFilter(const Self&); //purposely not implemented
00206   void operator=(const Self&); //purposely not implemented
00207 
00208 }; // end BinaryThresholdProjectionImageFilter
00209 
00210 } //end namespace itk
00211 
00212 #endif
00213 

Generated at Mon Jul 12 2010 17:53:30 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000