Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from PIL import Image
import numpy as np
img = Image.open('img.jpg', "r")
pixels = np.asarray(img)
add = [0,0,0]
index = 0
for row in pixels:
for pixel in row:
add += pixel
index += 1
result = add/index
result_list = []
for x in result:
result_list.append(int(round(x)))
print ('#%02x%02x%02x' % tuple(result_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.