Skip to content

Instantly share code, notes, and snippets.

@abrahamjso
Created February 13, 2013 06:34
Comparación de putpixel y getpixel ante el uso de arreglo y la función load de PIL, en la manipulación y procesamiento de imagenes.
def grayScale(self):
start = time.time()
self.rgb = self.img.convert('RGB')
for i in range(self.img.size[0]):
for j in range(self.img.size[1]):
r = self.rgb.getpixel((i, j))[0]
g = self.rgb.getpixel((i, j))[1]
b = self.rgb.getpixel((i, j))[2]
media = (r+g+b)/3
pixel = tuple([media, media, media])
self.img.putpixel((i, j), pixel)
self.img.save('grayScale.png', 'PNG')
end = time.time()
print 'Tiempo tomado: '+str(end-start)
return self.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment