Last active
April 5, 2019 12:18
-
-
Save daguiam/3c48b8bd77fc4892d654bad8eb315ce7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
def save_array_as_image(array, filename): | |
"""Saves a 2D numpy array to an image""" | |
image = Image.fromarray(array) | |
image.save(filename) | |
array = np.random.random((512,512))*255 | |
array = np.uint8(array) | |
print(array) | |
save_array_as_image(array, "image.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment