I am trying to find the average red value of pixels in an image. The code I have written is as follows:
path = "C:\\Users\\Ariana\\Pictures\\img.jpg"
img = PIL.Image.open(path)
imgarray = np.array(img)
reds = imgarray[:, 0]
avered = np.sum(reds)/len(reds)
print(avered)
The output should be at most 255 because this is the highest pixel value it can hold, however, the current output is 275, which should not be possible.
I tried specifying an axis while using np.sum, and I tried using the normal sum function, but both solutions output an array as an answer. Am I slicing the array incorrectly or using np.sum incorrectly?