Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkNeighborhoodFunctorImageFilter.h
Go to the documentation of this file.
1 #ifndef itkNeighborhoodFunctorImageFilter_h
2 #define itkNeighborhoodFunctorImageFilter_h
3 
4 #include "itkImageToImageFilter.h"
5 #include "itkZeroFluxNeumannBoundaryCondition.h"
6 #include "itkConstNeighborhoodIterator.h"
7 #include "itkImage.h"
8 #include "stdio.h"
9 
10 #include <itkHistogramToTextureFeaturesFilter.h>
11 #include "itkHistogram.h"
12 
13 namespace itk
14 {
15 
16 template<typename TInputImageType, typename TFeatureImageType , class FunctorType>
17 class NeighborhoodFunctorImageFilter : public ImageToImageFilter< TInputImageType, TFeatureImageType>
18 {
19 public:
21  typedef ImageToImageFilter<TInputImageType, TFeatureImageType> Superclass;
24 
25  itkNewMacro(Self);
26 
27  itkTypeMacro(NeighborhoodFunctorImageFilter, ImageToImageFilter);
28 
31  itkStaticConstMacro(ImageDimension, unsigned int,
32  TFeatureImageType::ImageDimension);
33  itkStaticConstMacro(InputImageDimension, unsigned int,
34  TInputImageType::ImageDimension);
35 
36  typedef TInputImageType InputImageType;
38  typedef itk::Image<short, InputImageDimension> MaskImageType;
40  typedef TFeatureImageType FeatureImageType;
42  typedef itk::Size<InputImageDimension> SizeType;
43 
45  typedef ImageBoundaryCondition< InputImageType > * ImageBoundaryConditionPointerType;
46 
48  typedef ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition;
49 
51  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
52 
53  typedef Neighborhood< InputImagePixelType, InputImageDimension > NeighborhoodType;
54 
60  void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
61  { m_BoundsCondition = i; }
62 
64  ImageBoundaryConditionPointerType GetBoundaryCondition()
65  { return m_BoundsCondition; }
66 
67  void SetNeighborhoodSize(SizeType size){m_Size = size;}
68  void SetNeighborhoodSize(unsigned int size){m_Size.Fill(size);}
69  SizeType GetNeighborhoodSize(){return m_Size;}
70 
71  void SetMask(const typename MaskImageType::Pointer & ptr){m_MaskImage = ptr;}
72 
73  const FunctorType & GetFunctorReference() const
74  {
75  return m_Functor;
76  }
77 
78  FunctorType & GetFunctorReference()
79  {
80  return m_Functor;
81  }
82 
83  void SetFunctor(const FunctorType & func)
84  {
85  m_Functor = func;
86  }
87 
88 protected:
89 
91  {
92  m_Size.Fill(0);
93  m_MaskImage = NULL;
94  m_BoundsCondition = static_cast< ImageBoundaryConditionPointerType >( &m_DefaultBoundaryCondition );
95  this->SetNumberOfIndexedOutputs(FunctorType::OutputCount);
96  }
98 
100 
101  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
102  ThreadIdType threadId);
103 
104 
112  virtual void GenerateInputRequestedRegion() throw ( InvalidRequestedRegionError );
113 
114 
115 private:
116  NeighborhoodFunctorImageFilter(const Self &); // purposely not implemented
117  void operator=(const Self &); // purposely not implemented
118 
121  ImageBoundaryConditionPointerType m_BoundsCondition;
122 
124  DefaultBoundaryCondition m_DefaultBoundaryCondition;
125 
127  FunctorType m_Functor;
128 
129  itk::Size<InputImageDimension> m_Size;
130 
131  typename MaskImageType::Pointer m_MaskImage;
132 
133 };
134 }
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "../src/Features/itkNeighborhoodFunctorImageFilter.cpp"
138 #endif
139 
140 #endif // itkFeatureImageFilter_h
Neighborhood< InputImagePixelType, InputImageDimension > NeighborhoodType
itk::SmartPointer< Self > Pointer
void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
itk::Image< short, InputImageDimension > MaskImageType
itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImageType::ImageDimension)
ImageBoundaryConditionPointerType GetBoundaryCondition()
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
Superclass::OutputImageRegionType OutputImageRegionType
ImageToImageFilter< TInputImageType, TFeatureImageType > Superclass
ImageBoundaryCondition< InputImageType > * ImageBoundaryConditionPointerType
ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition
unsigned short PixelType
void SetMask(const typename MaskImageType::Pointer &ptr)