Skip to content

Commit c4a34f0

Browse files
authored
Merge pull request InsightSoftwareConsortium#6019 from N-Dekker/Simplify-local-region-iterator-initializations-hxx
Simplify initialization of local region iterators in hxx files
2 parents c4fcb5e + d866701 commit c4a34f0

7 files changed

Lines changed: 21 additions & 35 deletions

File tree

Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ BinaryMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::AnalyzeKernel()
114114
tmpSEImage->Allocate();
115115

116116
// copy
117-
ImageRegionIterator<BoolImageType> kernelImageIt; // iterator on image
118-
kernelImageIt = ImageRegionIterator(tmpSEImage, tmpSEImage->GetRequestedRegion());
117+
ImageRegionIterator kernelImageIt(tmpSEImage, tmpSEImage->GetRequestedRegion());
119118

120119
kernel_it = KernelBegin;
121120

Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::BeforeThreadedG
9898

9999
const RegionType requestedRegion = this->GetOutput()->GetRequestedRegion();
100100

101-
auto iRegIter = ImageRegionConstIterator(this->GetInput(), requestedRegion);
102-
auto oRegIter = ImageRegionIterator(this->GetOutput(), requestedRegion);
101+
ImageRegionConstIterator iRegIter(this->GetInput(), requestedRegion);
102+
ImageRegionIterator oRegIter(this->GetOutput(), requestedRegion);
103103
/* Copy the input image to the output image - then only boundary pixels
104104
* need to be changed in the output image */
105105
while (!oRegIter.IsAtEnd())

Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ Hessian3DToVesselnessMeasureImageFilter<TPixel>::GenerateData()
5151
const typename EigenValueOutputImageType::ConstPointer eigenImage = m_SymmetricEigenValueFilter->GetOutput();
5252

5353
// walk the region of eigen values and get the vesselness measure
54-
EigenValueArrayType eigenValue;
55-
ImageRegionConstIterator it(eigenImage, eigenImage->GetRequestedRegion());
56-
ImageRegionIterator<OutputImageType> oit;
54+
EigenValueArrayType eigenValue;
55+
ImageRegionConstIterator it(eigenImage, eigenImage->GetRequestedRegion());
5756
this->AllocateOutputs();
58-
oit = ImageRegionIterator(output, output->GetRequestedRegion());
57+
ImageRegionIterator oit(output, output->GetRequestedRegion());
5958
while (!it.IsAtEnd())
6059
{
6160
// Get the eigen value

Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ ZeroCrossingImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
123123
bit.OverrideBoundaryCondition(&nbc);
124124
bit.GoToBegin();
125125

126-
static constexpr SizeValueType neighborhoodSize = Math::UnsignedPower(3, ImageDimension);
127-
static constexpr SizeValueType center = neighborhoodSize / 2;
128-
ImageRegionIterator<TOutputImage> it = ImageRegionIterator(output, face);
126+
static constexpr SizeValueType neighborhoodSize = Math::UnsignedPower(3, ImageDimension);
127+
static constexpr SizeValueType center = neighborhoodSize / 2;
128+
ImageRegionIterator it(output, face);
129129
while (!bit.IsAtEnd())
130130
{
131131
const InputImagePixelType this_one = bit.GetPixel(center);

Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,13 @@ CurvatureRegistrationFilter<TFixedImage, TMovingImage, TDisplacementField, TImag
204204
(void)dt;
205205
const DisplacementFieldPointer update = this->GetUpdateBuffer();
206206

207-
ImageRegionConstIterator<DisplacementFieldType> itInDeformation;
208-
ImageRegionIterator<DisplacementFieldType> itOutDeformation;
209-
ImageRegionConstIterator<DisplacementFieldType> itInUpdate;
210-
ImageRegionConstIteratorWithIndex<FixedImageType> fixedImageIteratorWithIndex;
211-
212-
itInDeformation =
213-
ImageRegionConstIterator(this->GetDisplacementField(), this->GetDisplacementField()->GetLargestPossibleRegion());
214-
itOutDeformation =
215-
ImageRegionIterator(this->GetDisplacementField(), this->GetDisplacementField()->GetLargestPossibleRegion());
216-
itInUpdate = ImageRegionConstIterator(update, update->GetLargestPossibleRegion());
217-
fixedImageIteratorWithIndex = ImageRegionConstIteratorWithIndex<FixedImageType>(
218-
this->GetFixedImage(), this->GetFixedImage()->GetLargestPossibleRegion());
207+
ImageRegionConstIterator itInDeformation(this->GetDisplacementField(),
208+
this->GetDisplacementField()->GetLargestPossibleRegion());
209+
ImageRegionIterator itOutDeformation(this->GetDisplacementField(),
210+
this->GetDisplacementField()->GetLargestPossibleRegion());
211+
ImageRegionConstIterator itInUpdate(update, update->GetLargestPossibleRegion());
212+
ImageRegionConstIteratorWithIndex fixedImageIteratorWithIndex(this->GetFixedImage(),
213+
this->GetFixedImage()->GetLargestPossibleRegion());
219214

220215
const SizeValueType numberOfPixels = this->GetFixedImage()->GetLargestPossibleRegion().GetNumberOfPixels();
221216

Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,9 @@ ExtensionVelocitiesImageFilter<TLevelSet, TAuxValue, VAuxDimension>::GenerateDat
143143
const double levelSetValue = this->GetLevelSetValue();
144144

145145
// define iterators
146-
using LocalLevelSetImageType = typename LevelSetType::LevelSetImageType;
147-
148146
ImageRegionConstIterator inputIt(inputPtr, inputPtr->GetBufferedRegion());
149147
ImageRegionIterator outputIt(outputPtr, outputPtr->GetBufferedRegion());
150148

151-
ImageRegionIterator<LocalLevelSetImageType> tempIt;
152-
153-
154149
ImageRegionIterator<AuxImageType> auxTempIt[VAuxDimension];
155150
ImageRegionIterator<AuxImageType> auxOutputIt[VAuxDimension];
156151

@@ -178,7 +173,7 @@ ExtensionVelocitiesImageFilter<TLevelSet, TAuxValue, VAuxDimension>::GenerateDat
178173
m_Marcher->SetAuxiliaryTrialValues(m_Locator->GetModifiableAuxOutsideValues());
179174
m_Marcher->Update();
180175

181-
tempIt = ImageRegionIterator(tempLevelSet, tempLevelSet->GetBufferedRegion());
176+
ImageRegionIterator tempIt(tempLevelSet, tempLevelSet->GetBufferedRegion());
182177

183178
for (unsigned int k = 0; k < VAuxDimension; ++k)
184179
{

Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ Segmenter<TInputImage>::CollectBoundaryInformation(flat_region_table_t & flatReg
336336
const ImageRegionType region = face->GetRequestedRegion();
337337

338338
// Grab all the labels of the boundary pixels.
339-
ImageRegionIterator<typename BoundaryType::face_t> faceIt =
340-
ImageRegionIterator<typename BoundaryType::face_t>(face, region);
339+
ImageRegionIterator faceIt(face, region);
341340
ImageRegionIterator labelIt(output, region);
342341
faceIt.GoToBegin();
343342
labelIt.GoToBegin();
@@ -443,10 +442,9 @@ Segmenter<TInputImage>::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage
443442
const typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx);
444443
const ImageRegionType region = face->GetRequestedRegion();
445444

446-
ConstNeighborhoodIterator<InputImageType> searchIt(rad, thresholdImage, region);
447-
NeighborhoodIterator<OutputImageType> labelIt(rad, output, region);
448-
ImageRegionIterator<typename BoundaryType::face_t> faceIt =
449-
ImageRegionIterator<typename BoundaryType::face_t>(face, region);
445+
ConstNeighborhoodIterator<InputImageType> searchIt(rad, thresholdImage, region);
446+
NeighborhoodIterator<OutputImageType> labelIt(rad, output, region);
447+
ImageRegionIterator faceIt(face, region);
450448

451449
const unsigned int nCenter = searchIt.Size() / 2;
452450
searchIt.GoToBegin();

0 commit comments

Comments
 (0)