put some protection against too large pixel values in boundaries()
otherwise FPE is generated