ANIMA  4.0
animaFlipTensorImageFilter.hxx
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageRegionConstIterator.h>
4 #include <itkImageRegionIterator.h>
5 
6 namespace anima
7 {
8 
9 template <class TPixelType, unsigned int TImageDimension>
10 void
13 {
14  // Override the method in itkImageSource, so we can set the vector length of
15  // the output itk::VectorImage
16 
17  this->Superclass::GenerateOutputInformation();
18 
19  OutputImageType *output = this->GetOutput();
20  output->SetVectorLength(m_NumberOfComponents);
21 }
22 
23 template <class TPixelType, unsigned int TImageDimension>
24 void
27 {
28  itk::ImageRegionConstIterator<InputImageType> inItr(this->GetInput(), outputRegionForThread);
29  itk::ImageRegionConstIterator<MaskImageType> maskItr(this->GetComputationMask(), outputRegionForThread);
30  itk::ImageRegionIterator<OutputImageType> outItr(this->GetOutput(), outputRegionForThread);
31 
32  OutputPixelType outTensor(6);
33 
34  while (!maskItr.IsAtEnd())
35  {
36  if (maskItr.Get() == 0)
37  {
38  outTensor.Fill(0.0);
39  outItr.Set(outTensor);
40 
41  ++inItr;
42  ++outItr;
43  ++maskItr;
44  continue;
45  }
46 
47  outTensor = inItr.Get();
48 
49  if (m_FlippedAxis == "x")
50  {
51  outTensor[1] *= -1.0;
52  outTensor[3] *= -1.0;
53  }
54  else if (m_FlippedAxis == "y")
55  {
56  outTensor[1] *= -1.0;
57  outTensor[4] *= -1.0;
58  }
59  else if (m_FlippedAxis == "z")
60  {
61  outTensor[3] *= -1.0;
62  outTensor[4] *= -1.0;
63  }
64 
65  outItr.Set(outTensor);
66 
67  this->IncrementNumberOfProcessedPoints();
68  ++inItr;
69  ++outItr;
70  ++maskItr;
71  }
72 }
73 
74 } // end of namespace anima
itk::VectorImage< TPixelType, TImageDimension > OutputImageType
OutputImageType::PixelType OutputPixelType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE
Superclass::OutputImageRegionType OutputImageRegionType