ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVectorRescaleIntensityImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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:
35  VectorMagnitudeLinearTransform() : m_Factor(0.0) {}
36  ~VectorMagnitudeLinearTransform() = default;
37  void SetFactor(RealType a) { m_Factor = a; }
38  static constexpr unsigned int VectorDimension = TInput::Dimension;
39  bool operator!=(const VectorMagnitudeLinearTransform & other) const
40  {
41  if ( Math::NotExactlyEquals(m_Factor, other.m_Factor) )
42  {
43  return true;
44  }
45  return false;
46  }
47 
48  bool operator==(const VectorMagnitudeLinearTransform & other) const
49  {
50  return !( *this != other );
51  }
52 
53  inline TOutput operator()(const TInput & x) const
54  {
55  TOutput result;
56 
57  for ( unsigned int i = 0; i < VectorDimension; i++ )
58  {
59  const RealType scaledComponent = static_cast< RealType >( x[i] ) * m_Factor;
60  result[i] = static_cast< typename TOutput::ValueType >( scaledComponent );
61  }
62  return result;
63  }
64 
65 private:
67 };
68 } // end namespace Functor
69 
92 template< typename TInputImage, typename TOutputImage = TInputImage >
93 class ITK_TEMPLATE_EXPORT VectorRescaleIntensityImageFilter:
94  public
95  UnaryFunctorImageFilter< TInputImage, TOutputImage,
96  Functor::VectorMagnitudeLinearTransform<
97  typename TInputImage::PixelType,
98  typename TOutputImage::PixelType > >
99 {
100 public:
101  ITK_DISALLOW_COPY_AND_ASSIGN(VectorRescaleIntensityImageFilter);
102 
106  TInputImage, TOutputImage,
108  typename TInputImage::PixelType,
109  typename TOutputImage::PixelType > >;
110 
113 
114  using OutputPixelType = typename TOutputImage::PixelType;
115  using InputPixelType = typename TInputImage::PixelType;
116  using InputValueType = typename InputPixelType::ValueType;
117  using OutputValueType = typename OutputPixelType::ValueType;
120 
121  using InputImageType = typename Superclass::InputImageType;
122  using InputImagePointer = typename Superclass::InputImagePointer;
123 
126 
128  itkNewMacro(Self);
129 
130  itkSetMacro(OutputMaximumMagnitude, OutputRealType);
131  itkGetConstReferenceMacro(OutputMaximumMagnitude, OutputRealType);
132 
136  itkGetConstReferenceMacro(Scale, InputRealType);
137  itkGetConstReferenceMacro(Shift, InputRealType);
139 
142  itkGetConstReferenceMacro(InputMaximumMagnitude, InputRealType);
143 
145  void BeforeThreadedGenerateData() override;
146 
147  void PrintSelf(std::ostream & os, Indent indent) const override;
148 
149 #ifdef ITK_USE_CONCEPT_CHECKING
150  // Begin concept checking
151  itkConceptMacro( InputHasNumericTraitsCheck,
153  itkConceptMacro( OutputHasNumericTraitsCheck,
155  // End concept checking
156 #endif
157 
158 protected:
160  ~VectorRescaleIntensityImageFilter() override = default;
161 
162 private:
165 
168 };
169 } // end namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkVectorRescaleIntensityImageFilter.hxx"
173 #endif
174 
175 #endif
Define numeric traits for std::vector.
typename NumericTraits< OutputValueType >::RealType OutputRealType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename NumericTraits< InputValueType >::RealType InputRealType
typename InputImageType::Pointer InputImagePointer
bool operator==(const VectorMagnitudeLinearTransform &other) const
typename NumericTraits< typename TInputImage::PixelType::ValueType >::RealType RealType
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
Implements pixel-wise generic operation on one image.
bool operator!=(const VectorMagnitudeLinearTransform &other) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Applies a linear transformation to the magnitude of pixel vectors in a vector Image.
#define itkConceptMacro(name, concept)