I need to display an image’s average red value per pixel. I tried using the code below:
path = "C:\\Users\\dc\\Images\\image1.jpg"
img = PIL.Image.open(path)
imgarray = np.array(image1)
reds = imgarray[:, 0]
avered = np.sum(reds)/len(reds)
print(avered)
The output was not as expected.
Is there anything to change with arrays?
Using
np.mean
instead ofnp.sum
might bring proper results.