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:
42
44 void
46 {
47 m_Factor = a;
48 }
49 void
51 {
52 m_Offset = b;
53 }
54 void
55 SetMinimum(TOutput min)
56 {
57 m_Minimum = min;
58 }
59 void
60 SetMaximum(TOutput max)
61 {
62 m_Maximum = max;
63 }
64
65 bool
71
73
74 inline TOutput
75 operator()(const TInput & x) const
76 {
77 const RealType value = static_cast<RealType>(x) * m_Factor + m_Offset;
78 auto result = static_cast<TOutput>(value);
79
80 result = (result > m_Maximum) ? m_Maximum : result;
81 result = (result < m_Minimum) ? m_Minimum : result;
82 return result;
83 }
84
85private:
88 TOutput m_Maximum;
89 TOutput m_Minimum;
90};
91} // end namespace Functor
92
132template <typename TInputImage, typename TOutputImage = TInputImage>
133class ITK_TEMPLATE_EXPORT RescaleIntensityImageFilter
135 TInputImage,
136 TOutputImage,
137 Functor::IntensityLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
138{
139public:
140 ITK_DISALLOW_COPY_AND_MOVE(RescaleIntensityImageFilter);
142
146 TInputImage,
147 TOutputImage,
149
152
153 using OutputPixelType = typename TOutputImage::PixelType;
154 using InputPixelType = typename TInputImage::PixelType;
156
158 itkNewMacro(Self);
159
161 itkOverrideGetNameOfClassMacro(RescaleIntensityImageFilter);
162
163 itkSetMacro(OutputMinimum, OutputPixelType);
164 itkSetMacro(OutputMaximum, OutputPixelType);
165 itkGetConstReferenceMacro(OutputMinimum, OutputPixelType);
166 itkGetConstReferenceMacro(OutputMaximum, OutputPixelType);
167
171 itkGetConstReferenceMacro(Scale, RealType);
172 itkGetConstReferenceMacro(Shift, RealType);
174
177 itkGetConstReferenceMacro(InputMinimum, InputPixelType);
178 itkGetConstReferenceMacro(InputMaximum, InputPixelType);
180
182 void
184
186 void
187 PrintSelf(std::ostream & os, Indent indent) const override;
188
189 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
190 itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputPixelType>));
191 itkConceptMacro(RealTypeMultiplyOperatorCheck, (Concept::MultiplyOperator<RealType>));
192 itkConceptMacro(RealTypeAdditiveOperatorsCheck, (Concept::AdditiveOperators<RealType>));
193
194protected:
196 ~RescaleIntensityImageFilter() override = default;
197
198private:
201
204
207};
208} // end namespace itk
209
210#ifndef ITK_MANUAL_INSTANTIATION
211# include "itkRescaleIntensityImageFilter.hxx"
212#endif
213
214#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
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
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:720
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....