Computing the image histogram