ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkUnaryFunctorWithIndexImageFilter.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
19//
20// Created by Jean-Marie Mirebeau on 07/03/2014.
21//
22//
23
24#ifndef itkUnaryFunctorWithIndexImageFilter_h
25#define itkUnaryFunctorWithIndexImageFilter_h
26
31
32namespace itk
33{
34
41template <typename TInputImage, typename TOutputImage, typename TFunctor>
42class UnaryFunctorWithIndexImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(UnaryFunctorWithIndexImageFilter);
46
51
53 itkNewMacro(Self);
54
56 itkOverrideGetNameOfClassMacro(UnaryFunctorWithIndexImageFilter);
57
58 using InputImageType = TInputImage;
59 using OutputImageType = TOutputImage;
60 using FunctorType = TFunctor;
61
63
64protected:
66
68
69 using InputRegionType = typename InputImageType::RegionType;
70 using OutputRegionType = typename OutputImageType::RegionType;
71
72 void
74 {
75 if (region.GetSize()[0] == 0)
76 {
77 return;
78 }
79
81 ImageScanlineIterator<OutputImageType> outputIt(this->GetOutput(), region);
82
83 for (inputIt.GoToBegin(), outputIt.GoToBegin(); !outputIt.IsAtEnd();)
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
void Set(const PixelType &value) const
Read-only ImageRegionIteratorWithIndex: ImageRegionConstIteratorWithIndex<TImage> behaves as ImageReg...
A multi-dimensional iterator templated over image type that walks a region of pixels,...
OutputImageType * GetOutput()
virtual void DynamicMultiThreadingOn()
const InputImageType * GetInput() const
Implements transparent reference counting.
GetSetFunctorMacro(Functor, FunctorType)
typename OutputImageType::RegionType OutputRegionType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
void DynamicThreadedGenerateData(const OutputRegionType &region) override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....