ITK  6.0.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  * 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 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;
41  void
42  SetMaximum(TOutput max)
43  {
44  m_Maximum = max;
45  }
46 
47 
48  bool
49  operator==(const InvertIntensityTransform & other) const
50  {
51  return m_Maximum == other.m_Maximum;
52  }
53 
54  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(InvertIntensityTransform);
55 
56  inline TOutput
57  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 UnaryFunctorImageFilter<
92  TInputImage,
93  TOutputImage,
94  Functor::InvertIntensityTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
95 {
96 public:
97  ITK_DISALLOW_COPY_AND_MOVE(InvertIntensityImageFilter);
98 
102  TInputImage,
103  TOutputImage,
107 
108  using OutputPixelType = typename TOutputImage::PixelType;
109  using InputPixelType = typename TInputImage::PixelType;
111 
113  itkNewMacro(Self);
114 
116  itkOverrideGetNameOfClassMacro(InvertIntensityImageFilter);
117 
119  itkSetMacro(Maximum, InputPixelType);
120  itkGetConstReferenceMacro(Maximum, InputPixelType);
123  void
124  PrintSelf(std::ostream & os, Indent indent) const override;
125 
127  void
128  BeforeThreadedGenerateData() override;
129 
130 #ifdef ITK_USE_CONCEPT_CHECKING
131  // Begin concept checking
132  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
133  // End concept checking
134 #endif
135 
136 protected:
138  ~InvertIntensityImageFilter() override = default;
139 
140 private:
141  InputPixelType m_Maximum{};
142 };
143 } // end namespace itk
144 
145 #ifndef ITK_MANUAL_INSTANTIATION
146 # include "itkInvertIntensityImageFilter.hxx"
147 #endif
148 
149 #endif
itk::Functor::InvertIntensityTransform::operator==
bool operator==(const InvertIntensityTransform &other) const
Definition: itkInvertIntensityImageFilter.h:49
itkUnaryFunctorImageFilter.h
itk::InvertIntensityImageFilter
Invert the intensity of an image.
Definition: itkInvertIntensityImageFilter.h:90
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:716
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:65
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:110
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:60
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:169
itk::InvertIntensityImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkInvertIntensityImageFilter.h:108
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:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::InvertIntensityImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkInvertIntensityImageFilter.h:109
itk::Functor::InvertIntensityTransform::operator()
TOutput operator()(const TInput &x) const
Definition: itkInvertIntensityImageFilter.h:57
itk::Functor::InvertIntensityTransform::InvertIntensityTransform
InvertIntensityTransform()
Definition: itkInvertIntensityImageFilter.h:37