ITK  6.0.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
25namespace itk
26{
55template <typename TInputImage, typename TOutputImage>
57 : public UnaryFunctorImageFilter<TInputImage,
58 TOutputImage,
59 Functor::NOT<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
60
61{
62public:
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
129protected:
131 {
132 this->GetFunctor().SetForegroundValue(true);
133 this->GetFunctor().SetBackgroundValue(false);
134 }
135 ~NotImageFilter() override = default;
136};
137} // end namespace itk
138
139#endif
void SetForegroundValue(const TOutput &FG)
void SetBackgroundValue(const TOutput &BG)
TOutput GetForegroundValue() const
TOutput GetBackgroundValue() const
Unary logical NOT functor.
Base class for all process objects that output image data.
Implements the NOT logical operator pixel-wise on an image.
TOutputImage::PixelType GetForegroundValue() const
void SetBackgroundValue(const typename TOutputImage::PixelType &backgroundValue)
TOutputImage::PixelType GetBackgroundValue() const
~NotImageFilter() override=default
void SetForegroundValue(const typename TOutputImage::PixelType &foregroundValue)
virtual void Modified() const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:737
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....