Skip to content

Instantly share code, notes, and snippets.

View goks's full-sized avatar
💭
Focus until you are there!

Gokul goks

💭
Focus until you are there!
View GitHub Profile
@mrkn
mrkn / rgb2lab.py
Last active March 19, 2018 20:03
color space conversion from RGB to CIELAB in PIL/Pillow (Japanese article) ref: http://qiita.com/mrkn/items/670e1622d41d2dcd26b4
from PIL import Image, ImageCms
im = Image.open(image_path)
if im.mode != "RGB":
im = im.convert("RGB")
srgb_profile = ImageCms.createProfile("sRGB")
lab_profile = ImageCms.createProfile("LAB")
rgb2lab_transform = ImageCms.buildTransformFromOpenProfiles(srgb_profile, lab_profile, "RGB", "LAB")