Skip to content

Instantly share code, notes, and snippets.

@alice-rdz
Created February 12, 2013 07:46
def escala_grises(self):
image = Image.open(self.o_imagen)
pixels = image.load()
ancho,alto = image.size
self.matriz = numpy.empty((ancho, alto))
for i in range(ancho):
for j in range(alto):
(r,g,b) = image.getpixel((i,j))
escala = (r+g+b)/3
pixels[i,j] = (escala,escala,escala)
self.matriz[i,j] = int(escala)
return image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment