@@ -29,17 +29,6 @@ function DistanceDeltaE_UnRolled(const C1: PColorLAB; const C2: TColorBGRA; cons
29
29
30
30
implementation
31
31
32
- // 2-4x speedup over Power(x, 1/3) in LAB colorspace finding
33
- function Cbrt (x: Single): Single; inline;
34
- begin
35
- Result := Sqrt(x);
36
- Result := (2.0 * Result + x / Sqr(Result)) / 3.0 ;
37
- Result := (2.0 * Result + x / Sqr(Result)) / 3.0 ;
38
- Result := (2.0 * Result + x / Sqr(Result)) / 3.0 ;
39
- // Result := (2.0 * Result + x / Sqr(Result)) / 3.0; // Can't see that we need one more
40
- end ;
41
-
42
-
43
32
function DistanceRGB_UnRolled (const C1: PColorRGB; const C2: TColorBGRA; const mul: TChannelMultipliers): Single;
44
33
begin
45
34
Result := Sqrt(Sqr((C1^.R-C2.R) * mul[0 ]) + Sqr((C1^.G-C2.G) * mul[1 ]) + Sqr((C1^.B-C2.B) * mul[2 ]));
@@ -196,11 +185,11 @@ function DistanceLAB_UnRolled(const C1: PColorLAB; const C2: TColorBGRA; const m
196
185
Y := (vR * 0.2126 + vG * 0.7152 + vB * 0.0722 ) * D65_Yn_Inv;
197
186
Z := (vR * 0.0193 + vG * 0.1192 + vB * 0.9505 ) * D65_Zn_Inv;
198
187
199
- if X > 0.008856 then X := Cbrt (X)
188
+ if X > 0.008856 then X := fcbrt (X)
200
189
else X := (7.787 * X) + 0.137931 ;
201
- if Y > 0.008856 then Y := Cbrt (Y)
190
+ if Y > 0.008856 then Y := fcbrt (Y)
202
191
else Y := (7.787 * Y) + 0.137931 ;
203
- if Z > 0.008856 then Z := Cbrt (Z)
192
+ if Z > 0.008856 then Z := fcbrt (Z)
204
193
else Z := (7.787 * Z) + 0.137931 ;
205
194
206
195
Color2.L := (116.0 * Y) - 16.0 ;
@@ -234,11 +223,11 @@ function DistanceLCH_UnRolled(const C1: PColorLCH; const C2: TColorBGRA; const m
234
223
Y := (vR * 0.2126 + vG * 0.7152 + vB * 0.0722 ) * D65_Yn_Inv;
235
224
Z := (vR * 0.0193 + vG * 0.1192 + vB * 0.9505 ) * D65_Zn_Inv;
236
225
237
- if X > 0.008856 then X := Cbrt (X)
226
+ if X > 0.008856 then X := fcbrt (X)
238
227
else X := (7.787 * X) + 0.137931 ;
239
- if Y > 0.008856 then Y := Cbrt (Y)
228
+ if Y > 0.008856 then Y := fcbrt (Y)
240
229
else Y := (7.787 * Y) + 0.137931 ;
241
- if Z > 0.008856 then Z := Cbrt (Z)
230
+ if Z > 0.008856 then Z := fcbrt (Z)
242
231
else Z := (7.787 * Z) + 0.137931 ;
243
232
244
233
L := (116.0 * Y) - 16.0 ;
@@ -298,11 +287,11 @@ function DistanceDeltaE_UnRolled(const C1: PColorLAB; const C2: TColorBGRA; cons
298
287
Y := (vR * 0.2126 + vG * 0.7152 + vB * 0.0722 ) * D65_Yn_Inv;
299
288
Z := (vR * 0.0193 + vG * 0.1192 + vB * 0.9505 ) * D65_Zn_Inv;
300
289
301
- if X > 0.008856 then X := Cbrt (X)
290
+ if X > 0.008856 then X := fcbrt (X)
302
291
else X := (7.787 * X) + 0.137931 ;
303
- if Y > 0.008856 then Y := Cbrt (Y)
292
+ if Y > 0.008856 then Y := fcbrt (Y)
304
293
else Y := (7.787 * Y) + 0.137931 ;
305
- if Z > 0.008856 then Z := Cbrt (Z)
294
+ if Z > 0.008856 then Z := fcbrt (Z)
306
295
else Z := (7.787 * Z) + 0.137931 ;
307
296
308
297
Color2.L := (116.0 * Y) - 16.0 ;
0 commit comments