ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkBinaryGeneratorImageFilter.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 * https://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 itkBinaryGeneratorImageFilter_h
19#define itkBinaryGeneratorImageFilter_h
20
23
24
25#include <functional>
26
27namespace itk
28{
55template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
56class ITK_TEMPLATE_EXPORT BinaryGeneratorImageFilter : public InPlaceImageFilter<TInputImage1, TOutputImage>
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(BinaryGeneratorImageFilter);
60
66
68 itkNewMacro(Self);
69
71 itkOverrideGetNameOfClassMacro(BinaryGeneratorImageFilter);
72
74 using Input1ImageType = TInputImage1;
75 using Input1ImagePointer = typename Input1ImageType::ConstPointer;
76 using Input1ImageRegionType = typename Input1ImageType::RegionType;
77 using Input1ImagePixelType = typename Input1ImageType::PixelType;
79
80 using Input2ImageType = TInputImage2;
81 using Input2ImagePointer = typename Input2ImageType::ConstPointer;
82 using Input2ImageRegionType = typename Input2ImageType::RegionType;
83 using Input2ImagePixelType = typename Input2ImageType::PixelType;
85
86 using OutputImageType = TOutputImage;
87 using OutputImagePointer = typename OutputImageType::Pointer;
88 using OutputImageRegionType = typename OutputImageType::RegionType;
89 using OutputImagePixelType = typename OutputImageType::PixelType;
90
92
95
97 virtual void
98 SetInput1(const TInputImage1 * image1);
99 virtual void
101 virtual void
104
106 virtual void
108
111 virtual const Input1ImagePixelType &
113
115 virtual void
116 SetInput2(const TInputImage2 * image2);
117 virtual void
119 virtual void
122
123
125 virtual void
127 void
129 {
130 this->SetConstant2(ct);
131 }
132 const Input2ImagePixelType &
134 {
135 return this->GetConstant2();
136 }
137
138
141 virtual const Input2ImagePixelType &
143
144#if !defined(ITK_WRAPPING_PARSER)
149 void
150 SetFunctor(const std::function<ConstRefFunctionType> & f)
151 {
152 // the closure creates a copy of f
153 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
154 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
155 };
157
158 this->Modified();
159 }
160 void
161 SetFunctor(const std::function<ValueFunctionType> & f)
162 {
163 // the capture creates a copy of f
164 m_DynamicThreadedGenerateDataFunction = [this, f](const OutputImageRegionType & outputRegionForThread) {
165 return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
166 };
167
168 this->Modified();
169 }
170
175 void
177 {
178 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
179 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
180 };
182
183 this->Modified();
184 }
185 void
187 {
188 m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const OutputImageRegionType & outputRegionForThread) {
189 return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
190 };
191
192 this->Modified();
193 }
194
195
204 template <typename TFunctor>
205 void
206 SetFunctor(const TFunctor & functor)
207 {
208 // the capture creates a copy of the functor
209 m_DynamicThreadedGenerateDataFunction = [this, functor](const OutputImageRegionType & outputRegionForThread) {
210 return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
211 };
213
214 this->Modified();
215 }
216#endif // !defined( ITK_WRAPPING_PARSER )
217
218
220 static constexpr unsigned int InputImage1Dimension = TInputImage1::ImageDimension;
221 static constexpr unsigned int InputImage2Dimension = TInputImage2::ImageDimension;
222 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
223
224 itkConceptMacro(SameDimensionCheck1,
226 itkConceptMacro(SameDimensionCheck2,
228
229protected:
231 ~BinaryGeneratorImageFilter() override = default;
232
242 template <typename TFunctor>
243 void
244 DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType & outputRegionForThread);
245 void
246 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
247 void
249 {
250 this->UpdateProgress(1.0);
251 }
252
253
254 // Needed to take the image information from the 2nd input, if the first one is
255 // a simple decorated object.
256 void
258
259private:
261};
262} // end namespace itk
263
264#ifndef ITK_MANUAL_INSTANTIATION
265# include "itkBinaryGeneratorImageFilter.hxx"
266#endif
267
268#endif
typename Input2ImageType::PixelType Input2ImagePixelType
OutputImagePixelType(Input1ImagePixelType, Input2ImagePixelType) ValueFunctionType
virtual void SetInput1(const DecoratedInput1ImagePixelType *input1)
typename Input1ImageType::ConstPointer Input1ImagePointer
OutputImagePixelType(*)(const Input1ImagePixelType &, const Input2ImagePixelType &) FunctionType
SimpleDataObjectDecorator< Input2ImagePixelType > DecoratedInput2ImagePixelType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const OutputImageRegionType &outputRegionForThread)
typename Input2ImageType::ConstPointer Input2ImagePointer
typename OutputImageType::PixelType OutputImagePixelType
virtual void SetInput2(const DecoratedInput2ImagePixelType *input2)
virtual void SetConstant1(const Input1ImagePixelType &input1)
virtual void SetInput2(const TInputImage2 *image2)
~BinaryGeneratorImageFilter() override=default
virtual void SetConstant2(const Input2ImagePixelType &input2)
virtual void SetInput1(const Input1ImagePixelType &input1)
typename Input1ImageType::RegionType Input1ImageRegionType
virtual const Input1ImagePixelType & GetConstant1() const
void SetFunctor(ValueFunctionType *funcPointer)
void SetFunctor(const std::function< ValueFunctionType > &f)
void GenerateOutputInformation() override
InPlaceImageFilter< TInputImage1, TOutputImage > Superclass
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::Pointer OutputImagePointer
SimpleDataObjectDecorator< Input1ImagePixelType > DecoratedInput1ImagePixelType
OutputImagePixelType(const Input1ImagePixelType &, const Input2ImagePixelType &) ConstRefFunctionType
virtual void SetInput2(const Input2ImagePixelType &input2)
typename Input1ImageType::PixelType Input1ImagePixelType
typename Input2ImageType::RegionType Input2ImageRegionType
void SetFunctor(const std::function< ConstRefFunctionType > &f)
virtual void SetInput1(const TInputImage1 *image1)
const Input2ImagePixelType & GetConstant() const
void SetFunctor(ConstRefFunctionType *funcPointer)
virtual void Modified() const
void UpdateProgress(float progress)
Update the progress of the process object.
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....