Medical Imaging Interaction Toolkit  2024.06.00
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 
73  { m_BoundsCondition = i; }
74 
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
itk::NeighborhoodFunctorImageFilter::~NeighborhoodFunctorImageFilter
~NeighborhoodFunctorImageFilter() override
Definition: itkNeighborhoodFunctorImageFilter.h:110
itk::NeighborhoodFunctorImageFilter::FeaturePixelType
FeatureImageType::PixelType FeaturePixelType
Definition: itkNeighborhoodFunctorImageFilter.h:53
itk::NeighborhoodFunctorImageFilter::InputImagePixelType
TInputImageType::PixelType InputImagePixelType
Definition: itkNeighborhoodFunctorImageFilter.h:49
itk::NeighborhoodFunctorImageFilter::NeighborhoodFunctorImageFilter
NeighborhoodFunctorImageFilter()
Definition: itkNeighborhoodFunctorImageFilter.h:102
itk::NeighborhoodFunctorImageFilter::ImageBoundaryConditionPointerType
ImageBoundaryCondition< InputImageType > * ImageBoundaryConditionPointerType
Definition: itkNeighborhoodFunctorImageFilter.h:57
itk::NeighborhoodFunctorImageFilter::InputImageType
TInputImageType InputImageType
Definition: itkNeighborhoodFunctorImageFilter.h:48
itk::NeighborhoodFunctorImageFilter::FeatureImageType
TFeatureImageType FeatureImageType
Definition: itkNeighborhoodFunctorImageFilter.h:52
itk::NeighborhoodFunctorImageFilter::DefaultBoundaryCondition
ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition
Definition: itkNeighborhoodFunctorImageFilter.h:60
itk::NeighborhoodFunctorImageFilter::SetNeighborhoodSize
void SetNeighborhoodSize(SizeType size)
Definition: itkNeighborhoodFunctorImageFilter.h:79
itk::SmartPointer< Self >
itk::NeighborhoodFunctorImageFilter::GetBoundaryCondition
ImageBoundaryConditionPointerType GetBoundaryCondition()
Definition: itkNeighborhoodFunctorImageFilter.h:76
itk::NeighborhoodFunctorImageFilter::Pointer
SmartPointer< Self > Pointer
Definition: itkNeighborhoodFunctorImageFilter.h:34
itk::NeighborhoodFunctorImageFilter::itkStaticConstMacro
itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImageType::ImageDimension)
itk::NeighborhoodFunctorImageFilter::Superclass
ImageToImageFilter< TInputImageType, TFeatureImageType > Superclass
Definition: itkNeighborhoodFunctorImageFilter.h:33
itk::NeighborhoodFunctorImageFilter::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkNeighborhoodFunctorImageFilter.h:35
itk::NeighborhoodFunctorImageFilter::GenerateInputRequestedRegion
void GenerateInputRequestedRegion() override
itk::NeighborhoodFunctorImageFilter::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
itk::NeighborhoodFunctorImageFilter::SizeType
itk::Size< InputImageDimension > SizeType
Definition: itkNeighborhoodFunctorImageFilter.h:54
itk::NeighborhoodFunctorImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
itk::NeighborhoodFunctorImageFilter::GetNeighborhoodSize
SizeType GetNeighborhoodSize()
Definition: itkNeighborhoodFunctorImageFilter.h:81
itk::NeighborhoodFunctorImageFilter::SetNeighborhoodSize
void SetNeighborhoodSize(unsigned int size)
Definition: itkNeighborhoodFunctorImageFilter.h:80
itk::NeighborhoodFunctorImageFilter::MaskImageType
itk::Image< short, InputImageDimension > MaskImageType
Definition: itkNeighborhoodFunctorImageFilter.h:50
itk::NeighborhoodFunctorImageFilter::GetFunctorReference
FunctorType & GetFunctorReference()
Definition: itkNeighborhoodFunctorImageFilter.h:90
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
itk::NeighborhoodFunctorImageFilter::NeighborhoodType
Neighborhood< InputImagePixelType, InputImageDimension > NeighborhoodType
Definition: itkNeighborhoodFunctorImageFilter.h:65
itk::NeighborhoodFunctorImageFilter::OutputImageRegionType
Superclass::OutputImageRegionType OutputImageRegionType
Definition: itkNeighborhoodFunctorImageFilter.h:63
itk::NeighborhoodFunctorImageFilter
Definition: itkNeighborhoodFunctorImageFilter.h:29
itk::NeighborhoodFunctorImageFilter::OverrideBoundaryCondition
void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
Definition: itkNeighborhoodFunctorImageFilter.h:72
itk::NeighborhoodFunctorImageFilter::Self
NeighborhoodFunctorImageFilter Self
Definition: itkNeighborhoodFunctorImageFilter.h:32
itk::NeighborhoodFunctorImageFilter::SetMask
void SetMask(const typename MaskImageType::Pointer &ptr)
Definition: itkNeighborhoodFunctorImageFilter.h:83
itk::NeighborhoodFunctorImageFilter::MaskImagePixelType
MaskImageType::PixelType MaskImagePixelType
Definition: itkNeighborhoodFunctorImageFilter.h:51
itk::NeighborhoodFunctorImageFilter::SetFunctor
void SetFunctor(const FunctorType &func)
Definition: itkNeighborhoodFunctorImageFilter.h:95
itk::NeighborhoodFunctorImageFilter::GetFunctorReference
const FunctorType & GetFunctorReference() const
Definition: itkNeighborhoodFunctorImageFilter.h:85