ANIMA  4.0
animaGeneralizedFAImageFilter.hxx
Go to the documentation of this file.
1 #pragma once
2 
4 #include <itkImageRegionConstIterator.h>
5 #include <itkImageRegionConstIteratorWithIndex.h>
6 #include <itkImageRegionIterator.h>
7 
8 namespace anima
9 {
10 template <typename TInputPixelType>
11 void
14 {
15  typedef itk::ImageRegionConstIteratorWithIndex <TInputImage> InputIteratorType;
16  typedef itk::ImageRegionIterator <TOutputImage> OutputIteratorType;
17 
18  InputIteratorType inputIt(this->GetInput(),outputRegionForThread);
19  OutputIteratorType outIt(this->GetOutput(),outputRegionForThread);
20 
21  unsigned int vdim = this->GetInput()->GetNumberOfComponentsPerPixel();
22  InputImagePixel tmpCoefs;
23 
24  while(!inputIt.IsAtEnd())
25  {
26  tmpCoefs = inputIt.Get();
27 
28  if (isZero(tmpCoefs))
29  {
30  ++inputIt;
31  outIt.Set(0);
32  ++outIt;
33  continue;
34  }
35 
36  double sumSquares = 0;
37  for (unsigned int i = 0;i < vdim;++i)
38  sumSquares += tmpCoefs[i]*tmpCoefs[i];
39 
40  outIt.Set(sqrt(1 - tmpCoefs[0]*tmpCoefs[0]/sumSquares));
41  ++inputIt;
42  ++outIt;
43  }
44 }
45 
46 } // end of namespace anima
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE
Superclass::OutputImageRegionType OutputImageRegionType