Last active
March 19, 2018 20:03
-
-
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
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, 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing!