Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkImageAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ ImageAlgorithm::EnlargeRegionOverBox(const typename InputImageType::RegionType &
outputPoint[d] = inputPoint[d];
}
}
outputCorners[count] =
outputImage->template TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(outputPoint);
outputCorners[count] = outputImage->TransformPhysicalPointToContinuousIndex(outputPoint);
}

// Compute a rectangular region from the vector of corner indexes
Expand Down
13 changes: 13 additions & 0 deletions Modules/Core/Common/include/itkImageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,19 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject
return index;
}


/** \brief Returns the continuous index from a physical point
* \note This specific overload is easier to use, because it does not have template arguments. It just uses
* `itk::SpacePrecisionType`, both for the coordinates of the point and the index values.
*
* \sa Transform */
[[nodiscard]] ContinuousIndex<SpacePrecisionType, VImageDimension>
TransformPhysicalPointToContinuousIndex(const PointType & point) const
{
return TransformPhysicalPointToContinuousIndex<SpacePrecisionType>(point);
}
Comment on lines +518 to +522
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to have two of such (simple, non-templated) overloads? One of float and one of double? Specifically:

ContinuousIndex<float, VImageDimension>
TransformPhysicalPointToContinuousIndex(const Point<float, VImageDimension> &) const;

ContinuousIndex<double, VImageDimension>
TransformPhysicalPointToContinuousIndex(const Point<double, VImageDimension> &) const;

So one from Point<float, N> to ContinuousIndex<float, N>, and one from Point<double, N> to ContinuousIndex<double, N>? Overload resolution would then automatically choose the right one, no need for the user to specify template arguments. Right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The float one is rarely used, I believe. If someone wants an unusual thing, they can spell out the template parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, could all those image->template TransformPhysicalPointToContinuousIndex<ContinuousValueType>(point) calls inside ITK itself then replaced by simple non-templated image->TransformPhysicalPointToContinuousIndex(point) calls?



/** \brief Get the continuous index from a physical point
*
* Returns true if the resulting index is within the image, false otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ class ITK_TEMPLATE_EXPORT PhasedArray3DSpecialCoordinatesImage : public SpecialC
return index;
}

/** \brief Returns the continuous index from a physical point
* \note This specific overload is easier to use, because it does not have template arguments. It just uses
* `itk::SpacePrecisionType`, both for the coordinates of the point and the index values.
*
* \sa Transform */
[[nodiscard]] ContinuousIndex<SpacePrecisionType, ImageDimension>
TransformPhysicalPointToContinuousIndex(const PointType & point) const
{
return TransformPhysicalPointToContinuousIndex<SpacePrecisionType>(point);
}


/** \brief Get the continuous index from a physical point
*
* Returns true if the resulting index is within the image, false otherwise.
Expand Down
12 changes: 12 additions & 0 deletions Modules/Core/ImageAdaptors/include/itkImageAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,18 @@ class ITK_TEMPLATE_EXPORT ImageAdaptor : public ImageBase<TImage::ImageDimension
return m_Image->template TransformPhysicalPointToContinuousIndex<TIndexRep>(point);
}

/** \brief Returns the continuous index from a physical point
* \note This specific overload is easier to use, because it does not have template arguments. It just uses
* `itk::SpacePrecisionType`, both for the coordinates of the point and the index values.
*
* \sa Transform */
[[nodiscard]] ContinuousIndex<SpacePrecisionType, TImage::ImageDimension>
TransformPhysicalPointToContinuousIndex(const PointType & point) const
{
return m_Image->TransformPhysicalPointToContinuousIndex(point);
}


/** \brief Get the continuous index from a physical point
*
* Returns true if the resulting index is within the image, false otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ TriangleMeshToBinaryImageFilter<TInputMesh, TOutputImage>::RasterizeTriangles()
{
PointType p = points.Value();
// the index value type must match the point value type
const ContinuousIndex<PointType::ValueType, 3> ind =
OutputImage->template TransformPhysicalPointToContinuousIndex<PointType::ValueType>(p);
const ContinuousIndex<PointType::ValueType, 3> ind = OutputImage->TransformPhysicalPointToContinuousIndex(p);
NewPoints->InsertElement(pointId++, ind);

++points;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/include/itkBSplineBaseTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ BSplineBaseTransform<TParametersValueType, VDimension, VSplineOrder>::
WeightsType & weights,
ParameterIndexArrayType & indexes) const
{
ContinuousIndexType index =
this->m_CoefficientImages[0]->template TransformPhysicalPointToContinuousIndex<TParametersValueType>(point);
ContinuousIndexType index = this->m_CoefficientImages[0]->TransformPhysicalPointToContinuousIndex(point);

// NOTE: if the support region does not lie totally within the grid
// we assume zero displacement and return the input point
Expand Down
5 changes: 2 additions & 3 deletions Modules/Filtering/ImageGrid/include/itkWarpImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ WarpImageFilter<TInputImage, TOutputImage, TDisplacementField>::EvaluateDisplace
const DisplacementFieldType * fieldPtr,
DisplacementType & output)
{
const ContinuousIndex<double, ImageDimension> index =
fieldPtr->template TransformPhysicalPointToContinuousIndex<double>(point);
unsigned int dim; // index over dimension
const ContinuousIndex<double, ImageDimension> index = fieldPtr->TransformPhysicalPointToContinuousIndex(point);
unsigned int dim; // index over dimension
/**
* Compute base index = closest index below point
* Compute distance from point to base index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ itkDiscreteGradientMagnitudeGaussianImageFunctionTestND(int argc, char * argv[])

inputImage->TransformIndexToPhysicalPoint(it.GetIndex(), point);
const ContinuousIndexType cindex =
inputImage->TransformPhysicalPointToContinuousIndex<ContinuousValueIndexType>(point);
inputImage->template TransformPhysicalPointToContinuousIndex<ContinuousValueIndexType>(point);
out.Set(function->EvaluateAtContinuousIndex(cindex));
}
++it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ itkDiscreteHessianGaussianImageFunctionTestND(int argc, char * argv[])

reader->GetOutput()->TransformIndexToPhysicalPoint(it.GetIndex(), point);
const ContinuousIndexType cindex =
reader->GetOutput()->TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(point);
reader->GetOutput()->template TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(point);
hessian = function->EvaluateAtContinuousIndex(cindex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::ComputeImageDerivatives(const Mov
if (m_ComputeGradient)
{
const ContinuousIndex<double, MovingImageDimension> tempIndex =
m_MovingImage->template TransformPhysicalPointToContinuousIndex<double>(mappedPoint);
m_MovingImage->TransformPhysicalPointToContinuousIndex(mappedPoint);
MovingImageIndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
gradient = m_GradientImage->GetPixel(mappedIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ KappaStatisticImageToImageMetric<TFixedImage, TMovingImage>::GetDerivative(const
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetric<TFixedPointSet, TMovingImage
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down Expand Up @@ -247,7 +247,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetric<TFixedPointSet, TMovingImage
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ MeanSquaresPointSetToImageMetric<TFixedPointSet, TMovingImage>::GetDerivative(
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down Expand Up @@ -242,7 +242,7 @@ MeanSquaresPointSetToImageMetric<TFixedPointSet, TMovingImage>::GetValueAndDeriv
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ NormalizedCorrelationImageToImageMetric<TFixedImage, TMovingImage>::GetDerivativ
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down Expand Up @@ -434,7 +434,7 @@ NormalizedCorrelationImageToImageMetric<TFixedImage, TMovingImage>::GetValueAndD
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->m_MovingImage->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->m_MovingImage->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ NormalizedCorrelationPointSetToImageMetric<TFixedPointSet, TMovingImage>::GetDer
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->GetMovingImage()->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->GetMovingImage()->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down Expand Up @@ -335,7 +335,7 @@ NormalizedCorrelationPointSetToImageMetric<TFixedPointSet, TMovingImage>::GetVal
using MovingImageContinuousIndexType = ContinuousIndex<CoordRepType, MovingImageType::ImageDimension>;

const MovingImageContinuousIndexType tempIndex =
this->GetMovingImage()->template TransformPhysicalPointToContinuousIndex<CoordRepType>(transformedPoint);
this->GetMovingImage()->TransformPhysicalPointToContinuousIndex(transformedPoint);

typename MovingImageType::IndexType mappedIndex;
mappedIndex.CopyWithRound(tempIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::BeforeThreadedGenera
const IndexType & idx = it.GetIndex();
typename InputImageType::PointType pt;
shrunkImage->TransformIndexToPhysicalPoint(idx, pt);
const ContinuousIndexType cidx =
inputImage->template TransformPhysicalPointToContinuousIndex<typename PointType::ValueType>(pt);
const ContinuousIndexType cidx = inputImage->TransformPhysicalPointToContinuousIndex(pt);
for (unsigned int i = 0; i < ImageDimension; ++i)
{
cluster[numberOfComponents + i] = cidx[i];
Expand Down