In [8]:
import matplotlib.pyplot as plt
import matplotlib.image as image
import numpy as np
img = image.imread("img/banana.png")
# porcesando
img2 = np.zeros(img.shape)
for i in range(img.shape[0]):
for j in range(img.shape[1]):
if sum(img[i][j]) > 1.5:
img2[i][j] = np.array([0,0,1])
else:
img2[i][j] = np.array([0,0,0])
fig, axs = plt.subplots(1, 2)
axs[0].imshow(img)
axs[1].imshow(img2)
plt.savefig('imagen.png')
Para guardar una imagen, simplemente usamos savefig de matplotlib.
No hay comentarios.:
Publicar un comentario