ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
61public:
62 ITK_DISALLOW_COPY_AND_MOVE(NotImageFilter);
63
66 using Superclass =
67 UnaryFunctorImageFilter<TInputImage,
68 TOutputImage,
70
73
75 itkNewMacro(Self);
76
78 itkOverrideGetNameOfClassMacro(NotImageFilter);
79
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 }
97
98
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 }
118
119
123
124protected:
126 {
127 this->GetFunctor().SetForegroundValue(true);
128 this->GetFunctor().SetBackgroundValue(false);
129 }
130 ~NotImageFilter() override = default;
131};
132} // end namespace itk
133
134#endif
void SetForegroundValue(const TOutput &FG)
void SetBackgroundValue(const TOutput &BG)
Unary logical NOT functor.
TOutputImage::PixelType GetForegroundValue() const
void SetBackgroundValue(const typename TOutputImage::PixelType &backgroundValue)
SmartPointer< const Self > ConstPointer
TOutputImage::PixelType GetBackgroundValue() const
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::NOT< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
~NotImageFilter() override=default
SmartPointer< Self > Pointer
void SetForegroundValue(const typename TOutputImage::PixelType &foregroundValue)
virtual void Modified() const
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
constexpr bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition itkMath.h:754
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....