ITK  5.2.0
Insight Toolkit
itkVectorRescaleIntensityImageFilter.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 itkVectorRescaleIntensityImageFilter_h
19 #define itkVectorRescaleIntensityImageFilter_h
20 
21 #include "itkMath.h"
23 
24 namespace itk
25 {
26 // This functor class applies a scaling transformation A.x
27 // to input values.
28 namespace Functor
29 {
30 template <typename TInput, typename TOutput>
31 class ITK_TEMPLATE_EXPORT VectorMagnitudeLinearTransform
32 {
33 public:
36  : m_Factor(0.0)
37  {}
38  ~VectorMagnitudeLinearTransform() = default;
39  void
41  {
42  m_Factor = a;
43  }
44  static constexpr unsigned int VectorDimension = TInput::Dimension;
45  bool
47  {
48  if (Math::NotExactlyEquals(m_Factor, other.m_Factor))
49  {
50  return true;
51  }
52  return false;
53  }
54 
55  bool
57  {
58  return !(*this != other);
59  }
60 
61  inline TOutput
62  operator()(const TInput & x) const
63  {
64  TOutput result;
65 
66  for (unsigned int i = 0; i < VectorDimension; i++)
67  {
68  const RealType scaledComponent = static_cast<RealType>(x[i]) * m_Factor;
69  result[i] = static_cast<typename TOutput::ValueType>(scaledComponent);
70  }
71  return result;
72  }
73 
74 private:
76 };
77 } // end namespace Functor
78 
102 template <typename TInputImage, typename TOutputImage = TInputImage>
103 class ITK_TEMPLATE_EXPORT VectorRescaleIntensityImageFilter
104  : public UnaryFunctorImageFilter<
105  TInputImage,
106  TOutputImage,
107  Functor::VectorMagnitudeLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
108 {
109 public:
110  ITK_DISALLOW_COPY_AND_MOVE(VectorRescaleIntensityImageFilter);
111 
115  TInputImage,
116  TOutputImage,
118 
121 
122  using OutputPixelType = typename TOutputImage::PixelType;
123  using InputPixelType = typename TInputImage::PixelType;
124  using InputValueType = typename InputPixelType::ValueType;
125  using OutputValueType = typename OutputPixelType::ValueType;
128 
129  using InputImageType = typename Superclass::InputImageType;
130  using InputImagePointer = typename Superclass::InputImagePointer;
131 
134 
136  itkNewMacro(Self);
137 
138  itkSetMacro(OutputMaximumMagnitude, OutputRealType);
139  itkGetConstReferenceMacro(OutputMaximumMagnitude, OutputRealType);
140 
144  itkGetConstReferenceMacro(Scale, InputRealType);
145  itkGetConstReferenceMacro(Shift, InputRealType);
147 
150  itkGetConstReferenceMacro(InputMaximumMagnitude, InputRealType);
151 
153  void
154  BeforeThreadedGenerateData() override;
155 
156  void
157  PrintSelf(std::ostream & os, Indent indent) const override;
158 
159 #ifdef ITK_USE_CONCEPT_CHECKING
160  // Begin concept checking
161  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
162  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputValueType>));
163  // End concept checking
164 #endif
165 
166 protected:
168  ~VectorRescaleIntensityImageFilter() override = default;
169 
170 private:
173 
176 };
177 } // end namespace itk
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 # include "itkVectorRescaleIntensityImageFilter.hxx"
181 #endif
182 
183 #endif
itkUnaryFunctorImageFilter.h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:714
itk::VectorRescaleIntensityImageFilter::m_OutputMaximumMagnitude
OutputRealType m_OutputMaximumMagnitude
Definition: itkVectorRescaleIntensityImageFilter.h:175
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::VectorRescaleIntensityImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkVectorRescaleIntensityImageFilter.h:123
itk::Functor::VectorMagnitudeLinearTransform::operator!=
bool operator!=(const VectorMagnitudeLinearTransform &other) const
Definition: itkVectorRescaleIntensityImageFilter.h:46
itk::VectorRescaleIntensityImageFilter::m_InputMaximumMagnitude
InputRealType m_InputMaximumMagnitude
Definition: itkVectorRescaleIntensityImageFilter.h:174
itk::Functor::VectorMagnitudeLinearTransform::m_Factor
RealType m_Factor
Definition: itkVectorRescaleIntensityImageFilter.h:75
itk::VectorRescaleIntensityImageFilter::OutputValueType
typename OutputPixelType::ValueType OutputValueType
Definition: itkVectorRescaleIntensityImageFilter.h:125
itk::Functor::VectorMagnitudeLinearTransform::VectorMagnitudeLinearTransform
VectorMagnitudeLinearTransform()
Definition: itkVectorRescaleIntensityImageFilter.h:35
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Math::NotExactlyEquals
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:733
itk::VectorRescaleIntensityImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkVectorRescaleIntensityImageFilter.h:122
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::Functor::VectorMagnitudeLinearTransform::operator==
bool operator==(const VectorMagnitudeLinearTransform &other) const
Definition: itkVectorRescaleIntensityImageFilter.h:56
itk::VectorRescaleIntensityImageFilter::m_Shift
InputRealType m_Shift
Definition: itkVectorRescaleIntensityImageFilter.h:172
itk::VectorRescaleIntensityImageFilter
Applies a linear transformation to the magnitude of pixel vectors in a vector Image.
Definition: itkVectorRescaleIntensityImageFilter.h:103
itk::Functor::VectorMagnitudeLinearTransform::SetFactor
void SetFactor(RealType a)
Definition: itkVectorRescaleIntensityImageFilter.h:40
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::Functor::VectorMagnitudeLinearTransform::operator()
TOutput operator()(const TInput &x) const
Definition: itkVectorRescaleIntensityImageFilter.h:62
itk::VectorRescaleIntensityImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkVectorRescaleIntensityImageFilter.h:124
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
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::VectorRescaleIntensityImageFilter::InputRealType
typename NumericTraits< InputValueType >::RealType InputRealType
Definition: itkVectorRescaleIntensityImageFilter.h:126
itk::VectorRescaleIntensityImageFilter::m_Scale
InputRealType m_Scale
Definition: itkVectorRescaleIntensityImageFilter.h:171
itk::VectorRescaleIntensityImageFilter::OutputRealType
typename NumericTraits< OutputValueType >::RealType OutputRealType
Definition: itkVectorRescaleIntensityImageFilter.h:127
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::Functor::VectorMagnitudeLinearTransform< TInputImage::PixelType, TOutputImage::PixelType >::RealType
typename NumericTraits< typename TInputImage::PixelType ::ValueType >::RealType RealType
Definition: itkVectorRescaleIntensityImageFilter.h:34
itkMath.h
itk::Functor::VectorMagnitudeLinearTransform
Definition: itkVectorRescaleIntensityImageFilter.h:31