ITK  5.4.0
Insight Toolkit
itkNotImageFilter.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 itkNotImageFilter_h
19 #define itkNotImageFilter_h
20 
22 #include "itkLogicOpsFunctors.h"
23 #include "itkNumericTraits.h"
24 
25 namespace itk
26 {
55 template <typename TInputImage, typename TOutputImage>
57  : public UnaryFunctorImageFilter<TInputImage,
58  TOutputImage,
59  Functor::NOT<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
60 
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_MOVE(NotImageFilter);
64 
67  using Superclass =
68  UnaryFunctorImageFilter<TInputImage,
69  TOutputImage,
71 
74 
76  itkNewMacro(Self);
77 
79  itkOverrideGetNameOfClassMacro(NotImageFilter);
80 
83  void
84  SetBackgroundValue(const typename TOutputImage::PixelType & backgroundValue)
85  {
86  if (Math::NotExactlyEquals(this->GetBackgroundValue(), backgroundValue))
87  {
88  this->Modified();
89  this->GetFunctor().SetBackgroundValue(backgroundValue);
90  }
91  }
92  typename TOutputImage::PixelType
94  {
95  return this->GetFunctor().GetBackgroundValue();
96  }
102  void
103  SetForegroundValue(const typename TOutputImage::PixelType & foregroundValue)
104  {
105  std::cout << "this->GetForegroundValue(): " << this->GetForegroundValue()
106  << " foregroundValue: " << foregroundValue << std::endl;
107  if (Math::NotExactlyEquals(this->GetForegroundValue(), foregroundValue))
108  {
109  this->Modified();
110  this->GetFunctor().SetForegroundValue(foregroundValue);
111  }
112  }
113  typename TOutputImage::PixelType
115  {
116  return this->GetFunctor().GetForegroundValue();
117  }
121 #ifdef ITK_USE_CONCEPT_CHECKING
122  // Begin concept checking
126  // End concept checking
127 #endif
128 
129 protected:
131  {
132  this->GetFunctor().SetForegroundValue(true);
133  this->GetFunctor().SetBackgroundValue(false);
134  }
135  ~NotImageFilter() override = default;
136 };
137 } // end namespace itk
138 
139 #endif
itkUnaryFunctorImageFilter.h
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::Functor::LogicOpBase::GetForegroundValue
TOutput GetForegroundValue() const
Definition: itkLogicOpsFunctors.h:92
itkLogicOpsFunctors.h
itk::NotImageFilter::SetBackgroundValue
void SetBackgroundValue(const typename TOutputImage::PixelType &backgroundValue)
Definition: itkNotImageFilter.h:84
itk::Functor::NOT
Unary logical NOT functor.
Definition: itkLogicOpsFunctors.h:323
itk::Concept::NotOperator
Definition: itkConceptChecking.h:599
itk::SmartPointer< Self >
itk::Math::NotExactlyEquals
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:737
itk::NotImageFilter::GetForegroundValue
TOutputImage::PixelType GetForegroundValue() const
Definition: itkNotImageFilter.h:114
itk::Functor::LogicOpBase::SetForegroundValue
void SetForegroundValue(const TOutput &FG)
Definition: itkLogicOpsFunctors.h:81
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::NotImageFilter::~NotImageFilter
~NotImageFilter() override=default
itk::NotImageFilter::GetBackgroundValue
TOutputImage::PixelType GetBackgroundValue() const
Definition: itkNotImageFilter.h:93
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::NotImageFilter::NotImageFilter
NotImageFilter()
Definition: itkNotImageFilter.h:130
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::NOT< TInputImage::PixelType, TOutputImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
itkNumericTraits.h
itk::Functor::LogicOpBase::GetBackgroundValue
TOutput GetBackgroundValue() const
Definition: itkLogicOpsFunctors.h:97
itk::NotImageFilter::SetForegroundValue
void SetForegroundValue(const typename TOutputImage::PixelType &foregroundValue)
Definition: itkNotImageFilter.h:103
itk::Object::Modified
virtual void Modified() const
itk::NotImageFilter
Implements the NOT logical operator pixel-wise on an image.
Definition: itkNotImageFilter.h:56
itk::Functor::LogicOpBase::SetBackgroundValue
void SetBackgroundValue(const TOutput &BG)
Definition: itkLogicOpsFunctors.h:86