Skip to content

Use ImageRegionIterator without "WithIndex" in *.hxx files #5848

Draft
N-Dekker wants to merge 3 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Use-ImageRegionIterators-without-Index
Draft

Use ImageRegionIterator without "WithIndex" in *.hxx files #5848
N-Dekker wants to merge 3 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Use-ImageRegionIterators-without-Index

Conversation

@N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Mar 1, 2026

Replaced ImageRegionIteratorWithIndex with ImageRegionIterator, and replaced
ImageRegionConstIteratorWithIndex with ImageRegionConstIterator, in cases
where the index of the iterator was not used.

When the index is not needed, ImageRegionIterator and ImageRegionConstIterator
are much faster than the corresponding iterators "with index"!

Aims to speed up the following filters:

  • BinomialBlurImageFilter
  • EigenAnalysis2DImageFilter
  • GradientRecursiveGaussianImageFilter
  • HessianRecursiveGaussianImageFilter
  • HoughTransform2DLinesImageFilter
  • VoronoiPartitioningImageFilter
  • VoronoiSegmentationImageFilter
  • VoronoiSegmentationImageFilterBase
  • VoronoiSegmentationRGBImageFilter

As well as:

  • GradientDifferenceImageToImageMetric
  • MetaImageConverter
  • PeakSignalToNoiseRatioCalculator
  • RobustAutomaticThresholdCalculator

@github-actions github-actions bot added area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Numerics Issues affecting the Numerics module labels Mar 1, 2026
@N-Dekker N-Dekker changed the title Use ImageRegionIterator without "WithIndex" in *.hxx files Use ImageRegionIterator without "WithIndex" in *.hxx files Mar 1, 2026
N-Dekker added 3 commits March 1, 2026 13:06
ImageToImageMetric uses ImageRegionConstIteratorWithIndex  internally.
Paved the way to remove `ImageRegionIteratorWithIndex` uses from various
`itk*.hxx` files.
Replaced `ImageRegionIteratorWithIndex` with `ImageRegionIterator`, and replaced
`ImageRegionConstIteratorWithIndex` with `ImageRegionConstIterator`, in cases
where the index of the iterator was not used.

When the index is not needed, `ImageRegionIterator` and `ImageRegionConstIterator`
are _much_ faster than the corresponding iterators "with index"!

Aims to speed up the following filters:
- BinomialBlurImageFilter
- EigenAnalysis2DImageFilter
- GradientRecursiveGaussianImageFilter
- HessianRecursiveGaussianImageFilter
- HoughTransform2DLinesImageFilter
- VoronoiPartitioningImageFilter
- VoronoiSegmentationImageFilter
- VoronoiSegmentationImageFilterBase
- VoronoiSegmentationRGBImageFilter

As well as:
- GradientDifferenceImageToImageMetric
- MetaImageConverter
- PeakSignalToNoiseRatioCalculator
- RobustAutomaticThresholdCalculator

Found by regular expression ` ImageRegionIteratorWithIndex(?!.*\.GetIndex\(\))`
and ` ImageRegionConstIteratorWithIndex(?!.*\.GetIndex\(\))`.
@N-Dekker N-Dekker force-pushed the Use-ImageRegionIterators-without-Index branch from ef2e670 to 4df6928 Compare March 1, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Python wrapping Python bindings for a class area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant