ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkNotImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 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
58  UnaryFunctorImageFilter< TInputImage, TOutputImage,
59  Functor::NOT<
60  typename TInputImage::PixelType,
61  typename TOutputImage::PixelType > >
62 
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_ASSIGN(NotImageFilter);
66 
70  TInputImage, TOutputImage,
72  typename TInputImage::PixelType,
73  typename TOutputImage::PixelType > >;
74 
77 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(NotImageFilter,
84 
87  void SetBackgroundValue(const typename TOutputImage::PixelType & backgroundValue)
88  {
89  if ( Math::NotExactlyEquals(this->GetBackgroundValue(), backgroundValue) )
90  {
91  this->Modified();
92  this->GetFunctor().SetBackgroundValue(backgroundValue);
93  }
94  }
95  typename TOutputImage::PixelType GetBackgroundValue() const
96  {
97  return this->GetFunctor().GetBackgroundValue();
98  }
100 
101 
104  void SetForegroundValue(const typename TOutputImage::PixelType & foregroundValue)
105  {
106  std::cout << "this->GetForegroundValue(): " << this->GetForegroundValue()
107  << " foregroundValue: " << foregroundValue << std::endl;
108  if ( Math::NotExactlyEquals(this->GetForegroundValue(), foregroundValue) )
109  {
110  this->Modified();
111  this->GetFunctor().SetForegroundValue(foregroundValue);
112  }
113  }
114  typename TOutputImage::PixelType GetForegroundValue() const
115  {
116  return this->GetFunctor().GetForegroundValue();
117  }
119 
120 
121 #ifdef ITK_USE_CONCEPT_CHECKING
122  // Begin concept checking
123  itkConceptMacro( InputConvertibleToOutputCheck,
124  ( Concept::Convertible< typename TInputImage::PixelType,
125  bool > ) );
126  itkConceptMacro( OutputConvertibleToOutputCheck,
127  ( Concept::Convertible< bool,
128  typename TOutputImage::PixelType > ) );
129  itkConceptMacro( InputNotOperatorCheck,
131  // End concept checking
132 #endif
133 
134 protected:
136  {
137  this->GetFunctor().SetForegroundValue(true);
138  this->GetFunctor().SetBackgroundValue(false);
139  }
140  ~NotImageFilter() override = default;
141 };
142 } // end namespace itk
143 
144 #endif
void SetBackgroundValue(const TOutput &BG)
Implements the NOT logical operator pixel-wise on an image.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
TOutputImage::PixelType GetBackgroundValue() const
~NotImageFilter() override=default
void SetBackgroundValue(const typename TOutputImage::PixelType &backgroundValue)
TOutput GetBackgroundValue() const
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
virtual void Modified() const
Implements pixel-wise generic operation on one image.
void SetForegroundValue(const typename TOutputImage::PixelType &foregroundValue)
Unary logical NOT functor.
void SetForegroundValue(const TOutput &FG)
#define itkConceptMacro(name, concept)
TOutput GetForegroundValue() const
TOutputImage::PixelType GetForegroundValue() const