Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save agirault/f48d4c6bbad3a34361e1 to your computer and use it in GitHub Desktop.
Save agirault/f48d4c6bbad3a34361e1 to your computer and use it in GitHub Desktop.
template <class T, unsigned int VImageDimension >
void VectorImageUtils< T, VImageDimension >::HFieldToDeformationFieldImageFilter(typename DeformationImageType::Pointer itkImage)
{
ImageRegionConstIteratorWithIndex<DeformationImageType> it = ImageRegionConstIteratorWithIndex<DeformationImageType>(
itkImage, itkImage->GetRequestedRegion());
for(it.GoToBegin();!it.IsAtEnd(); ++it)
{
typename DeformationImageType::PixelType displacementValue;
typename DeformationImageType::PixelType hFieldValue = it.Get();
typename DeformationImageType::IndexType index = it.GetIndex();
typedef typename DeformationImageType::PixelType::ValueType CoordRepType;
const unsigned int Dimension = DeformationImageType::ImageDimension;
itk::Point<CoordRepType, Dimension> ipt;
itkImage->TransformIndexToPhysicalPoint(index,ipt);
displacementValue = hFieldValue - ipt;
it.Set(displacementValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment