ITK  4.13.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  typedef TInputImage InputImageType;
57  typedef TOutputImage OutputImageType;
58  typedef TFunctor FunctorType;
59 
61 
62 protected:
64 
66 
67  typedef typename InputImageType::RegionType InputRegionType;
68  typedef typename OutputImageType::RegionType OutputRegionType;
69 
70  virtual void ThreadedGenerateData(const OutputRegionType & region, ThreadIdType) ITK_OVERRIDE
71  {
72  if( region.GetSize()[0] == 0 )
73  {
74  return;
75  }
76 
78  ImageScanlineIterator< OutputImageType > outputIt( this->GetOutput(), region);
79 
80  for( inputIt.GoToBegin(), outputIt.GoToBegin();
81  !outputIt.IsAtEnd();
82  )
83  {
84  while(!outputIt.IsAtEndOfLine())
85  {
86  outputIt.Set(m_Functor(inputIt.Value(), inputIt.GetIndex()));
87  ++inputIt;
88  ++outputIt;
89  }
90  outputIt.NextLine();
91  }
92  }
93 };
94 
95 } // end namespace itk
96 
97 #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.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
virtual void ThreadedGenerateData(const OutputRegionType &region, ThreadIdType) override
Base class for all process objects that output image data.
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
ImageToImageFilter< TInputImage, TOutputImage > Superclass
GetSetFunctorMacro(Functor, FunctorType)
const InputImageType * GetInput() const
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
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...