Convert RGB Image Into Greyscale Image

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’)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s