ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkBinaryNotImageFilter.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 itkBinaryNotImageFilter_h
19 #define itkBinaryNotImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 
25 namespace itk
26 {
27 
54 namespace Functor {
55 
56 template< typename TPixel >
57 class BinaryNot
58 {
59 public:
60  BinaryNot() {};
61  ~BinaryNot() {};
62  bool operator!=( const BinaryNot & ) const
63  {
64  return false;
65  }
66  bool operator==( const BinaryNot & other ) const
67  {
68  return !(*this != other);
69  }
70  inline TPixel operator()( const TPixel & A )
71  {
72  bool a = ( A == m_ForegroundValue );
73  if( !a )
74  {
75  return m_ForegroundValue;
76  }
77  return m_BackgroundValue;
78  }
79 
82 };
83 
84 }
85 template <typename TImage>
87  public
88 UnaryFunctorImageFilter<TImage, TImage,
89  Functor::BinaryNot< typename TImage::PixelType > >
90 
91 
92 {
93 public:
96  typedef UnaryFunctorImageFilter<TImage, TImage,
100 
102  itkNewMacro(Self);
103 
105  itkTypeMacro(BinaryNotImageFilter,
107 
108  typedef typename TImage::PixelType PixelType;
109 
112  itkSetMacro(ForegroundValue, PixelType);
113  itkGetConstMacro(ForegroundValue, PixelType);
115 
118  itkSetMacro(BackgroundValue, PixelType);
119 
122  itkGetConstMacro(BackgroundValue, PixelType);
123 
124 protected:
126  {
129  }
131 
132  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
133  {
134  Superclass::PrintSelf(os,indent);
135 
136  typedef typename NumericTraits<PixelType>::PrintType
137  PixelPrintType;
138 
139  os << indent << "ForegroundValue: "
140  << static_cast< PixelPrintType > (m_ForegroundValue)
141  << std::endl;
142 
143  os << indent << "BackgroundValue: "
144  << static_cast< PixelPrintType > (m_BackgroundValue)
145  << std::endl;
146  }
147 
148  void GenerateData() ITK_OVERRIDE
149  {
153  }
154 
155 private:
156  BinaryNotImageFilter(const Self&); //purposely not implemented
157  void operator=(const Self&); //purposely not implemented
158 
161 
162 };
163 
164 } // end namespace itk
165 
166 
167 #endif
Light weight base class for most itk classes.
TPixel operator()(const TPixel &A)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void GenerateData() override
SmartPointer< const Self > ConstPointer
bool operator!=(const BinaryNot &) const
void operator=(const Self &)
virtual void PrintSelf(std::ostream &os, Indent indent) const override
static T max(const T &)
Implements the BinaryNot logical operator pixel-wise between two images.
bool operator==(const BinaryNot &other) const
Implements pixel-wise generic operation on one image.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
UnaryFunctorImageFilter< TImage, TImage, Functor::BinaryNot< typename TImage::PixelType > > Superclass
Define additional traits for native types such as int or float.