I am working on a program that takes a screenshot and saves the pixels in a Numpy Array with 3 axis (X, Y, and the RGB value itself) and cannot properly sum the last axis.
I have searched up information on this topic, and although I have tried several things such as "Axis=2" I have made no progress. I would like to stay away from for loops. Because although they work I feel as though that defeats the purpose of sum in the first place.
#Imports
import numpy as np
from PIL import ImageGrab
#Define Hight and Width of screen
height = 1080
width = 1920
#Capture screen with by taking individual RGB values in an array
screen = np.array(ImageGrab.grab(bbox=(0,0,width,height)))
red = np.sum(screen[[0][0]])
green = np.sum(screen[[1][0]])
blue = np.sum(screen[[2][0]])
print(red,blue,green)
I am hoping to get the result that the variables red green and blue show their respective value of the sum of all of the pixels on the screen, however I am currently getting "1468800" for all of them. Any help is appreciated, Thanks.