Grayscale image has equal red, green and blue values:
R = G = B
For each image pixel with red, green and blue values of (R,G,B):
R’ = G’ = B’ = (R+G+B) / 3
Pixel with RGB values of (30,128,255)
The red level R=30.
The green level G=128.
The blue level B=255.
R’ = G’ = B’ = (R+G+B) / 3 = (30+128+255) / 3 = 138
so the pixel will get RGB values of:
(138,138,138)
program in sagemath:-
from matplotlib import image
img =image.imread(‘picture.png’)
a=(img[: , : , 1]+img[ : , : , 2]+img[ : , : ,0 ] )/ 3
image.imsave(‘b.png’,a, cmap = ‘gray’)