Medical Imaging Interaction Toolkit  2022.04.99-b878213f
Medical Imaging Interaction Toolkit
itkNeighborhoodFunctorImageFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef itkNeighborhoodFunctorImageFilter_h
14 #define itkNeighborhoodFunctorImageFilter_h
15 
16 #include "itkImageToImageFilter.h"
17 #include "itkZeroFluxNeumannBoundaryCondition.h"
18 #include "itkConstNeighborhoodIterator.h"
19 #include "itkImage.h"
20 #include <cstdio>
21 
22 #include <itkHistogramToTextureFeaturesFilter.h>
23 #include "itkHistogram.h"
24 
25 namespace itk
26 {
27 
28 template<typename TInputImageType, typename TFeatureImageType , class FunctorType>
29 class NeighborhoodFunctorImageFilter : public ImageToImageFilter< TInputImageType, TFeatureImageType>
30 {
31 public:
33  typedef ImageToImageFilter<TInputImageType, TFeatureImageType> Superclass;
36 
37  itkNewMacro(Self);
38 
39  itkTypeMacro(NeighborhoodFunctorImageFilter, ImageToImageFilter);
40 
43  itkStaticConstMacro(ImageDimension, unsigned int,
44  TFeatureImageType::ImageDimension);
45  itkStaticConstMacro(InputImageDimension, unsigned int,
46  TInputImageType::ImageDimension);
47 
48  typedef TInputImageType InputImageType;
49  typedef typename TInputImageType::PixelType InputImagePixelType;
50  typedef itk::Image<short, InputImageDimension> MaskImageType;
51  typedef typename MaskImageType::PixelType MaskImagePixelType;
52  typedef TFeatureImageType FeatureImageType;
53  typedef typename FeatureImageType::PixelType FeaturePixelType;
54  typedef itk::Size<InputImageDimension> SizeType;
55 
57  typedef ImageBoundaryCondition< InputImageType > * ImageBoundaryConditionPointerType;
58 
60  typedef ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition;
61 
63  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
64 
65  typedef Neighborhood< InputImagePixelType, InputImageDimension > NeighborhoodType;
66 
72  void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
73  { m_BoundsCondition = i; }
74 
76  ImageBoundaryConditionPointerType GetBoundaryCondition()
77  { return m_BoundsCondition; }
78 
79  void SetNeighborhoodSize(SizeType size){m_Size = size;}
80  void SetNeighborhoodSize(unsigned int size){m_Size.Fill(size);}
81  SizeType GetNeighborhoodSize(){return m_Size;}
82 
83  void SetMask(const typename MaskImageType::Pointer & ptr){m_MaskImage = ptr;}
84 
85  const FunctorType & GetFunctorReference() const
86  {
87  return m_Functor;
88  }
89 
90  FunctorType & GetFunctorReference()
91  {
92  return m_Functor;
93  }
94 
95  void SetFunctor(const FunctorType & func)
96  {
97  m_Functor = func;
98  }
99 
100 protected:
101 
103  {
104  this->DynamicMultiThreadingOff();
105  m_Size.Fill(0);
106  m_MaskImage = nullptr;
107  m_BoundsCondition = static_cast< ImageBoundaryConditionPointerType >( &m_DefaultBoundaryCondition );
108  this->SetNumberOfIndexedOutputs(FunctorType::OutputCount);
109  }
111 
112  void BeforeThreadedGenerateData() override;
113 
114  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
115  ThreadIdType threadId) override;
116 
117 
125  void GenerateInputRequestedRegion() override;
126 
127 
128 private:
129  NeighborhoodFunctorImageFilter(const Self &); // purposely not implemented
130  void operator=(const Self &); // purposely not implemented
131 
134  ImageBoundaryConditionPointerType m_BoundsCondition;
135 
137  DefaultBoundaryCondition m_DefaultBoundaryCondition;
138 
140  FunctorType m_Functor;
141 
142  itk::Size<InputImageDimension> m_Size;
143 
144  typename MaskImageType::Pointer m_MaskImage;
145 
146 };
147 }
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "../src/Features/itkNeighborhoodFunctorImageFilter.cpp"
151 #endif
152 
153 #endif // itkFeatureImageFilter_h
Neighborhood< InputImagePixelType, InputImageDimension > NeighborhoodType
void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
itk::Image< short, InputImageDimension > MaskImageType
itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImageType::ImageDimension)
ImageBoundaryConditionPointerType GetBoundaryCondition()
Superclass::OutputImageRegionType OutputImageRegionType
void GenerateInputRequestedRegion() override
ImageToImageFilter< TInputImageType, TFeatureImageType > Superclass
ImageBoundaryCondition< InputImageType > * ImageBoundaryConditionPointerType
ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
void BeforeThreadedGenerateData() override
void SetMask(const typename MaskImageType::Pointer &ptr)