Skip to content

Commit

Permalink
BUG: Fix TransformToDisplacementFieldFilter displacementPoint/Vector
Browse files Browse the repository at this point in the history
The subtraction `transformedPoint - outputPoint` yields a `Vector`, not
a `Point`. Adjusted `NonlinearThreadedGenerateData` accordingly.

This little flaw was found by locally (temporarily) declaring converting
constructors of `Point` "explicit".
  • Loading branch information
N-Dekker authored and hjmjohnson committed Feb 27, 2022
1 parent 7742563 commit dc70e38
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea
// to an output pixel
PointType outputPoint; // Coordinates of output pixel
PointType transformedPoint; // Coordinates of transformed pixel
PointType displacementPoint; // the difference
PixelType displacementPixel; // the difference, cast to pixel type


Expand All @@ -203,11 +202,11 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea
// Compute corresponding input pixel position
transformedPoint = transform->TransformPoint(outputPoint);

displacementPoint = transformedPoint - outputPoint;
const typename PointType::VectorType displacementVector = transformedPoint - outputPoint;
// Cast PointType -> PixelType
for (IndexValueType idx = 0; idx < ImageDimension; ++idx)
{
displacementPixel[idx] = static_cast<typename PixelType::ValueType>(displacementPoint[idx]);
displacementPixel[idx] = static_cast<typename PixelType::ValueType>(displacementVector[idx]);
}
outIt.Set(displacementPixel);
++outIt;
Expand Down

0 comments on commit dc70e38

Please sign in to comment.