Created
June 1, 2020 08:04
-
-
Save Allwin12/c0030bbba006bfaf43dcf33913d40ded to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import math | |
# creating a image object | |
img = Image.open('selenagomez.png') | |
px = img.load() | |
height, width = img.size | |
new_image = Image.new(img.mode, img.size) | |
for row in range(0, height): | |
for column in range(0, width): | |
red, blue, green = px[row, column] | |
avg = math.floor((red + blue + green)/3) | |
new_image.putpixel((row, column), (avg, avg, avg)) | |
new_image.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment