ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkReplaceNonFiniteImageFilter.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 itkReplaceNonFiniteImageFilter_h
19#define itkReplaceNonFiniteImageFilter_h
20
22#include "itkMath.h"
23
24namespace itk
25{
26namespace Functor
27{
33template <typename TInput, typename TOutput>
35{
36public:
37 using InputType = TInput;
38 using OutputType = TOutput;
39
40 ReplaceNonFinite() = default;
41 ~ReplaceNonFinite() = default;
42
43 const OutputType &
45 {
46 return this->m_ReplacementValue;
47 }
48 void
50 {
51 this->m_ReplacementValue = value;
52 }
53
54 bool
55 operator!=(const ReplaceNonFinite & other) const
56 {
57 return (other.GetReplacementValue() != this->m_ReplacementValue);
58 }
59
60 bool
61 operator==(const ReplaceNonFinite & other) const
62 {
63 return !(*this != other);
64 }
65
66 inline OutputType
67 operator()(const InputType & input) const
68 {
69 if (Math::isfinite(input))
70 {
71 return static_cast<OutputType>(input);
72 }
73 else
74 {
75 return this->m_ReplacementValue;
76 }
77 }
78
79private:
81};
82} // namespace Functor
83
84
92template <typename TInputImage, typename TOutputImage = TInputImage>
95 TInputImage,
96 TOutputImage,
97 Functor::ReplaceNonFinite<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
98{
99public:
100 ITK_DISALLOW_COPY_AND_MOVE(ReplaceNonFiniteImageFilter);
101
105 TInputImage,
106 TOutputImage,
108
111
113 itkNewMacro(Self);
114
116 itkOverrideGetNameOfClassMacro(ReplaceNonFiniteImageFilter);
117
118protected:
120 ~ReplaceNonFiniteImageFilter() override = default;
121};
122
123} // end namespace itk
124
125#endif // itkReplaceNonFiniteImageFilter_h
Replaces a non-finite value with a finite one.
bool operator==(const ReplaceNonFinite &other) const
bool operator!=(const ReplaceNonFinite &other) const
void SetReplacementValue(const OutputType &value)
OutputType operator()(const InputType &input) const
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ReplaceNonFinite< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
~ReplaceNonFiniteImageFilter() override=default
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....