ITK  5.2.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  * 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 #ifndef itkBinaryNotImageFilter_h
19 #define itkBinaryNotImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 
25 namespace itk
26 {
27 
55 namespace Functor
56 {
57 
58 template <typename TPixel>
59 class BinaryNot
60 {
61 public:
62  BinaryNot() = default;
63  ~BinaryNot() = default;
64  bool
65  operator!=(const BinaryNot &) const
66  {
67  return false;
68  }
69  bool
70  operator==(const BinaryNot & other) const
71  {
72  return !(*this != other);
73  }
74  inline TPixel
75  operator()(const TPixel & A) const
76  {
77  bool a = (A == m_ForegroundValue);
78  if (!a)
79  {
80  return m_ForegroundValue;
81  }
82  return m_BackgroundValue;
83  }
84 
87 };
88 
89 } // namespace Functor
90 template <typename TImage>
92  : public UnaryFunctorImageFilter<TImage, TImage, Functor::BinaryNot<typename TImage::PixelType>>
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryNotImageFilter);
96 
102 
104  itkNewMacro(Self);
105 
108 
109  using PixelType = typename TImage::PixelType;
110 
113  itkSetMacro(ForegroundValue, PixelType);
114  itkGetConstMacro(ForegroundValue, PixelType);
116 
119  itkSetMacro(BackgroundValue, PixelType);
120 
123  itkGetConstMacro(BackgroundValue, PixelType);
124 
125 protected:
127  {
130  }
131  ~BinaryNotImageFilter() override = default;
132 
133  void
134  PrintSelf(std::ostream & os, Indent indent) const override
135  {
136  Superclass::PrintSelf(os, indent);
137 
138  using PixelPrintType = typename NumericTraits<PixelType>::PrintType;
139 
140  os << indent << "ForegroundValue: " << static_cast<PixelPrintType>(m_ForegroundValue) << std::endl;
141 
142  os << indent << "BackgroundValue: " << static_cast<PixelPrintType>(m_BackgroundValue) << std::endl;
143  }
144 
145  void
146  GenerateData() override
147  {
151  }
152 
153 private:
156 };
157 
158 } // end namespace itk
159 
160 
161 #endif
itk::Functor::BinaryNot
Definition: itkBinaryNotImageFilter.h:59
itk::BinaryNotImageFilter
Implements the BinaryNot logical operator pixel-wise between two images.
Definition: itkBinaryNotImageFilter.h:91
itkUnaryFunctorImageFilter.h
itk::Functor::BinaryNot::m_ForegroundValue
TPixel m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:85
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::BinaryNotImageFilter::PixelType
typename TImage::PixelType PixelType
Definition: itkBinaryNotImageFilter.h:109
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:97
itk::BinaryNotImageFilter::~BinaryNotImageFilter
~BinaryNotImageFilter() override=default
itk::Functor::BinaryNot::operator==
bool operator==(const BinaryNot &other) const
Definition: itkBinaryNotImageFilter.h:70
itk::Functor::BinaryNot::BinaryNot
BinaryNot()=default
itk::Functor::BinaryNot::~BinaryNot
~BinaryNot()=default
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::BinaryNotImageFilter::GenerateData
void GenerateData() override
Definition: itkBinaryNotImageFilter.h:146
itk::InPlaceImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::ImageSource::GenerateData
void GenerateData() override
itk::Functor::BinaryNot::m_BackgroundValue
TPixel m_BackgroundValue
Definition: itkBinaryNotImageFilter.h:86
itk::Functor::BinaryNot::operator()
TPixel operator()(const TPixel &A) const
Definition: itkBinaryNotImageFilter.h:75
itk::Functor::BinaryNot::operator!=
bool operator!=(const BinaryNot &) const
Definition: itkBinaryNotImageFilter.h:65
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:167
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::BinaryNotImageFilter::m_ForegroundValue
PixelType m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:154
itk::BinaryNotImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryNotImageFilter.h:134
itk::UnaryFunctorImageFilter< TImage, TImage, Functor::BinaryNot< TImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
itkNumericTraits.h
itk::BinaryNotImageFilter::m_BackgroundValue
PixelType m_BackgroundValue
Definition: itkBinaryNotImageFilter.h:155
itk::BinaryNotImageFilter::BinaryNotImageFilter
BinaryNotImageFilter()
Definition: itkBinaryNotImageFilter.h:126