ITK  4.9.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 
32 namespace itk
33 {
34 
35 template<typename TInputImage, typename TOutputImage, typename TFunctor>
37  public ImageToImageFilter<TInputImage, TOutputImage>
38 {
39 public:
44 
46  itkNewMacro(Self);
47 
50 
51  typedef TInputImage InputImageType;
52  typedef TOutputImage OutputImageType;
53  typedef TFunctor FunctorType;
54 
56 
57 protected:
59 
61 
62  typedef typename InputImageType::RegionType InputRegionType;
63  typedef typename OutputImageType::RegionType OutputRegionType;
64 
65  virtual void ThreadedGenerateData(const OutputRegionType & region, ThreadIdType) ITK_OVERRIDE
66  {
67  if( region.GetSize()[0] == 0 )
68  {
69  return;
70  }
71 
73  ImageScanlineIterator< OutputImageType > outputIt( this->GetOutput(), region);
74 
75  for( inputIt.GoToBegin(), outputIt.GoToBegin();
76  !outputIt.IsAtEnd();
77  )
78  {
79  while(!outputIt.IsAtEndOfLine())
80  {
81  outputIt.Set(m_Functor(inputIt.Value(), inputIt.GetIndex()));
82  ++inputIt;
83  ++outputIt;
84  }
85  outputIt.NextLine();
86  }
87  }
88 };
89 
90 } // end namespace itk
91 
92 #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()