MATH: Refactor of math::algo::kernel_region()
MVE: Refactor imagetools.cc