In [16]:
import matplotlib.image as image
import numpy as np
from PIL import Image
color = [0,0,0]
filas, columnas = 200, 200
n = 8
nI = filas/n
nJ = columnas/n
img = np.zeros((filas, columnas, 3))
def pintar(img,x0,x1,y0,y1,color):
for x in range(int(x0),int(x1)):
for y in range(int(y0),int(y1)):
img[x][y] = np.array(color)
imagenes = []
for i in range(4):
if i%2 == 1:
tColor = [0,0,0]
else:
tColor = [1,1,1]
pintar(img,(i+1)*nI,(n-1-i)*nI,(i+1)*nI,(n-1-i)*nI,tColor)
imagenes.append(Image.fromarray(np.uint8(img*255)))
im = Image.fromarray(np.uint8(img*255))
imagenes[0].save('gif.gif',
save_all=True,
append_images=imagenes[1:],
optimize=False,
duration=500,
loop=0)
im
Out[16]:
No hay comentarios.:
Publicar un comentario