finding the mean for each of the channels (RGB) across an array of images How can I find the mean for each of the channels (RGB) across an array of images?
For example train_dataset[0]['image'].shape is (600, 800, 3) and len(train_dataset) is 720 meaning it includes 720 images of dimension 600x800 and 3 channels. train_dataset[0]['image'] is an ndarray.
I am looking to end up with 3 numbers each representing the mean for each of the channels across all these 720 images.
I have this very dumb solution but I wonder if there's a better solution?

I also did it this other way and got almost the same answer:
Could probably be more elegant, but here's an idea:
mean[:, :, 0:2] = np.mean(imgs[:, :, :, 0:2], axis=0)