ITK  5.2.0
Insight Toolkit
itkInvertIntensityImageFilter.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  * 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
42  SetMaximum(TOutput max)
43  {
44  m_Maximum = max;
45  }
46 
47  bool
48  operator!=(const InvertIntensityTransform & other) const
49  {
50  if (m_Maximum != other.m_Maximum)
51  {
52  return true;
53  }
54  return false;
55  }
56 
57  bool
58  operator==(const InvertIntensityTransform & other) const
59  {
60  return !(*this != other);
61  }
62 
63  inline TOutput
64  operator()(const TInput & x) const
65  {
66  auto result = static_cast<TOutput>(m_Maximum - x);
67 
68  return result;
69  }
70 
71 private:
72  TInput m_Maximum;
73 };
74 } // end namespace Functor
75 
96 template <typename TInputImage, typename TOutputImage = TInputImage>
97 class ITK_TEMPLATE_EXPORT InvertIntensityImageFilter
98  : public UnaryFunctorImageFilter<
99  TInputImage,
100  TOutputImage,
101  Functor::InvertIntensityTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
102 {
103 public:
104  ITK_DISALLOW_COPY_AND_ASSIGN(InvertIntensityImageFilter);
105 
109  TInputImage,
110  TOutputImage,
114 
115  using OutputPixelType = typename TOutputImage::PixelType;
116  using InputPixelType = typename TInputImage::PixelType;
118 
120  itkNewMacro(Self);
121 
124 
126  itkSetMacro(Maximum, InputPixelType);
127  itkGetConstReferenceMacro(Maximum, InputPixelType);
129 
130  void
131  PrintSelf(std::ostream & os, Indent indent) const override;
132 
134  void
135  BeforeThreadedGenerateData() override;
136 
137 #ifdef ITK_USE_CONCEPT_CHECKING
138  // Begin concept checking
139  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
140  // End concept checking
141 #endif
142 
143 protected:
145  ~InvertIntensityImageFilter() override = default;
146 
147 private:
149 };
150 } // end namespace itk
151 
152 #ifndef ITK_MANUAL_INSTANTIATION
153 # include "itkInvertIntensityImageFilter.hxx"
154 #endif
155 
156 #endif
itk::Functor::InvertIntensityTransform::operator==
bool operator==(const InvertIntensityTransform &other) const
Definition: itkInvertIntensityImageFilter.h:58
itkUnaryFunctorImageFilter.h
itk::InvertIntensityImageFilter
Invert the intensity of an image.
Definition: itkInvertIntensityImageFilter.h:97
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:712
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::Functor::InvertIntensityTransform::m_Maximum
TInput m_Maximum
Definition: itkInvertIntensityImageFilter.h:72
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::InvertIntensityTransform
Definition: itkInvertIntensityImageFilter.h:33
itk::InvertIntensityImageFilter::RealType
typename NumericTraits< InputPixelType >::RealType RealType
Definition: itkInvertIntensityImageFilter.h:117
itk::Functor::InvertIntensityTransform::SetMaximum
void SetMaximum(TOutput max)
Definition: itkInvertIntensityImageFilter.h:42
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:167
itk::InvertIntensityImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkInvertIntensityImageFilter.h:115
itk::Functor::InvertIntensityTransform< TInputImage::PixelType, TOutputImage::PixelType >::RealType
typename NumericTraits< TInputImage::PixelType >::RealType RealType
Definition: itkInvertIntensityImageFilter.h:36
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::InvertIntensityImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkInvertIntensityImageFilter.h:116
itk::InvertIntensityImageFilter::m_Maximum
InputPixelType m_Maximum
Definition: itkInvertIntensityImageFilter.h:148
itk::Functor::InvertIntensityTransform::operator()
TOutput operator()(const TInput &x) const
Definition: itkInvertIntensityImageFilter.h:64
itk::Functor::InvertIntensityTransform::InvertIntensityTransform
InvertIntensityTransform()
Definition: itkInvertIntensityImageFilter.h:37
itk::Functor::InvertIntensityTransform::operator!=
bool operator!=(const InvertIntensityTransform &other) const
Definition: itkInvertIntensityImageFilter.h:48