ralph-schleicher / rs-colors

A color data type for Common Lisp.
17 stars 5 forks source link

Can't convert to CIE L*a*b* #1

Closed sjl closed 8 years ago

sjl commented 8 years ago

I'm trying to convert colors to lab (to implement one of these color difference measures), but getting an error when converting:

[ClozureCL] SAND.COLOR-DIFFERENCE> (cie-lab-color-coordinates (make-cie-xyz-color 0 0 0))
> Error: There is no applicable method for the generic function:
>          #<STANDARD-GENERIC-FUNCTION CIE-XYZ-COLOR-COORDINATES #x30200468AB3F>
>        when called with arguments:
>          (NIL)
...
 (210669B0) : 0 (FUNCALL #'#<#<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD (T)>> #<STANDARD-GENERIC-FUNCTION CIE-XYZ-COLOR-COORDINATES #x30200468AB3F> NIL) 149
 (210669F8) : 1 (CIE-LAB-FROM-CIE-XYZ 0 0 0 NIL) 69
 (21066A38) : 2 (CALL-CHECK-REGS CIE-LAB-COLOR-COORDINATES #<CIE-XYZ-COLOR (0 0 0) #x302004B44C7D>) 221
 (21066A70) : 3 (TOPLEVEL-EVAL (CIE-LAB-COLOR-COORDINATES (MAKE-CIE-XYZ-COLOR 0 0 0)) NIL) 693
sjl commented 8 years ago

I'm pretty sure the issue starts somewhere around https://github.com/ralph-schleicher/rs-colors/blob/master/cie-lab.lisp#L126 where it's calling (white-point ...) on the ciexyz color (which doesn't have a white point).

ralph-schleicher commented 8 years ago

Should work now.

 (change-class (make-cie-rgb-color 1 0 0) 'cie-lab-color)
   ==>  #<CIE-LAB-COLOR (49.12652f0 118.28679548921406 84.70089723323953) {10073E8F53}>