ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkAdaptImageFilter.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 itkAdaptImageFilter_h
19#define itkAdaptImageFilter_h
20
22
23namespace itk
24{
25namespace Functor
26{
42template <typename TInput, typename TAccessor>
44{
45public:
46
49 using AccessorType = TAccessor;
50
52 using OutputType = typename TAccessor::ExternalType;
53 inline OutputType
54 operator()(const TInput & A) const
55 {
56 return m_Accessor.Get(A);
57 }
58
59
63 {
64 return m_Accessor;
65 }
66
72 void
74 {
75 m_Accessor = accessor;
76 }
77
79 bool
80 operator==(const Self & other) const
81 {
82 return m_Accessor == other.m_Accessor;
83 }
84
86
87private:
89};
90} // namespace Functor
91
120template <typename TInputImage, typename TOutputImage, typename TAccessor>
122 : public UnaryFunctorImageFilter<TInputImage,
123 TOutputImage,
124 Functor::AccessorFunctor<typename TInputImage::PixelType, TAccessor>>
125{
126public:
127 ITK_DISALLOW_COPY_AND_MOVE(AdaptImageFilter);
129
132
134 TOutputImage,
136
139 using typename Superclass::FunctorType;
140
142 itkNewMacro(Self);
143
145 using AccessorType = TAccessor;
146
148 itkOverrideGetNameOfClassMacro(AdaptImageFilter);
149
153 {
154 return this->GetFunctor().GetAccessor();
155 }
156
158 void
160 {
161 FunctorType functor = this->GetFunctor();
162 if (accessor != functor.GetAccessor())
163 {
164 functor.SetAccessor(accessor);
165 this->SetFunctor(functor);
166 this->Modified();
167 }
168 }
169
170
171protected:
172 AdaptImageFilter() = default;
173 ~AdaptImageFilter() override = default;
174};
175} // end namespace itk
176
177#endif
~AdaptImageFilter() override=default
AdaptImageFilter()=default
SmartPointer< Self > Pointer
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::AccessorFunctor< typename TInputImage::PixelType, TAccessor > > Superclass
void SetAccessor(AccessorType &accessor)
SmartPointer< const Self > ConstPointer
Convert an accessor to a functor so that it can be used in a UnaryFunctorImageFilter.
OutputType operator()(const TInput &A) const
bool operator==(const Self &other) const
typename TAccessor::ExternalType OutputType
void SetAccessor(AccessorType &accessor)
virtual void Modified() const
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....