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 
25 namespace itk
26 {
27 
54 namespace Functor
55 {
56 
57 template <typename TPixel>
58 class BinaryNot
59 {
60 public:
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  const 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
85 template <typename TImage>
87  : public UnaryFunctorImageFilter<TImage, TImage, Functor::BinaryNot<typename TImage::PixelType>>
88 {
89 public:
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);
118 protected:
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 
146 private:
149 };
150 
151 } // end namespace itk
152 
153 
154 #endif
itk::Functor::BinaryNot
Definition: itkBinaryNotImageFilter.h:58
itk::BinaryNotImageFilter
Implements the BinaryNot logical operator pixel-wise between two images.
Definition: itkBinaryNotImageFilter.h:86
itkUnaryFunctorImageFilter.h
itk::Functor::BinaryNot::m_ForegroundValue
TPixel m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:80
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::BinaryNotImageFilter::PixelType
typename TImage::PixelType PixelType
Definition: itkBinaryNotImageFilter.h:104
itk::Functor::BinaryNot::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BinaryNot)
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::BinaryNotImageFilter::~BinaryNotImageFilter
~BinaryNotImageFilter() override=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:55
itk::BinaryNotImageFilter::GenerateData
void GenerateData() override
Definition: itkBinaryNotImageFilter.h:139
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:81
itk::Functor::BinaryNot::operator()
TPixel operator()(const TPixel &A) const
Definition: itkBinaryNotImageFilter.h:70
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:169
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::BinaryNotImageFilter::m_ForegroundValue
PixelType m_ForegroundValue
Definition: itkBinaryNotImageFilter.h:147
itk::BinaryNotImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryNotImageFilter.h:127
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:62
itk::BinaryNotImageFilter::m_BackgroundValue
PixelType m_BackgroundValue
Definition: itkBinaryNotImageFilter.h:148
itk::BinaryNotImageFilter::BinaryNotImageFilter
BinaryNotImageFilter()
Definition: itkBinaryNotImageFilter.h:119