5 #include <itkImageRegionConstIterator.h> 6 #include <itkImageRegionIterator.h> 11 template <
typename TPixelType,
unsigned int Dimension>
13 SVFLieBracketImageFilter <TPixelType, Dimension>
14 ::BeforeThreadedGenerateData()
16 this->Superclass::BeforeThreadedGenerateData();
20 if (m_FirstFieldJacobian.IsNull())
22 typename JacobianFilterType::Pointer jacFilter = JacobianFilterType::New();
23 jacFilter->SetInput(this->GetInput(0));
24 jacFilter->SetNoIdentity(
true);
25 jacFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
26 jacFilter->SetNeighborhood(0);
30 m_FirstFieldJacobian = jacFilter->GetOutput();
31 m_FirstFieldJacobian->DisconnectPipeline();
34 if (m_SecondFieldJacobian.IsNull())
36 typename JacobianFilterType::Pointer jacFilter = JacobianFilterType::New();
37 jacFilter->SetInput(this->GetInput(1));
38 jacFilter->SetNoIdentity(
true);
39 jacFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
40 jacFilter->SetNeighborhood(0);
44 m_SecondFieldJacobian = jacFilter->GetOutput();
45 m_SecondFieldJacobian->DisconnectPipeline();
49 template <
typename TPixelType,
unsigned int Dimension>
54 typedef itk::ImageRegionConstIterator <InputImageType> InputIteratorType;
55 typedef itk::ImageRegionConstIterator <JacobianImageType> JacobianIteratorType;
56 typedef itk::ImageRegionIterator <OutputImageType> OutIteratorType;
58 InputIteratorType firstInputItr(this->GetInput(0),outputRegionForThread);
59 InputIteratorType secondInputItr(this->GetInput(1),outputRegionForThread);
60 OutIteratorType outItr(this->GetOutput(),outputRegionForThread);
62 JacobianIteratorType firstJacItr(m_FirstFieldJacobian,outputRegionForThread);
63 JacobianIteratorType secondJacItr(m_SecondFieldJacobian,outputRegionForThread);
69 while (!outItr.IsAtEnd())
73 inputValue = secondInputItr.Get();
74 jacValue = firstJacItr.Get();
76 for (
unsigned int i = 0;i < Dimension;++i)
78 for (
unsigned int j = 0;j < Dimension;++j)
79 outputValue[i] += jacValue[i * Dimension + j] * inputValue[j];
82 inputValue = firstInputItr.Get();
83 jacValue = secondJacItr.Get();
85 for (
unsigned int i = 0;i < Dimension;++i)
87 for (
unsigned int j = 0;j < Dimension;++j)
88 outputValue[i] -= jacValue[i * Dimension + j] * inputValue[j];
91 outItr.Set(outputValue);
InputImageType::PixelType InputPixelType
Compute the Jacobian matrix in real coordinates of a displacement field.
Computes the Lie bracket between two fields u and v as expressed by Bossa et al.
Superclass::OutputImageRegionType OutputImageRegionType
OutputImageType::PixelType OutputPixelType
JacobianImageType::PixelType JacobianPixelType