Q:

Write a NumPy program to convert a numpy array to an image. Display the image

0

Write a NumPy program to convert a numpy array to an image. Display the image.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

from PIL import Image
import numpy as np
img_w, img_h = 200, 200
data = np.zeros((img_h, img_w, 3), dtype=np.uint8)
data[100, 100] = [255, 0, 0]
img = Image.fromarray(data, 'RGB')
img.save('test.png')
img.show()

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now