ITK  5.2.0
Insight Toolkit
itkUnaryGeneratorImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkUnaryGeneratorImageFilter_h
19 #define itkUnaryGeneratorImageFilter_h
20 
21 #include "itkMath.h"
22 #include "itkInPlaceImageFilter.h"
24 
25 #include <functional>
26 
27 namespace itk
28 {
29 
54 template <typename TInputImage, typename TOutputImage>
55 class UnaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(UnaryGeneratorImageFilter);
59 
65 
67  itkNewMacro(Self);
68 
71 
72  using InputImageType = TInputImage;
73  using InputImagePointer = typename InputImageType::ConstPointer;
75  using InputImagePixelType = typename InputImageType::PixelType;
76 
77  using OutputImageType = TOutputImage;
78  using OutputImagePointer = typename OutputImageType::Pointer;
80  using OutputImagePixelType = typename OutputImageType::PixelType;
81 
84 
85 
86 #if !defined(ITK_WRAPPING_PARSER)
87 
91  void
92  SetFunctor(const std::function<ConstRefFunctionType> & f)
93  {
94  m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
95  return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
96  };
98 
99  this->Modified();
100  }
101  void
102  SetFunctor(const std::function<ValueFunctionType> & f)
103  {
104  m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
105  return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
106  };
107 
108  this->Modified();
109  }
110 
111 
116  void
118  {
119  m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
120  return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
121  };
123 
124  this->Modified();
125  }
126  void
128  {
129  m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
130  return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
131  };
132 
133  this->Modified();
134  }
135 
136 
144  template <typename TFunctor>
145  void
146  SetFunctor(const TFunctor & functor)
147  {
148  m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread) {
149  return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
150  };
152 
153  this->Modified();
154  }
155 #endif // !defined( ITK_WRAPPING_PARSER )
156 
157 protected:
159  ~UnaryGeneratorImageFilter() override = default;
160 
169  void
170  GenerateOutputInformation() override;
171 
172 
182  template <typename TFunctor>
183  void
184  DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
185  void
186  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
188 
189 private:
191 };
192 } // end namespace itk
193 
194 #ifndef ITK_MANUAL_INSTANTIATION
195 # include "itkUnaryGeneratorImageFilter.hxx"
196 #endif
197 
198 #endif
itk::UnaryGeneratorImageFilter::m_DynamicThreadedGenerateDataFunction
std::function< void(const OutputImageRegionType &)> m_DynamicThreadedGenerateDataFunction
Definition: itkUnaryGeneratorImageFilter.h:190
itk::UnaryGeneratorImageFilter::SetFunctor
void SetFunctor(ConstRefFunctionType *funcPointer)
Definition: itkUnaryGeneratorImageFilter.h:117
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::UnaryGeneratorImageFilter::GenerateOutputInformation
void GenerateOutputInformation() override
itk::UnaryGeneratorImageFilter::ConstRefFunctionType
OutputImagePixelType(const InputImagePixelType &) ConstRefFunctionType
Definition: itkUnaryGeneratorImageFilter.h:82
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::UnaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkUnaryGeneratorImageFilter.h:92
itk::UnaryGeneratorImageFilter
Implements pixel-wise generic "operation" on one image.
Definition: itkUnaryGeneratorImageFilter.h:55
itk::SmartPointer< Self >
itk::UnaryGeneratorImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkUnaryGeneratorImageFilter.h:79
itkImageRegionIteratorWithIndex.h
itk::UnaryGeneratorImageFilter::DynamicThreadedGenerateDataWithFunctor
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType &outputRegionForThread)
itk::UnaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ValueFunctionType > &f)
Definition: itkUnaryGeneratorImageFilter.h:102
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::UnaryGeneratorImageFilter::ValueFunctionType
OutputImagePixelType(InputImagePixelType) ValueFunctionType
Definition: itkUnaryGeneratorImageFilter.h:83
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::UnaryGeneratorImageFilter::UnaryGeneratorImageFilter
UnaryGeneratorImageFilter()
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::UnaryGeneratorImageFilter::SetFunctor
void SetFunctor(ValueFunctionType *funcPointer)
Definition: itkUnaryGeneratorImageFilter.h:127
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::UnaryGeneratorImageFilter::SetFunctor
void SetFunctor(const TFunctor &functor)
Definition: itkUnaryGeneratorImageFilter.h:146
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::UnaryGeneratorImageFilter::~UnaryGeneratorImageFilter
~UnaryGeneratorImageFilter() override=default
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::UnaryGeneratorImageFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
itkInPlaceImageFilter.h
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::UnaryGeneratorImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkUnaryGeneratorImageFilter.h:80
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::Object::Modified
virtual void Modified() const
itkMath.h
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90