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 
54 namespace Functor
55 {
56 
57 template <typename TPixel>
58 class BinaryNot
59 {
60 public:
61  BinaryNot() = default;
62  ~BinaryNot() = default;
63  bool
64  operator!=(const BinaryNot &) const
65  {
66  return false;
67  }
68  bool
69  operator==(const BinaryNot & other) const
70  {
71  return !(*this != other);
72  }
73  inline TPixel
74  operator()(const TPixel & A) const
75  {
76  bool a = (A == m_ForegroundValue);
77  if (!a)
78  {
79  return m_ForegroundValue;
80  }
81  return m_BackgroundValue;
82  }
83 
86 };
87 
88 } // namespace Functor
89 template <typename TImage>
91  : public UnaryFunctorImageFilter<TImage, TImage, Functor::BinaryNot<typename TImage::PixelType>>
92 {
93 public:
94  ITK_DISALLOW_COPY_AND_MOVE(BinaryNotImageFilter);
95 
101 
103  itkNewMacro(Self);
104 
107 
108  using PixelType = typename TImage::PixelType;
109 
112  itkSetMacro(ForegroundValue, PixelType);
113  itkGetConstMacro(ForegroundValue, PixelType);
115 
118  itkSetMacro(BackgroundValue, PixelType);
119 
122  itkGetConstMacro(BackgroundValue, PixelType);
123 
124 protected:
126  {
129  }
130  ~BinaryNotImageFilter() override = default;
131 
132  void
133  PrintSelf(std::ostream & os, Indent indent) const override
134  {
135  Superclass::PrintSelf(os, indent);
136 
137  using PixelPrintType = typename NumericTraits<PixelType>::PrintType;
138 
139  os << indent << "ForegroundValue: " << static_cast<PixelPrintType>(m_ForegroundValue) << std::endl;
140 
141  os << indent << "BackgroundValue: " << static_cast<PixelPrintType>(m_BackgroundValue) << std::endl;
142  }
143 
144  void
145  GenerateData() override
146  {
150  }
151 
152 private:
155 };
156 
157 } // end namespace itk
158 
159 
160 #endif
itk::Functor::BinaryNot
Definition: itkBinaryNotImageFilter.h:58
itk::BinaryNotImageFilter
Implements the BinaryNot logical operator pixel-wise between two images.
Definition: itkBinaryNotImageFilter.h:90
itkUnaryFunctorImageFilter.h
itk::Functor::BinaryNot::m_ForegroundValue
TPixel m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:84
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::BinaryNotImageFilter::PixelType
typename TImage::PixelType PixelType
Definition: itkBinaryNotImageFilter.h:108
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:69
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:145
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:85
itk::Functor::BinaryNot::operator()
TPixel operator()(const TPixel &A) const
Definition: itkBinaryNotImageFilter.h:74
itk::Functor::BinaryNot::operator!=
bool operator!=(const BinaryNot &) const
Definition: itkBinaryNotImageFilter.h:64
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:153
itk::BinaryNotImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryNotImageFilter.h:133
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:154
itk::BinaryNotImageFilter::BinaryNotImageFilter
BinaryNotImageFilter()
Definition: itkBinaryNotImageFilter.h:125