ITK  5.3.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 true;
67  }
68 
70 
71  inline TPixel
72  operator()(const TPixel & A) const
73  {
74  bool a = (A == m_ForegroundValue);
75  if (!a)
76  {
77  return m_ForegroundValue;
78  }
79  return m_BackgroundValue;
80  }
81 
84 };
85 
86 } // namespace Functor
87 template <typename TImage>
89  : public UnaryFunctorImageFilter<TImage, TImage, Functor::BinaryNot<typename TImage::PixelType>>
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_MOVE(BinaryNotImageFilter);
93 
99 
101  itkNewMacro(Self);
102 
105 
106  using PixelType = typename TImage::PixelType;
107 
110  itkSetMacro(ForegroundValue, PixelType);
111  itkGetConstMacro(ForegroundValue, PixelType);
113 
116  itkSetMacro(BackgroundValue, PixelType);
117  itkGetConstMacro(BackgroundValue, PixelType);
119 
120 protected:
122  {
125  }
126  ~BinaryNotImageFilter() override = default;
127 
128  void
129  PrintSelf(std::ostream & os, Indent indent) const override
130  {
131  Superclass::PrintSelf(os, indent);
132 
133  using PixelPrintType = typename NumericTraits<PixelType>::PrintType;
134 
135  os << indent << "ForegroundValue: " << static_cast<PixelPrintType>(m_ForegroundValue) << std::endl;
136 
137  os << indent << "BackgroundValue: " << static_cast<PixelPrintType>(m_BackgroundValue) << std::endl;
138  }
139 
140  void
141  GenerateData() override
142  {
146  }
147 
148 private:
151 };
152 
153 } // end namespace itk
154 
155 
156 #endif
itk::Functor::BinaryNot
Definition: itkBinaryNotImageFilter.h:58
itk::BinaryNotImageFilter
Implements the BinaryNot logical operator pixel-wise between two images.
Definition: itkBinaryNotImageFilter.h:88
itkUnaryFunctorImageFilter.h
itk::Functor::BinaryNot::m_ForegroundValue
TPixel m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:82
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::BinaryNotImageFilter::PixelType
typename TImage::PixelType PixelType
Definition: itkBinaryNotImageFilter.h:106
itk::Functor::BinaryNot::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BinaryNot)
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:97
itk::BinaryNotImageFilter::~BinaryNotImageFilter
~BinaryNotImageFilter() override=default
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:141
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:83
itk::Functor::BinaryNot::operator()
TPixel operator()(const TPixel &A) const
Definition: itkBinaryNotImageFilter.h:72
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:149
itk::BinaryNotImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryNotImageFilter.h:129
itk::UnaryFunctorImageFilter< TImage, TImage, Functor::BinaryNot< TImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
itkNumericTraits.h
itk::Functor::BinaryNot::operator==
bool operator==(const BinaryNot &) const
Definition: itkBinaryNotImageFilter.h:64
itk::BinaryNotImageFilter::m_BackgroundValue
PixelType m_BackgroundValue
Definition: itkBinaryNotImageFilter.h:150
itk::BinaryNotImageFilter::BinaryNotImageFilter
BinaryNotImageFilter()
Definition: itkBinaryNotImageFilter.h:121