gtaylor / python-colormath

A python module that abstracts common color math operations. For example, converting from CIE L*a*b to XYZ, or from RGB to CMYK
python-colormath.readthedocs.org
BSD 3-Clause "New" or "Revised" License
456 stars 83 forks source link

Convert from hsv to cielab #57

Closed hamburml closed 9 years ago

hamburml commented 9 years ago

Hi!

I am working with Blender and write a Addon for procedural mesh generation. I use colormath to convert rgb/hsv to cielab because I want to interpolate in cielab-colorspace (see http://howaboutanorange.com/blog/2011/08/10/color_interpolation/).

I think I am doing something wrong...

H: 208 S: 100 V: 100 (or H:0.58 S: 1 V: 1) is according to http://colormine.org/color-converter in Cielab L 55.8 A: 16.3 and B: -69.1

If I use colormath I get lab_l: 53.29 lab_a: 79.92 lab_b: 67.22

Here is a short code snippet:

   old_color_hsv = HSVColor(old_color[0], old_color[1], old_color[2])
   old_color_cielab = convert_color(old_color_hsv, LabColor)   # convert
   print("old_color_cielab", old_color_cielab)

Any ideas?

hamburml commented 9 years ago

Meh I think I have got it... I am searching for some time before I write an Issue and after I wrote it I know what I did wrong. :(

Blender's color picker values are already linear srgb values instead of "normal" rgb values. So I can do this (see code) and skip the HSVColor-Part.

 old_color_srgb = sRGBColor(old_color_rgb_gamma[0], old_color_rgb_gamma[1], old_color_rgb_gamma[2])
 old_color_cielab = convert_color(old_color_srgb, LabColor)   # convert
 print("old_color_cielab", old_color_cielab)