Skip to content

Commit b1162f4

Browse files
committed
STYLE: Remove GoToBegin() calls from Image Iterators in hxx files
Their `IteratorType(image, region)` constructors do already initialize the iterator at the begin of its region. Using Notepad++, Replace in Files, doing: Find what: ^([ ]+)(Image\w+Iterator[ ]+)(\w+)(\(.*\);)[\r\n]+\1\3\.GoToBegin\(\); Filters: itk*.hxx [v] Match case (*) Regular expression [ ] . matches newline Follow-up to pull request InsightSoftwareConsortium#4830 commit cf57876 "STYLE: Remove unnecessary iterator `GoToBegin()` calls from Core"
1 parent 869718f commit b1162f4

20 files changed

+10
-47
lines changed

Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ MRASlabIdentifier<TInputImage>::GenerateSlabRegions()
7878
region.SetIndex(index);
7979

8080
ImageRegionConstIterator iter(m_Image, region);
81-
iter.GoToBegin();
8281

8382
std::priority_queue<ImagePixelType> mins;
8483
for (unsigned int i = 0; i < m_NumberOfSamples; ++i)

Modules/Filtering/BiasCorrection/include/itkMRIBiasFieldCorrectionFilter.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ MRIBiasEnergyFunction<TImage, TImageMask, TBiasField>::GetValue(const Parameters
102102
else
103103
{
104104
ImageRegionIterator mIter(m_Mask, m_Region);
105-
mIter.GoToBegin();
106105
while (!bIter.IsAtEnd())
107106
{
108107
if (mIter.Get() > 0.0)
@@ -547,7 +546,6 @@ MRIBiasFieldCorrectionFilter<TInputImage, TOutputImage, TMaskImage>::CorrectImag
547546
{
548547
itkDebugMacro("Output mask is being used");
549548
ImageRegionIterator mIter(m_OutputMask, region);
550-
mIter.GoToBegin();
551549
while (!bIter.IsAtEnd())
552550
{
553551
const double inputPixel = iIter.Get();

Modules/Filtering/ImageIntensity/include/itkDiscreteGaussianDerivativeImageFunction.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ DiscreteGaussianDerivativeImageFunction<TInputImage, TOutput>::RecomputeGaussian
136136

137137
// Copy kernel image to neighborhood. Do not copy boundaries.
138138
ImageRegionConstIterator it(kernelImage, kernelRegion);
139-
it.GoToBegin();
140-
unsigned int idx = 0;
139+
unsigned int idx = 0;
141140

142141
while (!it.IsAtEnd())
143142
{

Modules/Filtering/ImageIntensity/include/itkDiscreteGradientMagnitudeGaussianImageFunction.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ DiscreteGradientMagnitudeGaussianImageFunction<TInputImage, TOutput>::RecomputeG
158158

159159
// Copy kernel image to neighborhood. Do not copy boundaries.
160160
ImageRegionConstIterator it(kernelImage, kernelRegion);
161-
it.GoToBegin();
162-
unsigned int idx = 0;
161+
unsigned int idx = 0;
163162

164163
while (!it.IsAtEnd())
165164
{

Modules/Filtering/ImageIntensity/include/itkDiscreteHessianGaussianImageFunction.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ DiscreteHessianGaussianImageFunction<TInputImage, TOutput>::RecomputeGaussianKer
164164

165165
// Copy kernel image to neighborhood. Do not copy boundaries.
166166
ImageRegionConstIterator it(kernelImage, kernelRegion);
167-
it.GoToBegin();
168-
unsigned int idx = 0;
167+
unsigned int idx = 0;
169168
while (!it.IsAtEnd())
170169
{
171170
m_KernelArray[kernelidx][idx] = it.Get();

Modules/Filtering/ImageIntensity/include/itkHistogramMatchingImageFilter.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ HistogramMatchingImageFilter<TInputImage, TOutputImage, THistogramMeasurement>::
437437
{
438438
// put each image pixel into the histogram
439439
ImageRegionConstIterator iter(image, image->GetBufferedRegion());
440-
441-
iter.GoToBegin();
442440
while (!iter.IsAtEnd())
443441
{
444442
const InputPixelType & value = iter.Value();

Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ AccumulateImageFilter<TInputImage, TOutputImage>::GenerateData()
181181
}
182182
const typename TInputImage::RegionType AccumulatedRegion(AccumulatedIndex, AccumulatedSize);
183183
ImageRegionConstIterator inputIter(inputImage, AccumulatedRegion);
184-
inputIter.GoToBegin();
185-
AccumulateType Value{};
184+
AccumulateType Value{};
186185
while (!inputIter.IsAtEnd())
187186
{
188187
Value += static_cast<AccumulateType>(inputIter.Get());

Modules/Filtering/ImageStatistics/include/itkImagePCAShapeModelEstimator.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ ImagePCAShapeModelEstimator<TInputImage, TOutputImage>::GenerateData()
166166
{
167167
region = this->GetOutput(j)->GetRequestedRegion();
168168
ImageRegionIterator outIterJ(this->GetOutput(j), region);
169-
170-
outIterJ.GoToBegin();
171169
while (!outIterJ.IsAtEnd())
172170
{
173171
outIterJ.Set(0);

Modules/Filtering/LabelMap/include/itkLabelMapToBinaryImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ LabelMapToBinaryImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateD
123123
{
124124
// fill the background with the background value
125125
ImageRegionIterator oIt(output, outputRegionForThread);
126-
oIt.GoToBegin();
127126

128127
while (!oIt.IsAtEnd())
129128
{

Modules/Filtering/Smoothing/include/itkBinomialBlurImageFilter.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ BinomialBlurImageFilter<TInputImage, TOutputImage>::GenerateData()
184184
//----------------------Reverse pass----------------------
185185
ImageRegionReverseIterator tempReverseIt(tempPtr, tempPtr->GetRequestedRegion());
186186

187-
tempReverseIt.GoToBegin();
188-
189187
while (!tempReverseIt.IsAtEnd())
190188
{
191189
// determine the index of the output pixel

0 commit comments

Comments
 (0)