Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkCartesianToPolarVectorImageFilter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __itkCartesianToPolarVectorImageFilter_h
18 #define __itkCartesianToPolarVectorImageFilter_h
19 
20 #include "itkUnaryFunctorImageFilter.h"
21 
22 #define _USE_MATH_DEFINES
23 #include <math.h>
24 
25 #define C2P_PI M_PI
26 
27 namespace itk
28 {
29 
30  namespace Functor {
31 
32  template< typename TInput, typename TOutput, bool symmetric >
34  {
35  public:
38  bool operator!=( const CartesianToPolarFunction & ) const
39  {
40  return false;
41  }
42  bool operator==( const CartesianToPolarFunction & other ) const
43  {
44  return !(*this != other);
45  }
46  inline TOutput operator()( const TInput & x )
47  {
48 
49  TOutput opoint;
50 
51  if(x[0] || x[1] || x[2])
52  {
53  opoint[0] = sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] );
54  opoint[1] = atan2( x[1], x[0] );
55  opoint[2] = 0.5*C2P_PI - atan( x[2] / sqrt( x[0] * x[0] + x[1] * x[1] ) );
56 
57  if(symmetric && opoint[1]>C2P_PI)
58  {
59  opoint[1] = opoint[1] - C2P_PI;
60  }
61  }
62  else
63  {
64  opoint[0] = 0;
65  opoint[1] = 0;
66  opoint[2] = 0;
67  }
68  return opoint;
69 
70  }
71  };
72 
73  } // end namespace functor
74 
75 
79  template <typename TInputImage, typename TOutputImage, bool symmetric>
81  public
82  UnaryFunctorImageFilter<TInputImage,TOutputImage,
83  Functor::CartesianToPolarFunction<
84  typename TInputImage::PixelType,
85  typename TOutputImage::PixelType, symmetric> >
86  {
87  public:
90  typedef UnaryFunctorImageFilter<
91  TInputImage,TOutputImage,
93  typename TInputImage::PixelType,
94  typename TOutputImage::PixelType, symmetric > > Superclass;
97 
98  typedef typename Superclass::OutputImageType OutputImageType;
100  typedef typename TInputImage::PixelType InputPixelType;
102 
104  itkTypeMacro( CartesianToPolarVectorImageFilter, UnaryFunctorImageFilter );
105 
107  itkFactorylessNewMacro(Self)
108  itkCloneMacro(Self)
109 
111  void PrintSelf(std::ostream& os, Indent indent) const
112  { this->Superclass::PrintSelf( os, indent ); }
113 
114 #ifdef ITK_USE_CONCEPT_CHECKING
115 
116  itkConceptMacro(InputHasNumericTraitsCheck,
117  (Concept::HasNumericTraits<InputValueType>));
119 #endif
120 
121  protected:
124 
125  private:
126  CartesianToPolarVectorImageFilter(const Self&); //purposely not implemented
127  void operator=(const Self&); //purposely not implemented
128 
129  };
130 
131 
132 
133 } // end namespace itk
134 
135 #endif // __itkCartesianToPolarVectorImageFilter_h
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::CartesianToPolarFunction< typename TInputImage::PixelType, typename TOutputImage::PixelType, symmetric > > Superclass
STL namespace.
ValueType
Type of the value held by a Value object.
Definition: jsoncpp.h:345
void PrintSelf(std::ostream &os, Indent indent) const
bool operator==(const CartesianToPolarFunction &other) const
bool operator!=(const CartesianToPolarFunction &) const
unsigned short PixelType