ITK  4.13.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:
68  TInputImage, TOutputImage,
70  typename TInputImage::PixelType,
71  typename TOutputImage::PixelType >
73 
76 
78  itkNewMacro(Self);
79 
81  itkTypeMacro(NotImageFilter,
83 
86  void SetBackgroundValue(const typename TOutputImage::PixelType & backgroundValue)
87  {
88  if ( Math::NotExactlyEquals(this->GetBackgroundValue(), backgroundValue) )
89  {
90  this->Modified();
91  this->GetFunctor().SetBackgroundValue(backgroundValue);
92  }
93  }
94  typename TOutputImage::PixelType GetBackgroundValue() const
95  {
96  return this->GetFunctor().GetBackgroundValue();
97  }
99 
100 
103  void 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 GetForegroundValue() const
114  {
115  return this->GetFunctor().GetForegroundValue();
116  }
118 
119 
120 #ifdef ITK_USE_CONCEPT_CHECKING
121  // Begin concept checking
122  itkConceptMacro( InputConvertibleToOutputCheck,
123  ( Concept::Convertible< typename TInputImage::PixelType,
124  bool > ) );
125  itkConceptMacro( OutputConvertibleToOutputCheck,
126  ( Concept::Convertible< bool,
127  typename TOutputImage::PixelType > ) );
128  itkConceptMacro( InputNotOperatorCheck,
130  // End concept checking
131 #endif
132 
133 protected:
135  {
136  this->GetFunctor().SetForegroundValue(true);
137  this->GetFunctor().SetBackgroundValue(false);
138  }
139  virtual ~NotImageFilter() ITK_OVERRIDE {}
140 
141 private:
142  ITK_DISALLOW_COPY_AND_ASSIGN(NotImageFilter);
143 };
144 } // end namespace itk
145 
146 #endif
SmartPointer< Self > Pointer
virtual ~NotImageFilter() override
void SetBackgroundValue(const TOutput &BG)
Implements the NOT logical operator pixel-wise on an image.
Base class for all process objects that output image data.
TOutputImage::PixelType GetBackgroundValue() const
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::NOT< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
void SetBackgroundValue(const typename TOutputImage::PixelType &backgroundValue)
TOutput GetBackgroundValue() const
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:721
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
SmartPointer< const Self > ConstPointer
TOutputImage::PixelType GetForegroundValue() const