ITK  6.0.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  * 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 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 
46  bool
48  {
49  return Math::ExactlyEquals(m_Factor, other.m_Factor);
50  }
51 
52  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(VectorMagnitudeLinearTransform);
53 
54  inline TOutput
55  operator()(const TInput & x) const
56  {
57  TOutput result;
58 
59  for (unsigned int i = 0; i < VectorDimension; ++i)
60  {
61  const RealType scaledComponent = static_cast<RealType>(x[i]) * m_Factor;
62  result[i] = static_cast<typename TOutput::ValueType>(scaledComponent);
63  }
64  return result;
65  }
66 
67 private:
69 };
70 } // end namespace Functor
71 
95 template <typename TInputImage, typename TOutputImage = TInputImage>
96 class ITK_TEMPLATE_EXPORT VectorRescaleIntensityImageFilter
97  : public UnaryFunctorImageFilter<
98  TInputImage,
99  TOutputImage,
100  Functor::VectorMagnitudeLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
101 {
102 public:
103  ITK_DISALLOW_COPY_AND_MOVE(VectorRescaleIntensityImageFilter);
104 
108  TInputImage,
109  TOutputImage,
111 
114 
115  using OutputPixelType = typename TOutputImage::PixelType;
116  using InputPixelType = typename TInputImage::PixelType;
117  using InputValueType = typename InputPixelType::ValueType;
118  using OutputValueType = typename OutputPixelType::ValueType;
121 
122  using typename Superclass::InputImageType;
123  using typename Superclass::InputImagePointer;
124 
126  itkOverrideGetNameOfClassMacro(VectorRescaleIntensityImageFilter);
127 
129  itkNewMacro(Self);
130 
131  itkSetMacro(OutputMaximumMagnitude, OutputRealType);
132  itkGetConstReferenceMacro(OutputMaximumMagnitude, OutputRealType);
133 
137  itkGetConstReferenceMacro(Scale, InputRealType);
138  itkGetConstReferenceMacro(Shift, InputRealType);
143  itkGetConstReferenceMacro(InputMaximumMagnitude, InputRealType);
144 
146  void
147  BeforeThreadedGenerateData() override;
148 
149  void
150  PrintSelf(std::ostream & os, Indent indent) const override;
151 
152 #ifdef ITK_USE_CONCEPT_CHECKING
153  // Begin concept checking
154  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
155  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputValueType>));
156  // End concept checking
157 #endif
158 
159 protected:
161  ~VectorRescaleIntensityImageFilter() override = default;
162 
163 private:
164  InputRealType m_Scale{};
165  InputRealType m_Shift{};
166 
167  InputRealType m_InputMaximumMagnitude{};
168  OutputRealType m_OutputMaximumMagnitude{};
169 };
170 } // end namespace itk
171 
172 #ifndef ITK_MANUAL_INSTANTIATION
173 # include "itkVectorRescaleIntensityImageFilter.hxx"
174 #endif
175 
176 #endif
itkUnaryFunctorImageFilter.h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:716
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::VectorRescaleIntensityImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkVectorRescaleIntensityImageFilter.h:116
itk::Functor::VectorMagnitudeLinearTransform::m_Factor
RealType m_Factor
Definition: itkVectorRescaleIntensityImageFilter.h:68
itk::Math::ExactlyEquals
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potentially different types.
Definition: itkMath.h:722
itk::VectorRescaleIntensityImageFilter::OutputValueType
typename OutputPixelType::ValueType OutputValueType
Definition: itkVectorRescaleIntensityImageFilter.h:118
itk::Functor::VectorMagnitudeLinearTransform::VectorMagnitudeLinearTransform
VectorMagnitudeLinearTransform()
Definition: itkVectorRescaleIntensityImageFilter.h:35
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VectorRescaleIntensityImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkVectorRescaleIntensityImageFilter.h:115
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::VectorMagnitudeLinearTransform::operator==
bool operator==(const VectorMagnitudeLinearTransform &other) const
Definition: itkVectorRescaleIntensityImageFilter.h:47
itk::VectorRescaleIntensityImageFilter
Applies a linear transformation to the magnitude of pixel vectors in a vector Image.
Definition: itkVectorRescaleIntensityImageFilter.h:96
itk::Functor::VectorMagnitudeLinearTransform::SetFactor
void SetFactor(RealType a)
Definition: itkVectorRescaleIntensityImageFilter.h:40
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::Functor::VectorMagnitudeLinearTransform::operator()
TOutput operator()(const TInput &x) const
Definition: itkVectorRescaleIntensityImageFilter.h:55
itk::VectorRescaleIntensityImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkVectorRescaleIntensityImageFilter.h:117
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::VectorRescaleIntensityImageFilter::InputRealType
typename NumericTraits< InputValueType >::RealType InputRealType
Definition: itkVectorRescaleIntensityImageFilter.h:119
itk::VectorRescaleIntensityImageFilter::OutputRealType
typename NumericTraits< OutputValueType >::RealType OutputRealType
Definition: itkVectorRescaleIntensityImageFilter.h:120
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