ITK  6.0.0
Insight Toolkit
itkBinaryNotImageFilter.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 itkBinaryNotImageFilter_h
19#define itkBinaryNotImageFilter_h
20
22#include "itkNumericTraits.h"
23
24
25namespace itk
26{
27
54namespace Functor
55{
56
57template <typename TPixel>
59{
60public:
61 bool
62 operator==(const BinaryNot &) const
63 {
64 return true;
65 }
66
68
69 inline TPixel
70 operator()(const TPixel & A) const
71 {
72 bool a = (A == m_ForegroundValue);
73 if (!a)
74 {
75 return m_ForegroundValue;
76 }
77 return m_BackgroundValue;
78 }
79
82};
83
84} // namespace Functor
85template <typename TImage>
87 : public UnaryFunctorImageFilter<TImage, TImage, Functor::BinaryNot<typename TImage::PixelType>>
88{
89public:
90 ITK_DISALLOW_COPY_AND_MOVE(BinaryNotImageFilter);
91
97
99 itkNewMacro(Self);
100
102 itkOverrideGetNameOfClassMacro(BinaryNotImageFilter);
103
104 using PixelType = typename TImage::PixelType;
105
108 itkSetMacro(ForegroundValue, PixelType);
109 itkGetConstMacro(ForegroundValue, PixelType);
114 itkSetMacro(BackgroundValue, PixelType);
115 itkGetConstMacro(BackgroundValue, PixelType);
118protected:
120 {
123 }
124 ~BinaryNotImageFilter() override = default;
125
126 void
127 PrintSelf(std::ostream & os, Indent indent) const override
128 {
129 Superclass::PrintSelf(os, indent);
130
131 using PixelPrintType = typename NumericTraits<PixelType>::PrintType;
132
133 os << indent << "ForegroundValue: " << static_cast<PixelPrintType>(m_ForegroundValue) << std::endl;
134
135 os << indent << "BackgroundValue: " << static_cast<PixelPrintType>(m_BackgroundValue) << std::endl;
136 }
137
138 void
139 GenerateData() override
140 {
144 }
145
146private:
149};
150
151} // end namespace itk
152
153
154#endif
Implements the BinaryNot logical operator pixel-wise between two images.
~BinaryNotImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
typename TImage::PixelType PixelType
TPixel operator()(const TPixel &A) const
bool operator==(const BinaryNot &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BinaryNot)
void GenerateData() override
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
Implements pixel-wise generic operation on one image.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....