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

itkBinaryProjectionImageFilter.h

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

Generated at Fri Apr 16 17:53:39 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000