ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkUnaryFunctorWithIndexImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 //
19 // Created by Jean-Marie Mirebeau on 07/03/2014.
20 //
21 //
22 
23 #ifndef itkUnaryFunctorWithIndexImageFilter_h
24 #define itkUnaryFunctorWithIndexImageFilter_h
25 
29 #include "itkImageToImageFilter.h"
30 
31 namespace itk
32 {
33 
40 template<typename TInputImage, typename TOutputImage, typename TFunctor>
42  public ImageToImageFilter<TInputImage, TOutputImage>
43 {
44 public:
49 
51  itkNewMacro(Self);
52 
55 
56  using InputImageType = TInputImage;
57  using OutputImageType = TOutputImage;
58  using FunctorType = TFunctor;
59 
61 
62 protected:
64  { this->DynamicMultiThreadingOn(); }
65 
67 
70 
71  void DynamicThreadedGenerateData(const OutputRegionType & region) override
72  {
73  if( region.GetSize()[0] == 0 )
74  {
75  return;
76  }
77 
79  ImageScanlineIterator< OutputImageType > outputIt( this->GetOutput(), region);
80 
81  for( inputIt.GoToBegin(), outputIt.GoToBegin();
82  !outputIt.IsAtEnd();
83  )
84  {
85  while(!outputIt.IsAtEndOfLine())
86  {
87  outputIt.Set(m_Functor(inputIt.Value(), inputIt.GetIndex()));
88  ++inputIt;
89  ++outputIt;
90  }
91  outputIt.NextLine();
92  }
93  }
94 };
95 
96 } // end namespace itk
97 
98 #endif
A multi-dimensional iterator templated over image type that walks a region of pixels, scanline by scanline or in the direction of the fastest axis.
void DynamicThreadedGenerateData(const OutputRegionType &region) override
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputRegionType
virtual void DynamicMultiThreadingOn()
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
GetSetFunctorMacro(Functor, FunctorType)
TOutputImage OutputImageType
const InputImageType * GetInput() const
typename InputImageType::RegionType InputRegionType
void Set(const PixelType &value) const
Base class for filters that take an image as input and produce an image as output.
OutputImageType * GetOutput()
A (simplification of) UnaryFunctorImageFilter, which provides the pixel index to the functor...