ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkInvertIntensityImageFilter.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 itkInvertIntensityImageFilter_h
19 #define itkInvertIntensityImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
32 template< typename TInput, typename TOutput >
33 class ITK_TEMPLATE_EXPORT InvertIntensityTransform
34 {
35 public:
40 
41  void SetMaximum(TOutput max) { m_Maximum = max; }
42 
43  bool operator!=(const InvertIntensityTransform & other) const
44  {
45  if ( m_Maximum != other.m_Maximum )
46  {
47  return true;
48  }
49  return false;
50  }
51 
52  bool operator==(const InvertIntensityTransform & other) const
53  {
54  return !( *this != other );
55  }
56 
57  inline TOutput operator()(const TInput & x) const
58  {
59  TOutput result = static_cast< TOutput >( m_Maximum - x );
60 
61  return result;
62  }
63 
64 private:
65  TInput m_Maximum;
66 };
67 } // end namespace functor
68 
89 template< typename TInputImage, typename TOutputImage = TInputImage >
90 class ITK_TEMPLATE_EXPORT InvertIntensityImageFilter:
91  public
92  UnaryFunctorImageFilter< TInputImage, TOutputImage,
93  Functor::InvertIntensityTransform<
94  typename TInputImage::PixelType,
95  typename TOutputImage::PixelType > >
96 {
97 public:
100  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
102  typename TInputImage::PixelType,
103  typename TOutputImage::PixelType > > Superclass;
106 
107  typedef typename TOutputImage::PixelType OutputPixelType;
108  typedef typename TInputImage::PixelType InputPixelType;
110 
112  itkNewMacro(Self);
113 
115  itkTypeMacro(InvertIntensityImageFilter,
117 
119  itkSetMacro(Maximum, InputPixelType);
120  itkGetConstReferenceMacro(Maximum, InputPixelType);
122 
123  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
124 
126  void BeforeThreadedGenerateData() ITK_OVERRIDE;
127 
128 #ifdef ITK_USE_CONCEPT_CHECKING
129  // Begin concept checking
130  itkConceptMacro( InputHasNumericTraitsCheck,
132  // End concept checking
133 #endif
134 
135 protected:
137  virtual ~InvertIntensityImageFilter() ITK_OVERRIDE {}
138 
139 private:
140  ITK_DISALLOW_COPY_AND_ASSIGN(InvertIntensityImageFilter);
141 
143 };
144 } // end namespace itk
145 
146 #ifndef ITK_MANUAL_INSTANTIATION
147 #include "itkInvertIntensityImageFilter.hxx"
148 #endif
149 
150 #endif
bool operator!=(const InvertIntensityTransform &other) const
Base class for all process objects that output image data.
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::InvertIntensityTransform< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
static ITK_CONSTEXPR_FUNC T max(const T &)
Implements pixel-wise generic operation on one image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)
Invert the intensity of an image.
bool operator==(const InvertIntensityTransform &other) const
NumericTraits< InputPixelType >::RealType RealType