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
16 changes: 12 additions & 4 deletions Modules/Core/Common/include/itkImageConstIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,24 @@ class ITK_TEMPLATE_EXPORT ImageConstIterator
return (m_Buffer + m_Offset) > (it.m_Buffer + it.m_Offset);
}

/** Get the index. This provides a read only reference to the index.
* This causes the index to be calculated from pointer arithmetic and is
* therefore an expensive operation.
/** Computes the index. Internally calls ImageBase::ComputeIndex, which may be a relatively expensive operation.
* \sa SetIndex */
[[nodiscard]] IndexType
GetIndex() const
ComputeIndex() const
{
return m_Image->ComputeIndex(m_Offset);
}

/** 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 */
[[nodiscard]] IndexType
GetIndex() const
{
return this->ComputeIndex();
}

/** Set the index. No bounds checking is performed.
* \sa GetIndex */
virtual void
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageReverseConstIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class ITK_TEMPLATE_EXPORT ImageReverseConstIterator
{


const IndexType ind = it.GetIndex();
const IndexType ind = it.ComputeIndex();

m_Offset = m_Image->ComputeOffset(ind);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator
{
this->ImageConstIterator<TImage>::operator=(it);

IndexType ind = this->GetIndex();
IndexType ind = this->ComputeIndex();
m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
(ind[0] - this->m_Region.GetIndex()[0]);
m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ InvertDisplacementFieldImageFilter<TInputImage, TOutputImage>::DynamicThreadedGe
}
update = ItI.Get() + update * this->m_Epsilon;
ItI.Set(update);
typename DisplacementFieldType::IndexType index = ItI.GetIndex();
typename DisplacementFieldType::IndexType index = ItI.ComputeIndex();
if (this->m_EnforceBoundaryCondition)
{
for (unsigned int d = 0; d < ImageDimension; ++d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ IterativeInverseDisplacementFieldImageFilter<TInputImage, TOutputImage>::Generat
while (!OutputIt.IsAtEnd())
{
// get the output image index
const OutputImageIndexType index = OutputIt.GetIndex();
const OutputImageIndexType index = OutputIt.ComputeIndex();
OutputImagePointType originalPoint;
outputPtr->TransformIndexToPhysicalPoint(index, originalPoint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea
while (!outIt.IsAtEndOfLine())
{
// Determine the index of the current output pixel
output->TransformIndexToPhysicalPoint(outIt.GetIndex(), outputPoint);
output->TransformIndexToPhysicalPoint(outIt.ComputeIndex(), outputPoint);

// Compute corresponding input pixel position
transformedPoint = transform->TransformPoint(outputPoint);
Expand Down Expand Up @@ -235,7 +235,7 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::LinearTh
// The region may be split along the fast scan-line direction, so
// the computation is done for the beginning and end of the largest
// possible region to improve consistent numerics.
IndexType index = outIt.GetIndex();
IndexType index = outIt.ComputeIndex();
index[0] = largestPossibleRegion.GetIndex(0);

outputPtr->TransformIndexToPhysicalPoint(index, outputPoint);
Expand All @@ -247,7 +247,7 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::LinearTh
inputPoint = transformPtr->TransformPoint(outputPoint);
const typename PointType::VectorType endDisplacement = inputPoint - outputPoint;

IndexValueType scanlineIndex = outIt.GetIndex()[0];
IndexValueType scanlineIndex = outIt.ComputeIndex()[0];

while (!outIt.IsAtEndOfLine())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::HysteresisThresholding
if (value > m_UpperThreshold)
{
node = m_NodeStore->Borrow();
node->m_Value = oit.GetIndex();
node->m_Value = oit.ComputeIndex();
m_NodeList->PushFront(node);
FollowEdge(oit.GetIndex(), multiplyImageFilterOutput);
FollowEdge(oit.ComputeIndex(), multiplyImageFilterOutput);
}

++oit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ HoughTransform2DLinesImageFilter<TInputPixelType, TOutputPixelType>::GetLines()
// Create the line.
LineType::LinePointListType list; // Insert two points per line.

const double radius = it_input.GetIndex()[0];
const double teta = ((it_input.GetIndex()[1]) * 2 * Math::pi / this->GetAngleResolution()) - Math::pi;
const double radius = it_input.ComputeIndex()[0];
const double teta = ((it_input.ComputeIndex()[1]) * 2 * Math::pi / this->GetAngleResolution()) - Math::pi;
const double Vx = radius * std::cos(teta);
const double Vy = radius * std::sin(teta);
const double norm = std::sqrt(Vx * Vx + Vy * Vy);
Expand Down Expand Up @@ -326,8 +326,8 @@ HoughTransform2DLinesImageFilter<TInputPixelType, TOutputPixelType>::GetLines()
{
for (double length = 0; length < m_DiscRadius; length += 1)
{
index[0] = static_cast<IndexValueType>(it_input.GetIndex()[0] + length * std::cos(angle));
index[1] = static_cast<IndexValueType>(it_input.GetIndex()[1] + length * std::sin(angle));
index[0] = static_cast<IndexValueType>(it_input.ComputeIndex()[0] + length * std::cos(angle));
index[1] = static_cast<IndexValueType>(it_input.ComputeIndex()[1] + length * std::sin(angle));
if (postProcessImage->GetBufferedRegion().IsInside(index))
{
postProcessImage->SetPixel(index, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DifferenceOfGaussiansGradientImageFilter<TInputImage, TDataType>::GenerateData()
for (; !outIt.IsAtEnd(); ++outIt)
{
// determine the index of the output pixel
outputIndex = outIt.GetIndex();
outputIndex = outIt.ComputeIndex();

// is the current index an acceptable distance from the edges
// of the image?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ BinShrinkImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
for (ImageScanlineIterator outputIterator(outputPtr, outputRegionForThread); !outputIterator.IsAtEnd();
outputIterator.NextLine())
{
const OutputIndexType outputIndex = outputIterator.GetIndex();
const OutputIndexType outputIndex = outputIterator.ComputeIndex();

auto offset = offsets.begin();
const InputIndexType startInputIndex = outputIndex * factorSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ExpandImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
// Walk the output region, and interpolate the input image
for (ImageScanlineIterator outIt(outputPtr, outputRegionForThread); !outIt.IsAtEnd(); outIt.NextLine())
{
const typename OutputImageType::IndexType outputIndex = outIt.GetIndex();
const typename OutputImageType::IndexType outputIndex = outIt.ComputeIndex();


// Determine the input pixel location associated with this output
Expand Down
2 changes: 1 addition & 1 deletion Modules/Filtering/ImageGrid/include/itkFlipImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ FlipImageFilter<TImage>::DynamicThreadedGenerateData(const OutputImageRegionType
for (ImageScanlineIterator outputIt(outputPtr, outputRegionForThread); !outputIt.IsAtEnd(); outputIt.NextLine())
{
// Determine the index of the output line
const typename TImage::IndexType outputIndex = outputIt.GetIndex();
const typename TImage::IndexType outputIndex = outputIt.ComputeIndex();

// Determine the input pixel location associated with the start of
// the line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ MirrorPadImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
InputIterator inIt(inputPtr, inputRegion);
for (OutputIterator outIt(outputPtr, outputRegion); !outIt.IsAtEnd(); ++outIt, i++, ++inIt)
{
OutputImageIndexType currentOutputIndex = outIt.GetIndex();
OutputImageIndexType currentOutputIndex = outIt.ComputeIndex();

this->ConvertOutputIndexToInputIndex(
currentOutputIndex, currentInputIndex, outputRegion, inputRegion, oddRegionArray, decayFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ ResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType, TTran
// Determine the continuous index of the first and end pixel of output
// scan line when mapped to the input coordinate frame.

IndexType index = outIt.GetIndex();
IndexType index = outIt.ComputeIndex();
index[0] = firstIndexValueOfLargestPossibleRegion;

const ContinuousInputIndexType startIndex = transformIndex(index);
index[0] += firstSizeValueOfLargestPossibleRegion;
const auto vectorFromStartIndex = transformIndex(index) - startIndex;

IndexValueType scanlineIndex = outIt.GetIndex()[0];
IndexValueType scanlineIndex = outIt.ComputeIndex()[0];


while (!outIt.IsAtEndOfLine())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData

for (inLineIt.GoToBegin(); !inLineIt.IsAtEnd(); inLineIt.NextLine(), outLineIt.NextLine())
{
SizeValueType lineId = this->IndexToLinearIndex(inLineIt.GetIndex());
SizeValueType lineId = this->IndexToLinearIndex(inLineIt.ComputeIndex());
LineEncodingType fgLine;
LineEncodingType bgLine;

Expand All @@ -142,7 +142,7 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData
{
// We've hit the start of a run
SizeValueType length = 0;
const IndexType thisIndex = inLineIt.GetIndex();
const IndexType thisIndex = inLineIt.ComputeIndex();

outLineIt.Set(m_BackgroundValue);

Expand All @@ -164,7 +164,7 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData
{
// We've hit the start of a run
SizeValueType length = 0;
const IndexType thisIndex = inLineIt.GetIndex();
const IndexType thisIndex = inLineIt.ComputeIndex();

outLineIt.Set(PVal);
++length;
Expand Down Expand Up @@ -198,7 +198,7 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::ThreadedIntegrateData(const

for (ImageScanlineIterator outLineIt(output, outputRegionForThread); !outLineIt.IsAtEnd(); outLineIt.NextLine())
{
const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex());
const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.ComputeIndex());
if (!m_ForegroundLineMap[thisIdx].empty())
{
for (auto I = this->m_LineOffsets.begin(); I != this->m_LineOffsets.end(); ++I)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ LabelContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(

for (inLineIt.GoToBegin(); !inLineIt.IsAtEnd(); inLineIt.NextLine(), outLineIt.NextLine())
{
const SizeValueType lineId = this->IndexToLinearIndex(inLineIt.GetIndex());
const SizeValueType lineId = this->IndexToLinearIndex(inLineIt.ComputeIndex());
LineEncodingType thisLine;
while (!inLineIt.IsAtEndOfLine())
{
const InputPixelType PVal = inLineIt.Get();

SizeValueType length = 0;
const InputIndexType thisIndex = inLineIt.GetIndex();
const InputIndexType thisIndex = inLineIt.ComputeIndex();
outLineIt.Set(m_BackgroundValue);
++length;
++inLineIt;
Expand Down Expand Up @@ -162,7 +162,7 @@ LabelContourImageFilter<TInputImage, TOutputImage>::ThreadedIntegrateData(

for (ImageScanlineIterator outLineIt(output, outputRegionForThread); !outLineIt.IsAtEnd(); outLineIt.NextLine())
{
const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex());
const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.ComputeIndex());
if (!m_LineMap[thisIdx].empty())
{
for (auto I = this->m_LineOffsets.begin(); I != this->m_LineOffsets.end(); ++I)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ GaussianImageSource<TOutputImage>::GenerateData()
// Walk the output image, evaluating the spatial function at each pixel
for (OutputIterator outIt(outputPtr, outputPtr->GetRequestedRegion()); !outIt.IsAtEnd(); ++outIt)
{
const typename TOutputImage::IndexType index = outIt.GetIndex();
const typename TOutputImage::IndexType index = outIt.ComputeIndex();
// The position at which the function is evaluated
typename FunctionType::InputType evalPoint;
outputPtr->TransformIndexToPhysicalPoint(index, evalPoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ AccumulateImageFilter<TInputImage, TOutputImage>::GenerateData()
}
while (!outputIter.IsAtEnd())
{
typename TOutputImage::IndexType OutputIndex = outputIter.GetIndex();
typename TOutputImage::IndexType OutputIndex = outputIter.ComputeIndex();
for (unsigned int i = 0; i < InputImageDimension; ++i)
{
if (i != m_AccumulateDimension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ BinaryImageToLabelMapFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateD
{
// We've hit the start of a run
SizeValueType length = 0;
const IndexType thisIndex = inLineIt.GetIndex();
const IndexType thisIndex = inLineIt.ComputeIndex();
++length;
++inLineIt;
while (!inLineIt.IsAtEndOfLine() && inLineIt.Get() == this->m_InputForegroundValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ValuedRegionalExtremaImageFilter<TInputImage, TOutputImage, TFunction1, TFunctio
if (compareOut(V, m_MarkerValue))
{
// reposition the input iterator
inNIt += outIt.GetIndex() - inNIt.GetIndex();
inNIt += outIt.ComputeIndex() - inNIt.GetIndex();

auto Cent = static_cast<InputImagePixelType>(V);

Expand All @@ -156,7 +156,7 @@ ValuedRegionalExtremaImageFilter<TInputImage, TOutputImage, TFunction1, TFunctio
// indexes of all neighbors with value V on the stack. The
// process terminates when the stack is empty.

outNIt += outIt.GetIndex() - outNIt.GetIndex();
outNIt += outIt.ComputeIndex() - outNIt.GetIndex();

OutputImagePixelType NVal;
OutIndexType idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ ContourExtractor2DImageFilter<TInputImage>::GenerateDataForLabels()
for (inputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt)
{
BoundingBoxType & bbox = labelBoundingBoxes[inputIt.Get()];
bbox.min[0] = std::min(bbox.min[0], inputIt.GetIndex()[0]);
bbox.min[1] = std::min(bbox.min[1], inputIt.GetIndex()[1]);
bbox.max[0] = std::max(bbox.max[0], inputIt.GetIndex()[0]);
bbox.max[1] = std::max(bbox.max[1], inputIt.GetIndex()[1]);
bbox.min[0] = std::min(bbox.min[0], inputIt.ComputeIndex()[0]);
bbox.min[1] = std::min(bbox.min[1], inputIt.ComputeIndex()[1]);
bbox.max[0] = std::max(bbox.max[0], inputIt.ComputeIndex()[0]);
bbox.max[1] = std::max(bbox.max[1], inputIt.ComputeIndex()[1]);
}
// Build the extended regions from the bounding boxes
for (const InputPixelType label : allLabels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ BinomialBlurImageFilter<TInputImage, TOutputImage>::GenerateData()
while (!tempItDir.IsAtEnd())
{
// determine the index of the output pixel
index = tempItDir.GetIndex();
index = tempItDir.ComputeIndex();

if (index[dim] < (startIndex[dim] + static_cast<typename TTempImage::OffsetValueType>(size[dim]) - 1))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SpatialFunctionImageEvaluatorFilter<TSpatialFunction, TInputImage, TOutputImage>
// Walk the output image, evaluating the spatial function at each pixel
for (; !outIt.IsAtEnd(); ++outIt)
{
const typename TOutputImage::IndexType index = outIt.GetIndex();
const typename TOutputImage::IndexType index = outIt.ComputeIndex();
outputPtr->TransformIndexToPhysicalPoint(index, evalPoint);
value = m_PixelFunction->Evaluate(evalPoint);

Expand Down
2 changes: 1 addition & 1 deletion Modules/Numerics/FEM/include/itkFEMRobustSolver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ RobustSolver<VDimension>::InitializeInterpolationGrid()
{
// Note: Iterator is guaranteed to be within image, since the
// elements with BB outside are skipped before.
this->m_InterpolationGrid->TransformIndexToPhysicalPoint(iter.GetIndex(), pt);
this->m_InterpolationGrid->TransformIndexToPhysicalPoint(iter.ComputeIndex(), pt);
for (FEMIndexType d = 0; d < NumberOfDimensions; ++d)
{
global_point[d] = pt[d];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ FEMScatteredDataPointSetToImageFilter<TInputPointSet,
// step over all points within the region
for (iter.GoToBegin(); !iter.IsAtEnd(); ++iter)
{
output->TransformIndexToPhysicalPoint(iter.GetIndex(), point);
output->TransformIndexToPhysicalPoint(iter.ComputeIndex(), point);
for (unsigned int d = 0; d < ImageDimension; ++d)
{
globalPoint[d] = point[d];
Expand Down
2 changes: 1 addition & 1 deletion Modules/Numerics/FEM/include/itkFEMSolver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ Solver<VDimension>::FillInterpolationGrid()
{
// Note: Iterator is guaranteed to be within image, since the
// elements with BB outside are skipped before.
m_InterpolationGrid->TransformIndexToPhysicalPoint(iter.GetIndex(), pt);
m_InterpolationGrid->TransformIndexToPhysicalPoint(iter.ComputeIndex(), pt);
for (unsigned int d = 0; d < NumberOfDimensions; ++d)
{
global_point[d] = pt[d];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ ConnectedComponentImageFilter<TInputImage, TOutputImage, TMaskImage>::DynamicThr
if (PVal != NumericTraits<InputPixelType>::ZeroValue(PVal))
{
// We've hit the start of a run
const IndexType thisIndex = inLineIt.GetIndex();
const IndexType thisIndex = inLineIt.ComputeIndex();
// std::cout << thisIndex << std::endl;
SizeValueType length = 1;
++inLineIt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ HardConnectedComponentImageFilter<TInputImage, TOutputImage>::GenerateData()
{
for (unsigned int i = 0; i < ImageDimension; ++i)
{
IndexType currentIndex = ot.GetIndex();
IndexType currentIndex = ot.ComputeIndex();
currentIndex[i] = currentIndex[i] - 1;
LabelType label = 0;
if (currentIndex[i] >= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ LevelSetNeighborhoodExtractor<TLevelSet>::GenerateDataFull()
this->UpdateProgress(static_cast<float>(i) / static_cast<float>(totalPixels));
}

inputIndex = inIt.GetIndex();
inputIndex = inIt.ComputeIndex();
this->CalculateDistance(inputIndex);
}
}
Expand Down
Loading
Loading