DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkStructureTensorImageFilter.hxx
Go to the documentation of this file.
1 
12 #ifndef __itkStructureTensorImageFilter_hxx
13 #define __itkStructureTensorImageFilter_hxx
14 
17 #include "itkUnaryFunctorImageFilter.h"
18 #include "itkFunctors.h"
19 
20 namespace itk
21 {
22 
23 template< class TInputImage, class TOutputImage >
24 StructureTensorImageFilter < TInputImage, TOutputImage >
26 {
27  m_IntensityScale=1.0;
28 }
29 
30 template< class TInputImage, class TOutputImage >
31 typename LightObject::Pointer
34 {
35  typename LightObject::Pointer loPtr = Superclass::InternalClone();
36 
37  typename Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
38  if(rval.IsNull())
39  {
40  itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass()<< " failed.");
41  }
42  rval->m_IntensityScale = m_IntensityScale;
43  return loPtr;
44 }
45 
46 template< class TInputImage, class TOutputImage >
47 void
50 {
51  typename TInputImage::ConstPointer inputPtr = this->GetInput();
52  typename GradientFilterType::Pointer gradientFilter = GradientFilterType::New();
53 
54  if (m_IntensityScale!=1.0)
55  {
57  FunctorType timeFunctor;
58  typedef UnaryFunctorImageFilter<TInputImage, TInputImage, FunctorType> ScaleFilterType;
59  typename ScaleFilterType::Pointer scaleFilter = ScaleFilterType::New();
60  timeFunctor.SetArgument(m_IntensityScale);
61  scaleFilter->SetFunctor(timeFunctor);
62  scaleFilter->SetInput(inputPtr);
63  scaleFilter->Update();
64  gradientFilter->SetInput(scaleFilter->GetOutput());
65  }
66  else
67  gradientFilter->SetInput(inputPtr);
68 
69  gradientFilter->Update();
70 
71  typename TOutputImage::Pointer gradient = gradientFilter->GetOutput();
72 
74  typename OuterProductFilterType::Pointer outproductFilter = OuterProductFilterType::New();
75  outproductFilter->SetInput(gradient);
76  outproductFilter->Update();
77 
78  typename TOutputImage::Pointer out = outproductFilter->GetOutput();
79  this->GraftOutput(out);
80 }
81 
82 
83 }
84 
85 
86 #endif
87 
LightObject::Pointer InternalClone() const ITK_OVERRIDE
Created "06-27-2016.
In each vxoel, multiply the input vector by a matrix.
ImageToImageFilter< TInputImage, TOutputImage > Superclass
virtual const char * GetNameOfClass() const
Run-time type information (and related methods).