Skip to content

Commit

Permalink
BUG: Limits check in ComputeJacobianWithRespectToPosition
Browse files Browse the repository at this point in the history
If the point was assumed to be inside the image (tested independently), the absolute value applied to index was unnecessary.
And by removing the absolute value we get also the checking for the index being inside.

Added the starting index of the LargestPossibleRegion to make the algorithm also valid for non-zero starting index.
  • Loading branch information
josempozo authored Feb 8, 2022
1 parent 1639cab commit 46e2ab9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ DisplacementFieldTransform<TParametersValueType, NDimensions>::ComputeJacobianWi
{

typename DisplacementFieldType::SizeType size = this->m_DisplacementField->GetLargestPossibleRegion().GetSize();
typename DisplacementFieldType::IndexType startingIndex = this->m_DisplacementField->GetLargestPossibleRegion().GetIndex();
typename DisplacementFieldType::SpacingType spacing = this->m_DisplacementField->GetSpacing();

IndexType ddrindex;
Expand All @@ -237,7 +238,7 @@ DisplacementFieldTransform<TParametersValueType, NDimensions>::ComputeJacobianWi
TParametersValueType space = NumericTraits<TParametersValueType>::OneValue();

// Minimum distance between neighbors
TParametersValueType mindist = NumericTraits<TParametersValueType>::OneValue();
IndexValueType mindist = NumericTraits<IndexValueType>::OneValue();

// Flag indicating a valid location for Jacobian calculation
bool isValidJacobianCalcLocat = true;
Expand All @@ -247,12 +248,12 @@ DisplacementFieldTransform<TParametersValueType, NDimensions>::ComputeJacobianWi
dPixSign = doInverseJacobian ? -dPixSign : dPixSign;
for (unsigned int row = 0; row < NDimensions; ++row)
{
TParametersValueType dist = itk::Math::abs((float)index[row]);
IndexValueType dist = index[row] - startingIndex[row];
if (dist < mindist)
{
isValidJacobianCalcLocat = false;
}
dist = itk::Math::abs((TParametersValueType)size[row] - (TParametersValueType)index[row]);
dist = static_cast<IndexValueType>(size[row]) - dist;
if (dist < mindist)
{
isValidJacobianCalcLocat = false;
Expand Down

0 comments on commit 46e2ab9

Please sign in to comment.