Skip to content

Commit

Permalink
ENH: Wrap TransformToDisplacementField for Python
Browse files Browse the repository at this point in the history
  • Loading branch information
tbirdso authored and dzenanz committed Aug 24, 2021
1 parent 71e04b4 commit f87c9bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea

// Define a few variables that will be used to translate from an input pixel
// to an output pixel
PointType outputPoint; // Coordinates of output pixel
PointType transformedPoint; // Coordinates of transformed pixel
PixelType displacement; // the difference
PointType outputPoint; // Coordinates of output pixel
PointType transformedPoint; // Coordinates of transformed pixel
PointType displacementPoint; // the difference
PixelType displacementPixel; // the difference, cast to pixel type


TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());
Expand All @@ -205,8 +206,13 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea
// Compute corresponding input pixel position
transformedPoint = transform->TransformPoint(outputPoint);

displacement = transformedPoint - outputPoint;
outIt.Set(displacement);
displacementPoint = transformedPoint - outputPoint;
// Cast PointType -> PixelType
for (IndexValueType idx = 0; idx < ImageDimension; ++idx)
{
displacementPixel[idx] = static_cast<typename PixelType::ValueType>(displacementPoint[idx]);
}
outIt.Set(displacementPixel);
++outIt;
}
outIt.NextLine();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
UNIQUE(transform_param_types "${WRAP_ITK_REAL};D")
itk_wrap_class("itk::TransformToDisplacementFieldFilter" POINTER)
foreach(vt ${WRAP_ITK_VECTOR})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
foreach(t ${transform_param_types})
itk_wrap_template("${ITKM_I${vt}${d}${d}}${ITKM_${t}}" "${ITKT_I${vt}${d}${d}}, ${ITKT_${t}}")
endforeach()
endforeach()
endforeach()
itk_end_wrap_class()

0 comments on commit f87c9bd

Please sign in to comment.