Skip to content
Merged
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
9 changes: 9 additions & 0 deletions Documentation/docs/migration_guides/itk_6_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ reoriented_image = itk.orient_image_filter(
)
```

`GetIndex()` replaced with `ComputeIndex()`, for iterators without index
------------------------------------------------------------------------
`ImageConstIterator::GetIndex()` is marked to be removed in the future. This iterator does not have an index,
internally, so its `GetIndex()` member function does a potentially expensive computation. For an iterator that is
derived from `ImageConstIterator`, please use its newly introduced `ComputeIndex()` member function instead. Or use an
iterator _with_ index (like `ImageIteratorWithIndex`).



Remove support for Python wrapped `long double` types
-----------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/ImageToPointSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ main(int argc, char * argv[])
{

// Convert the pixel position into a Point
image->TransformIndexToPhysicalPoint(it.GetIndex(), point);
image->TransformIndexToPhysicalPoint(it.ComputeIndex(), point);
pointSet->SetPoint(pointId, point);

// Transfer the pixel data to the value associated with the point.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Filtering/GaussianBlurImageFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ main(int argc, char * argv[])

while (!it.IsAtEnd())
{
out.Set(gaussianFunction->EvaluateAtIndex(it.GetIndex()));
out.Set(gaussianFunction->EvaluateAtIndex(it.ComputeIndex()));
++it;
++out;
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/BSplineWarping1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/BSplineWarping2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/DeformableRegistration12.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = transform->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/DeformableRegistration13.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = transform->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/DeformableRegistration14.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = transform->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/DeformableRegistration15.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ main(int argc, char * argv[])

while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, fixedPoint);
movingPoint = bsplineTransformFine->TransformPoint(fixedPoint);
displacement = movingPoint - fixedPoint;
Expand Down
2 changes: 1 addition & 1 deletion Examples/RegistrationITKv4/ThinPlateSplineWarp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ ExampleMain(int argc, const char * const argv[])
FieldVectorType displacement;
while (!fi.IsAtEnd())
{
index = fi.GetIndex();
index = fi.ComputeIndex();
field->TransformIndexToPhysicalPoint(index, point1);
point2 = tps->TransformPoint(point1);
for (unsigned int i = 0; i < ImageDimension; ++i)
Expand Down
8 changes: 5 additions & 3 deletions Modules/Core/Common/include/itkImageConstIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,17 @@ class ITK_TEMPLATE_EXPORT ImageConstIterator
return m_Image->ComputeIndex(m_Offset);
}

#ifndef ITK_FUTURE_LEGACY_REMOVE
/** Computes and returns the index. This may be a relatively expensive operation.
* \note It is often preferable for users to call ComputeIndex() directly, to make it more clear that this function
* may be expensive.
* \sa ComputeIndex */
* \deprecated Please use `ComputeIndex()` instead, or use an iterator with index, like `ImageIteratorWithIndex`! */
ITK_FUTURE_DEPRECATED(
"Please use `ComputeIndex()` instead, or use an iterator with index, like `ImageIteratorWithIndex`!")
[[nodiscard]] IndexType
GetIndex() const
{
return this->ComputeIndex();
}
#endif

/** Set the index. No bounds checking is performed.
* \sa GetIndex */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
// Set all pixels with first index == 0 to 0, and set the rest of the image to 255
while (!createImageIterator.IsAtEnd())
{
if (createImageIterator.GetIndex()[0] == 0)
if (createImageIterator.ComputeIndex()[0] == 0)
{
createImageIterator.Set(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
// Set all pixels with first index == 0 to 0, and set the rest of the image to 255
while (!createImageIterator.IsAtEnd())
{
if (createImageIterator.GetIndex()[0] == 0)
if (createImageIterator.ComputeIndex()[0] == 0)
{
createImageIterator.Set(0);
}
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/test/itkExtractImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ itkExtractImageTest(int, char *[])

for (; !iteratorIn1.IsAtEnd(); ++iteratorIn1)
{
const ShortImage::IndexType::IndexValueType row = iteratorIn1.GetIndex()[0];
const ShortImage::IndexType::IndexValueType column = iteratorIn1.GetIndex()[1];
const ShortImage::IndexType::IndexValueType row = iteratorIn1.ComputeIndex()[0];
const ShortImage::IndexType::IndexValueType column = iteratorIn1.ComputeIndex()[1];
if ((row < 0) || (row > 7) || (column < 0) || (column > 11))
{
if (iteratorIn1.Get() != 13)
Expand Down Expand Up @@ -251,8 +251,8 @@ itkExtractImageTest(int, char *[])
{
for (; !iteratorIn2.IsAtEnd(); ++iteratorIn2)
{
const ShortImage::IndexType::IndexValueType row = iteratorIn2.GetIndex()[0];
const ShortImage::IndexType::IndexValueType column = iteratorIn2.GetIndex()[1];
const ShortImage::IndexType::IndexValueType row = iteratorIn2.ComputeIndex()[0];
const ShortImage::IndexType::IndexValueType column = iteratorIn2.ComputeIndex()[1];
if ((row < 0) || (row > 7) || (column < 0) || (column > 11))
{
if (iteratorIn2.Get() != 13)
Expand Down Expand Up @@ -318,7 +318,7 @@ itkExtractImageTest(int, char *[])
{
const LineImage::PixelType linePixelValue = iteratorLineIn.Get();
testIndex[0] = extractIndex[0];
testIndex[1] = iteratorLineIn.GetIndex()[0];
testIndex[1] = iteratorLineIn.ComputeIndex()[0];
if (linePixelValue != if2->GetPixel(testIndex))
{
passed = false;
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/test/itkImageIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ itkImageIteratorTest(int, char *[])
}

// Exercise GetIndex()
const VectorImageType::IndexType index1 = itr1.GetIndex();
const VectorImageType::IndexType index1 = itr1.ComputeIndex();
if (index1 != startIndex3D)
{
std::cerr << "Error in GetIndex()" << std::endl;
Expand All @@ -162,13 +162,13 @@ itkImageIteratorTest(int, char *[])
index2[0]++;
VectorImageIterator itr5 = itr1;
itr5.SetIndex(index2);
if (itr5.GetIndex() != index2)
if (itr5.ComputeIndex() != index2)
{
std::cerr << "Error in GetIndex() and/or SetIndex()" << std::endl;
return EXIT_FAILURE;
}

if (itr5.GetIndex() == itr1.GetIndex())
if (itr5.ComputeIndex() == itr1.ComputeIndex())
{
std::cerr << "Error in GetIndex() and/or SetIndex()" << std::endl;
return EXIT_FAILURE;
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/test/itkImageRegionIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ itkImageRegionIteratorTest(int, char *[])
std::cout << "Simple iterator loop: ";
for (; !it.IsAtEnd(); ++it)
{
const itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = it.GetIndex();
const itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = it.ComputeIndex();
std::cout << index << std::endl;
}

Expand All @@ -109,7 +109,7 @@ itkImageRegionIteratorTest(int, char *[])
std::cout << "Simple const iterator loop: ";
for (; !cit.IsAtEnd(); ++cit)
{
const itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = cit.GetIndex();
const itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = cit.ComputeIndex();
std::cout << index << std::endl;
}

Expand All @@ -122,7 +122,7 @@ itkImageRegionIteratorTest(int, char *[])
{
--backIt;

itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = backIt.GetIndex();
itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = backIt.ComputeIndex();
std::cout << "Simple iterator backwards loop: ";
for (unsigned int i = 0; i < index.GetIndexDimension(); ++i)
{
Expand All @@ -147,7 +147,7 @@ itkImageRegionIteratorTest(int, char *[])
// Set all pixels with first index == 0 to 0, and set the rest of the image to 255
while (!createImageIterator.IsAtEnd())
{
if (createImageIterator.GetIndex()[0] == 0)
if (createImageIterator.ComputeIndex()[0] == 0)
{
createImageIterator.Set(0);
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/test/itkImageReverseIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ itkImageReverseIteratorTest(int, char *[])

for (; !it.IsAtEnd(); ++it)
{
ImageType::IndexType index = it.GetIndex();
ImageType::IndexType index = it.ComputeIndex();
std::cout << "Simple iterator loop: ";
for (unsigned int i = 0; i < index.GetIndexDimension(); ++i)
{
Expand All @@ -115,7 +115,7 @@ itkImageReverseIteratorTest(int, char *[])
{
--backIt;

ImageType::IndexType index = backIt.GetIndex();
ImageType::IndexType index = backIt.ComputeIndex();
std::cout << "Simple iterator backwards loop: ";
for (unsigned int i = 0; i < index.GetIndexDimension(); ++i)
{
Expand Down Expand Up @@ -183,7 +183,7 @@ itkImageReverseIteratorTest(int, char *[])
for (; !it.IsAtEnd(); ++it)
{
--castBackReverseIt;
itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = it.GetIndex();
itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType index = it.ComputeIndex();
itk::Image<itk::Vector<unsigned short, 5>, 3>::IndexType rindex = castBackReverseIt.GetIndex();
for (unsigned int i = 0; i < index.GetIndexDimension(); ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ itkImageScanlineIteratorTest1(int, char *[])
{
while (!createImageIterator.IsAtEndOfLine())
{
if (createImageIterator.GetIndex()[0] == 0)
if (createImageIterator.ComputeIndex()[0] == 0)
{
createImageIterator.Set(0);
}
Expand Down
13 changes: 7 additions & 6 deletions Modules/Core/Common/test/itkImportImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ itkImportImageTest(int, char *[])
bool passed = true;
for (; !iterator2.IsAtEnd(); ++iterator2)
{
std::cout << "Pixel " << iterator2.GetIndex() << " = " << iterator2.Get() << std::endl;
std::cout << "Pixel " << iterator2.ComputeIndex() << " = " << iterator2.Get() << std::endl;
if (iterator2.Get() !=
itk::Math::RoundHalfIntegerUp<short>(static_cast<float>(
(shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + shrink->GetShrinkFactors()[0] / 2) +
(shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[0] + shrink->GetShrinkFactors()[0] / 2) +
(region.GetSize()[0] *
((shrink->GetShrinkFactors()[1] / 2) + (shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[1]))))))
((shrink->GetShrinkFactors()[1] / 2) + (shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[1]))))))
{
std::cout << " iterator2.GetIndex() Get() " << iterator2.GetIndex() << ' ' << iterator2.Get() << " compare value "
std::cout << " iterator2.GetIndex() Get() " << iterator2.ComputeIndex() << ' ' << iterator2.Get()
<< " compare value "
<< itk::Math::RoundHalfIntegerUp<short>(static_cast<float>(
(shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + shrink->GetShrinkFactors()[0] / 2) +
(shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[0] + shrink->GetShrinkFactors()[0] / 2) +
(region.GetSize()[0] * ((shrink->GetShrinkFactors()[1] / 2) +
(shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[1])))))
(shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[1])))))
<< '\n';
passed = false;
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/test/itkStreamingImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ itkStreamingImageFilterTest(int, char *[])
bool passed = true;
for (; !iterator2.IsAtEnd(); ++iterator2)
{
short col = (shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + (shrink->GetShrinkFactors()[0] - 1) / 2);
short col = (shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[0] + (shrink->GetShrinkFactors()[0] - 1) / 2);
col += colOffset;

short row = (shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1] - 1) / 2);
short row = (shrink->GetShrinkFactors()[1] * iterator2.ComputeIndex()[1] + (shrink->GetShrinkFactors()[1] - 1) / 2);
row += rowOffset;
const short trueValue = col + region.GetSize()[0] * row;

if (iterator2.Get() != trueValue)
{
passed = false;
std::cout << "Pixel " << iterator2.GetIndex() << " expected " << trueValue << " but got " << iterator2.Get()
std::cout << "Pixel " << iterator2.ComputeIndex() << " expected " << trueValue << " but got " << iterator2.Get()
<< std::endl;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/test/itkStreamingImageFilterTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ itkStreamingImageFilterTest2(int, char *[])
for (; !iterator2.IsAtEnd(); ++iterator2)
{
auto col = itk::Math::RoundHalfIntegerUp<short>(static_cast<float>(
shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + (shrink->GetShrinkFactors()[0]) / 2.0));
shrink->GetShrinkFactors()[0] * iterator2.ComputeIndex()[0] + (shrink->GetShrinkFactors()[0]) / 2.0));
col += colOffset;

auto row = itk::Math::RoundHalfIntegerUp<short>(static_cast<float>(
shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1]) / 2.0));
shrink->GetShrinkFactors()[1] * iterator2.ComputeIndex()[1] + (shrink->GetShrinkFactors()[1]) / 2.0));
row += rowOffset;
const short trueValue = col + region.GetSize()[0] * row;

if (iterator2.Get() != trueValue)
{
passed = false;
std::cout << "Pixel " << iterator2.GetIndex() << " expected " << trueValue << " but got " << iterator2.Get()
std::cout << "Pixel " << iterator2.ComputeIndex() << " expected " << trueValue << " but got " << iterator2.Get()
<< std::endl;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ itkSymmetricSecondRankTensorImageReadTest(int argc, char * argv[])
if (itk::Math::abs(matrixPixel[i][j] - tensorPixel(i, j)) > tolerance)
{
std::cerr << "Tensor read does not match expected values " << std::endl;
std::cerr << "Index " << tItr.GetIndex() << std::endl;
std::cerr << "Index " << tItr.ComputeIndex() << std::endl;
std::cerr << "Tensor value " << std::endl << tensorPixel << std::endl;
std::cerr << "Matrix value " << std::endl << matrixPixel << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ itkSymmetricSecondRankTensorImageWriteReadTest(int argc, char * argv[])
if (itk::Math::abs(tensorPixelInput[i] - tensorPixelOutput[i]) > tolerance)
{
std::cerr << "Tensor read does not match expected values " << std::endl;
std::cerr << "Index " << inIt.GetIndex() << std::endl;
std::cerr << "Index " << inIt.ComputeIndex() << std::endl;
std::cerr << "Tensor input value " << std::endl << tensorPixelInput << std::endl;
std::cerr << "Tensor output value " << std::endl << tensorPixelOutput << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct helper<itk::Index<VDimension>>
static PositionType
GetPosition(const TImage *, const TIterator & it)
{
return it.GetIndex();
return it.ComputeIndex();
}
};

Expand All @@ -49,7 +49,7 @@ struct helper<itk::Point<TCoord, VDimension>>
GetPosition(const TImage * image, const TIterator & it)
{
typename TImage::PointType p;
image->TransformIndexToPhysicalPoint(it.GetIndex(), p);
image->TransformIndexToPhysicalPoint(it.ComputeIndex(), p);

PositionType point;
point.CastFrom(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ itkImageMaskSpatialObjectTest(int, char *[])

while (!itr.IsAtEnd())
{
const ImageType::IndexType constIndex = itr.GetIndex();
const ImageType::IndexType constIndex = itr.ComputeIndex();
const bool reference = insideRegion.IsInside(constIndex);
ImageType::PointType point;
image->TransformIndexToPhysicalPoint(constIndex, point);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ itkImageMaskSpatialObjectTest2(int, char *[])
itr.GoToBegin();
while (!itr.IsAtEnd())
{
const ImageType::IndexType constIndex = itr.GetIndex();
const ImageType::IndexType constIndex = itr.ComputeIndex();

ImageType::PointType point;
image->TransformIndexToPhysicalPoint(constIndex, point);
Expand All @@ -135,7 +135,7 @@ itkImageMaskSpatialObjectTest2(int, char *[])
itr.GoToBegin();
while (!itr.IsAtEnd())
{
const ImageType::IndexType constIndex = itr.GetIndex();
const ImageType::IndexType constIndex = itr.ComputeIndex();
const bool reference = insideRegion.IsInside(constIndex);

ImageType::PointType point;
Expand Down
Loading
Loading