reusable sanitize method for gradient arrays

because we also need that in GradientGlowFilter