ITK  4.13.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) {}
37  void SetFactor(RealType a) { m_Factor = a; }
38  itkStaticConstMacro(VectorDimension, unsigned int, 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:
103  typedef UnaryFunctorImageFilter<
104  TInputImage, TOutputImage,
106  typename TInputImage::PixelType,
107  typename TOutputImage::PixelType > > Superclass;
108 
111 
112  typedef typename TOutputImage::PixelType OutputPixelType;
113  typedef typename TInputImage::PixelType InputPixelType;
114  typedef typename InputPixelType::ValueType InputValueType;
115  typedef typename OutputPixelType::ValueType OutputValueType;
118 
119  typedef typename Superclass::InputImageType InputImageType;
120  typedef typename Superclass::InputImagePointer InputImagePointer;
121 
124 
126  itkNewMacro(Self);
127 
128  itkSetMacro(OutputMaximumMagnitude, OutputRealType);
129  itkGetConstReferenceMacro(OutputMaximumMagnitude, OutputRealType);
130 
134  itkGetConstReferenceMacro(Scale, InputRealType);
135  itkGetConstReferenceMacro(Shift, InputRealType);
137 
140  itkGetConstReferenceMacro(InputMaximumMagnitude, InputRealType);
141 
143  void BeforeThreadedGenerateData() ITK_OVERRIDE;
144 
145  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
146 
147 #ifdef ITK_USE_CONCEPT_CHECKING
148  // Begin concept checking
149  itkConceptMacro( InputHasNumericTraitsCheck,
151  itkConceptMacro( OutputHasNumericTraitsCheck,
153  // End concept checking
154 #endif
155 
156 protected:
158  virtual ~VectorRescaleIntensityImageFilter() ITK_OVERRIDE {}
159 
160 private:
161  ITK_DISALLOW_COPY_AND_ASSIGN(VectorRescaleIntensityImageFilter);
162 
165 
168 };
169 } // end namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkVectorRescaleIntensityImageFilter.hxx"
173 #endif
174 
175 #endif
NumericTraits< typename TInput::ValueType >::RealType RealType
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::VectorMagnitudeLinearTransform< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
NumericTraits< OutputValueType >::RealType OutputRealType
Base class for all process objects that output image data.
bool operator==(const VectorMagnitudeLinearTransform &other) const
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:721
Implements pixel-wise generic operation on one image.
bool operator!=(const VectorMagnitudeLinearTransform &other) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
NumericTraits< InputValueType >::RealType InputRealType
Applies a linear transformation to the magnitude of pixel vectors in a vector Image.
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)