This could be avoided by implementing the _slanted_integral_image differently, see my comment in line 80.