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
24namespace itk
25{
26// This functor class applies a scaling transformation A.x
27// to input values.
28namespace Functor
29{
30template <typename TInput, typename TOutput>
31class ITK_TEMPLATE_EXPORT VectorMagnitudeLinearTransform
32{
33public:
36 : m_Factor(0.0)
37 {}
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
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
67private:
69};
70} // end namespace Functor
71
95template <typename TInputImage, typename TOutputImage = TInputImage>
96class ITK_TEMPLATE_EXPORT VectorRescaleIntensityImageFilter
98 TInputImage,
99 TOutputImage,
100 Functor::VectorMagnitudeLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
101{
102public:
103 ITK_DISALLOW_COPY_AND_MOVE(VectorRescaleIntensityImageFilter);
104
108 TInputImage,
109 TOutputImage,
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);
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
159protected:
161 ~VectorRescaleIntensityImageFilter() override = default;
162
163private:
164 InputRealType m_Scale{};
165 InputRealType m_Shift{};
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
typename NumericTraits< typename TInput::ValueType >::RealType RealType
bool operator==(const VectorMagnitudeLinearTransform &other) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(VectorMagnitudeLinearTransform)
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Implements pixel-wise generic operation on one image.
Applies a linear transformation to the magnitude of pixel vectors in a vector Image.
typename NumericTraits< OutputValueType >::RealType OutputRealType
typename NumericTraits< InputValueType >::RealType InputRealType
#define itkConceptMacro(name, concept)
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
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....