ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkRescaleIntensityImageFilter.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 itkRescaleIntensityImageFilter_h
19#define itkRescaleIntensityImageFilter_h
20
22#include "itkMath.h"
23
24namespace itk
25{
26// This functor class applies a linear transformation A.x + B
27// to input values.
28namespace Functor
29{
30template <typename TInput, typename TOutput>
31class ITK_TEMPLATE_EXPORT IntensityLinearTransform
32{
33public:
36 : m_Factor(1.0)
37 , m_Offset(0.0)
38 , m_Maximum(NumericTraits<TOutput>::max())
39 , m_Minimum(NumericTraits<TOutput>::NonpositiveMin())
40 {}
41
43 void
45 {
46 m_Factor = a;
47 }
48 void
50 {
51 m_Offset = b;
52 }
53 void
54 SetMinimum(TOutput min)
55 {
56 m_Minimum = min;
57 }
58 void
59 SetMaximum(TOutput max)
60 {
61 m_Maximum = max;
62 }
63
64 bool
70
72
73 inline TOutput
74 operator()(const TInput & x) const
75 {
76 const RealType value = static_cast<RealType>(x) * m_Factor + m_Offset;
77 auto result = static_cast<TOutput>(value);
78
79 result = (result > m_Maximum) ? m_Maximum : result;
80 result = (result < m_Minimum) ? m_Minimum : result;
81 return result;
82 }
83
84private:
87 TOutput m_Maximum;
88 TOutput m_Minimum;
89};
90} // end namespace Functor
91
131template <typename TInputImage, typename TOutputImage = TInputImage>
132class ITK_TEMPLATE_EXPORT RescaleIntensityImageFilter
134 TInputImage,
135 TOutputImage,
136 Functor::IntensityLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
137{
138public:
139 ITK_DISALLOW_COPY_AND_MOVE(RescaleIntensityImageFilter);
140
144 TInputImage,
145 TOutputImage,
147
150
151 using OutputPixelType = typename TOutputImage::PixelType;
152 using InputPixelType = typename TInputImage::PixelType;
154
156 itkNewMacro(Self);
157
159 itkOverrideGetNameOfClassMacro(RescaleIntensityImageFilter);
160
161 itkSetMacro(OutputMinimum, OutputPixelType);
162 itkSetMacro(OutputMaximum, OutputPixelType);
163 itkGetConstReferenceMacro(OutputMinimum, OutputPixelType);
164 itkGetConstReferenceMacro(OutputMaximum, OutputPixelType);
165
170 itkGetConstReferenceMacro(Scale, RealType);
171 itkGetConstReferenceMacro(Shift, RealType);
176 itkGetConstReferenceMacro(InputMinimum, InputPixelType);
177 itkGetConstReferenceMacro(InputMaximum, InputPixelType);
180 void
182
184 void
185 PrintSelf(std::ostream & os, Indent indent) const override;
186
187 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
188 itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputPixelType>));
189 itkConceptMacro(RealTypeMultiplyOperatorCheck, (Concept::MultiplyOperator<RealType>));
190 itkConceptMacro(RealTypeAdditiveOperatorsCheck, (Concept::AdditiveOperators<RealType>));
191
192protected:
194 ~RescaleIntensityImageFilter() override = default;
195
196private:
199
202
205};
206} // end namespace itk
207
208#ifndef ITK_MANUAL_INSTANTIATION
209# include "itkRescaleIntensityImageFilter.hxx"
210#endif
211
212#endif
typename NumericTraits< TInput >::RealType RealType
bool operator==(const IntensityLinearTransform &other) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(IntensityLinearTransform)
Control indentation during Print() invocation.
Definition itkIndent.h:50
Define additional traits for native types such as int or float.
typename NumericTraits< InputPixelType >::RealType RealType
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::IntensityLinearTransform< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
typename TInputImage::PixelType InputPixelType
void PrintSelf(std::ostream &os, Indent indent) const override
~RescaleIntensityImageFilter() override=default
void BeforeThreadedGenerateData() override
typename TOutputImage::PixelType OutputPixelType
Implements transparent reference counting.
#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:716
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....