# Custom border extrapolation of ShapedImageNeighborhoodRange by ImageNeighborhoodPixelAccessPolicy

**URL:** <https://discourse.itk.org/t/custom-border-extrapolation-of-shapedimageneighborhoodrange-by-imageneighborhoodpixelaccesspolicy/879>\
**Category:** Engineering\
**Created:** [April 30, 2018, 6:02pm UTC](https://discourse.itk.org/t/custom-border-extrapolation-of-shapedimageneighborhoodrange-by-imageneighborhoodpixelaccesspolicy/879 "2018-04-30T18:02:39Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [November 8, 2018, 11:27am UTC](https://discourse.itk.org/t/custom-border-extrapolation-of-shapedimageneighborhoodrange-by-imageneighborhoodpixelaccesspolicy/879/30 "2018-11-08T11:27:24Z")

</div>

@matt.mccormick Thanks for your extensive performance tests! Very interesting! Clearly the new range-based iterators aren’t _always_ faster (anymore) than the “old-school” NeighborhoodIterator classes, especially now that the old iterator classes have received some major PERF updates. 🤔 However, the new iterators will potentially be much faster than the old ones when the neighborhood location has to be reset frequently (for example, by means of `SetLocation`). As I observed with `GaussianDerivativeImageFunction`. Also I believe that the new range-based iterators could be significantly faster than the old ones on arbitrary neighborhood shapes (rather than just rectangular shapes). 😀

> [@matt.mccormick](#):
>
> +1 to this API – setting the constant value separately from the range initialization is easier to follow, in my opinion.

Sorry but I’m not really convinced. Allowing to modify the constant padding value _after_ range initialization might make things _harder_ to follow, in my opinion. Especially when the padding value is modified _after_ retrieving iterators from the range (using `begin()` and `end()`). It would yield the question whether such a modification would still affect these iterators. It seems clearer to me to specify the constant padding value as part of the range initialization so that it would then clearly remain constant.

(There’s also the design issue that current `ShapedImageNeighborhoodRange` class does _not_ have a policy data member, as I explained at [Custom border extrapolation of ShapedImageNeighborhoodRange by ImageNeighborhoodPixelAccessPolicy - #25 by phcerdan](https://discourse.itk.org/t/custom-border-extrapolation-of-shapedimageneighborhoodrange-by-imageneighborhoodpixelaccesspolicy/879/25))

Anyway, please go ahead if you would like to merge [ENH: Added policy for constant NeighborhoodRange values outside image by hjmjohnson · Pull Request #105 · InsightSoftwareConsortium/ITK · GitHub](https://github.com/InsightSoftwareConsortium/ITK/pull/105) I haven’t yet got the GitHub/ITK entirely up and running but if @hjmjohnson would like to do the merge, please do!

---

_[View the full topic](https://discourse.itk.org/t/custom-border-extrapolation-of-shapedimageneighborhoodrange-by-imageneighborhoodpixelaccesspolicy/879)._
