How to find the mean and Std of a 3 channel image
from numpy import asarray
from PIL import Image

image = Image.open('../input/chest-xray-pneumonia/chest_xray/train/NORMAL/IM-0115-0001.jpeg')
pixels = asarray(image)

pixels = pixels.astype('float32')
means = pixels.mean(axis=(0,1), dtype='float64')
stds = pixels.std(axis=(0,1), dtype='float64')
print('Means: %s, Stds: %s' % (means, stds))
pixels = (pixels - means) / stds
means = pixels.mean(axis=(0,1), dtype='float64')
stds = pixels.std(axis=(0,1), dtype='float64')
print('Means: %s, Stds: %s' % (means, stds))''' 

output&gt;&gt; Means: 128.90747832983968, Stds: 62.30103035552067  
         Means: 1.2235509834827096e-07, Stds: 1.0000000181304383

The problem is while putting 3 channel image ,only got two values each

Separate the image channels into r,g,b using OpenCV,
Then use numpy mean and std function to calculate the mean and standard deviations for each channel.
Example for separating the image into rgb channels.
import cv2
import numpy as np

img = cv2.imread(&quot;image.jpg&quot;)
b = img[:,:,0]
g = img[:,:,1]
r = img[:,:,2]

