Created
April 8, 2017 09:30
-
-
Save walsvid/e5048001b4ff89b6a7e1aec4b5bb41f1 to your computer and use it in GitHub Desktop.
How to convert between NumPy array and PIL Image
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 | |
import PIL | |
# Convert Image to array | |
img = PIL.Image.open("foo.jpg").convert("L") | |
arr = numpy.array(img) | |
# Convert array to Image | |
img = PIL.Image.fromarray(arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This helped.