2016-06-16 4 views
1

이것은 단순한 문제처럼 보입니다. 정확히 colormath을 위해 설계되었습니다. 그러나 convert_color을 호출하면 전달 된 동일한 개체가 반환됩니다. the documentation에 따르면 실패한 변환은 UndefinedConversionError을 발생시키고 개체를 반환하지 않아야합니다.python-colormath가 sRGB를 Adobe RGB로 변환 할 수없는 이유는 무엇입니까?

>>> from colormath.color_objects import sRGBColor, AdobeRGBColor 
>>> from colormath.color_conversions import convert_color 
>>> srgb = sRGBColor(0.0, 1.0, 0.0) 
>>> srgb 
sRGBColor(rgb_r=0.0,rgb_g=1.0,rgb_b=0.0) 
>>> argb = convert_color(srgb, AdobeRGBColor) 
>>> argb 
sRGBColor(rgb_r=0.0,rgb_g=1.0,rgb_b=0.0) 
>>> argb is srgb 
True 

그것은 일이 Lab로 변환 할 않습니다 그래서 문제가 될 수있는 것을 확실 해요.

>>> from colormath.color_objects import LabColor 
>>> convert_color(srgb, LabColor) 
LabColor(lab_l=87.73500278716472,lab_a=-86.1829494051608,lab_b=83.1795364492565) 

답변

1

귀하의 예제를 사용하여 convert_color 정의의 conversion 변수의 내용이, 따라서 정의가 실패하지 않는 수행 할 변환없고 원래로 초기화됩니다 new_color를 반환한다는 것을 의미 빈 목록입니다 sRGB 색상. 왜 이런 경우인지 정확하게 모르겠습니다.

import colour 

colour.RGB_to_RGB(
    (0, 1, 0), 
    colour.sRGB_COLOURSPACE, 
    colour.ADOBE_RGB_1998_COLOURSPACE) 


# array([ 0.28488056, 1.  , 0.04116936]) 
: 또는

, 나는 변환을 추출하지 때문에 경우에 작동 할 또 다른 파이썬 Colour Science API의 메인테이너, 그것은 아마 그러나 colormath 것보다 더 복잡 해요