Skip to content

Instantly share code, notes, and snippets.

@alice-rdz
Created May 9, 2013 16:07
def escala_grises(self):
inicio = time()
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)
fin = time()
tiempo_t = fin - inicio
df = image.save('escala.png')
print self.matriz
raw_input()
return image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment