POV-Ray : Newsgroups : povray.advanced-users : L*C*h(uv) color solid : Re: L*C*h(uv) color solid Server Time
28 Sep 2024 17:48:34 EDT (-0400)
  Re: L*C*h(uv) color solid  
From: Mike Horvath
Date: 20 Nov 2016 00:51:14
Message: <583139d2$1@news.povray.org>
On 11/20/2016 12:09 AM, clipka wrote:
> Am 20.11.2016 um 04:47 schrieb Mike Horvath:
>> I'm having a problem converting between units. Here is the code I'm
>> trying to adapt to POV-Ray:
>>
>>    
https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Conversions/LchConverter.cs
>>
>>
>>         internal static IRgb ToColor(ILch item)
>>         {
>>             var hRadians = item.H * Math.PI / 180.0;
>>             var lab = new Lab
>>                 {
>>                     L = item.L,
>>                     A = Math.Cos(hRadians) * item.C,
>>                     B = Math.Sin(hRadians) * item.C
>>                 };
>>             return lab.To<Rgb>();
>>         }
> ...
>
>>
>> Here is the POV-Ray version I created:
>>
>>     // input L = between 0 and 100
>>     // input C = between 0 and 100
>>     // input H = between 0 and 360
>>     // output L = between 0 and 100
>>     // output A = between -128 and +128
>>     // output B = between -128 and +128
>>     #macro CLCH2LAB(Color)
>>         #local LCHFT = color Color;
>>         #local L = LCHFT.red;
>>         #local C = LCHFT.green;
>>         #local H = LCHFT.blue;
>>         #local hRadians = radians(H);
>>         #local A = cos(hRadians) * C;
>>         #local B = sin(hRadians) * C;
>>         <L,A,B>
>>     #end
>>
>> When I plug the vector <50,50,180> into this function I get
>> <50.00000,-50.00000,0.00000> as a result. However, the Web converter
>> (http://colormine.org/convert/lch-to-lab) says it should be
>> <51.622535970468874,-37.18943330724933,2.558221480506817>
>>
>> It's a simple function. I don't see anything obvious that is wrong with
>> it. Do you?
>
> I see something obviously wrong with the web converter: the "CIE-L*ab"
> (whatever colour space that even is supposed to be; L*a*b, maybe?)
> result it computes cannot possibly be the same as the "lab" interim
> result computed by the `ToColor` function you've posted, as that leaves
> the "L" component entirely untouched, so it should evaluate to 50.
>
> Judging from the results the web converter computes for Lch to XYZ,
> which gives out-of-range values for an obviously within-range Lch value
> of <50,50,180>, that web converter can't be trusted.
>
> The first other web converter I've tested does convert "Lch" <50,50,180>
> to "Lab" <50,-50,0>, matching your implementation.
>


THANK YOU!!

Which other converter did you use, BTW? I need to do the same for 
LAB>XYZ and XYZ>RGB as well.

Mike


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.