ITK  5.0.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:
38  ~InvertIntensityTransform() = default;
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  auto 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:
98  ITK_DISALLOW_COPY_AND_ASSIGN(InvertIntensityImageFilter);
99 
102  using Superclass = UnaryFunctorImageFilter< TInputImage, TOutputImage,
104  typename TInputImage::PixelType,
105  typename TOutputImage::PixelType > >;
108 
109  using OutputPixelType = typename TOutputImage::PixelType;
110  using InputPixelType = typename TInputImage::PixelType;
112 
114  itkNewMacro(Self);
115 
117  itkTypeMacro(InvertIntensityImageFilter,
119 
121  itkSetMacro(Maximum, InputPixelType);
122  itkGetConstReferenceMacro(Maximum, InputPixelType);
124 
125  void PrintSelf(std::ostream & os, Indent indent) const override;
126 
128  void BeforeThreadedGenerateData() override;
129 
130 #ifdef ITK_USE_CONCEPT_CHECKING
131  // Begin concept checking
132  itkConceptMacro( InputHasNumericTraitsCheck,
134  // End concept checking
135 #endif
136 
137 protected:
139  ~InvertIntensityImageFilter() override = default;
140 
141 private:
143 };
144 } // end namespace itk
145 
146 #ifndef ITK_MANUAL_INSTANTIATION
147 #include "itkInvertIntensityImageFilter.hxx"
148 #endif
149 
150 #endif
Define numeric traits for std::vector.
bool operator!=(const InvertIntensityTransform &other) const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename TInputImage::PixelType InputPixelType
Base class for all process objects that output image data.
typename TOutputImage::PixelType OutputPixelType
Implements pixel-wise generic operation on one image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename NumericTraits< InputPixelType >::RealType RealType
#define itkConceptMacro(name, concept)
Invert the intensity of an image.
bool operator==(const InvertIntensityTransform &other) const