Skip to content

Instantly share code, notes, and snippets.

@pepgonzalez
Created April 25, 2013 05:51
Show Gist options
  • Save pepgonzalez/5457778 to your computer and use it in GitHub Desktop.
Save pepgonzalez/5457778 to your computer and use it in GitHub Desktop.
def generaHistogramas(imagen):
pixeles = imagen.load()
x,y = imagen.size
imagen_nueva = Image.new("RGB", (x, y))
hx = dict()
hy = dict()
for j in range(y):
sumax = 0
for i in range(x):
p = pixeles[i,j]
prom = math.ceil(( p[0] +p[1] + p[2] ) / 3.0)
imagen_nueva.putpixel((i,j),(int(prom),int(prom),int(prom)))
if i in hy:
hy[i] += prom
else:
hy[i] = prom
sumax += prom
if j in hx:
hx[j] += sumax
else:
hx[j] = sumax
return hx, hy, imagen_nueva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment