factorized some code between the uniform and adaptive image samplers.