I have few gray scale images and I thought of calculating the average pixel value of the total image, so that I can represent each individual image using a single value.
解决方案
If you want to do stuff like this, you should consider using scikit-image instead of raw PIL or pillow.
SciKit Image uses numpy arrays for images, so all the numpy methods work.
from skimage import io
import numpy as np
image = io.imread('http://i.stack.imgur.com/Y8UeF.jpg')
print(np.mean(image))
You might want to convert all images to float to get a value betwenn 0 and 1:
from skimage import io, img_as_float
import numpy as np
image = io.imread('http://i.stack.imgur.com/Y8UeF.jpg')
image = img_as_float(image)
print(np.mean(image))