MCPcopy Create free account
hub / github.com/Atarity/Lightpack / toLab

Function toLab

Software/math/PrismatikMath.cpp:209–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207 }
208
209 StructLab toLab(const StructXyz &xyz) {
210
211 double x = xyz.x / refX; //ref_X = 95.047 Observer= 2°, Illuminant= D65
212 double y = xyz.y / refY; //ref_Y = 100.000
213 double z = xyz.z / refZ; //ref_Z = 108.883
214
215 if ( x > 0.008856 )
216 x = pow(x, 1.0/3);
217 else
218 x = (7.787 * x) + ( 16.0 / 116 );
219
220 if ( y > 0.008856 )
221 y = pow(y, 1.0/3);
222 else
223 y = (7.787 * y) + (16.0 / 116);
224
225 if ( z > 0.008856 )
226 z = pow(z, 1.0/3);
227 else
228 z = (7.787 * z) + (16.0 / 116);
229
230 StructLab result;
231 result.l = round((116 * y) - 16);
232 result.a = withinRange<double, char>(round(500 * ( x - y )), -128, 127);
233 result.b = withinRange<double, char>(round(200 * ( y - z )), -128, 127);
234
235 return result;
236 }
237
238 StructLab toLab(const StructRgb &rgb) {
239 return toLab(toXyz(rgb));

Callers 1

Calls 2

roundFunction · 0.85
toXyzFunction · 0.85

Tested by

no test coverage detected