Created
August 21, 2018 11:37
-
-
Save topin89/4c73b92afe1f5a68fbf7faa6976d3031 to your computer and use it in GitHub Desktop.
Custom lookup table for Pillow and Numpy
This file contains 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
from PIL import Image | |
import numpy as np | |
IM_LUT=np.array([(255,255,255,255),(0,0,0,255), | |
(255,0,0,255),(0,255,0,255),(0,0,255,255), | |
(255,255,0,255),(255,0,255,255),(0,255,255,255), | |
(128,0,0,255),(0,128,0,255),(0,0,128,255), | |
(128,128,0,255),(128,0,128,255),(0,128,128,255), | |
(128,255,0,255),(128,0,255,255),(0,128,255,255), | |
(255,128,0,255),(255,0,128,255),(0,255,128,64),] | |
).astype(np.uint8)# Your lut here, preferebally 256 entries | |
image_data = np.zeros((width, height), dtype=np.uint8) #Your data here | |
Image.fromarray(IM_LUT[image_data], 'RGBA').save("image.bmp") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment