Refactoring image statistics computation.