DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkOuterProductVectorImageFilter.h
Go to the documentation of this file.
1 
13 #ifndef __itkOuterProductVectorImageFilter_h
14 #define __itkOuterProductVectorImageFilter_h
15 
16 #include "itkUnaryFunctorImageFilter.h"
17 #include "utlNDArray.h"
18 
19 namespace itk
20 {
31 namespace Functor
32 {
33 template <class TInput, class TOutput=TInput>
35 {
36 public:
37  typedef typename TInput::ValueType InputValueType;
38  typedef typename TOutput::ValueType OutputValueType;
40 
42  {
43  }
44 
46  {
47  }
48 
49  bool operator!=(const OuterProduct & other) const
50  {
51  return !( *this == other );
52  }
53 
54  bool operator==(const OuterProduct & other) const
55  {
56  return true;
57  }
58 
59  inline TOutput operator()(const TInput & A)
60  {
61  int N = A.GetSize();
62  TOutput out;
63  out.SetSize( N*N );
64  int kk=0;
65  for ( int i = 0; i < N; ++i )
66  {
67  for ( int j = 0; j < N; ++j )
68  {
69  out[kk] = A[i]*A[j];
70  kk++;
71  }
72  }
73 
74  return out;
75  }
76 
77 };
78 }
79 
80 template <class TInputImage, class TOutputImage=TInputImage>
82  public
83  UnaryFunctorImageFilter<TInputImage, TOutputImage,
84  Functor::OuterProduct<
85  typename TInputImage::PixelType,
86  typename TOutputImage::PixelType> >
87 {
88 public:
91  typedef UnaryFunctorImageFilter<
92  TInputImage, TOutputImage,
94  typename TInputImage::PixelType, typename TOutputImage::PixelType> > Superclass;
95 
96  typedef SmartPointer<Self> Pointer;
97  typedef SmartPointer<const Self> ConstPointer;
98 
100  itkNewMacro( Self );
101 
103  itkTypeMacro( OuterProductVectorImageFilter, UnaryFunctorImageFilter );
104 
105 protected:
107  {
108  }
109 
111  {
112  }
113 
115  {
116  Superclass::GenerateOutputInformation();
117  typename TInputImage::ConstPointer inputPtr = this->GetInput();
118  typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
119  int N = inputPtr->GetNumberOfComponentsPerPixel();
120  outputPtr->SetNumberOfComponentsPerPixel(N*N);
121  }
122 
123 
124 private:
125  OuterProductVectorImageFilter(const Self &); // purposely not implemented
126  void operator=(const Self &); // purposely not implemented
127 };
128 } // end namespace itk
129 
130 
131 #endif
NDArray is a N-Dimensional array class (row-major, c version)
Definition: utlFunctors.h:131
bool operator!=(const OuterProduct &other) const
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::OuterProduct< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
In each vxoel, multiply the input vector by a matrix.
bool operator==(const OuterProduct &other) const