Skip to content

Instantly share code, notes, and snippets.

@AdriC1705
Created May 29, 2013 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdriC1705/5670632 to your computer and use it in GitHub Desktop.
Save AdriC1705/5670632 to your computer and use it in GitHub Desktop.
def binario(mat):
ancho = len(mat)
alto = len(mat[0])
nuevo = 0
foto = Image.new('RGBA',(ancho, alto)) #nueva imagen
pixeles = foto.load()
for i in range(ancho):
for j in range(alto):
if mat[i,j]<0:
nuevo = 0
elif mat[i,j]>255:
nuevo = 255
else:
nuevo = int(mat[i,j])
pixeles[i,j] = (nuevo,nuevo,nuevo)
return foto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment