Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
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&);
00206 void operator=(const Self&);
00207
00208 };
00209
00210 }
00211
00212 #endif
00213