Help us understand the problem. What is going on with this article?

PIL (Pillow) で RGB から CIELAB へ色空間を変換する

More than 3 years have passed since last update.

RGB と CIELAB の間の相互変換は PIL.Image.convert ではなく、PIL.ImageCms を使って行なう。

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)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away