Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mrkn
Last active March 19, 2018 20:03
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkn/28f95f95731a5a24e553 to your computer and use it in GitHub Desktop.
Save mrkn/28f95f95731a5a24e553 to your computer and use it in GitHub Desktop.
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")
lab_im = ImageCms.applyTransform(im, rgb2lab_transform)
@goks
Copy link

goks commented Dec 19, 2016

How do you write the lab_im to a file as an image?

lab_im.save('worker.jpg') 

didnt work.

@fantauzzi
Copy link

Thank you for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment