aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2023-01-11 17:29:57 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2023-01-11 17:29:57 +0200
commit7b2e877a3220879b8dc790a65f0502a35ac36b0d (patch)
treeb7fc95f166d29a48114b6270fd14694b01c7f49b /Software/Visual_Studio
parentdc78b21e274476fcd331d684a68f7a5fd5407422 (diff)
downloadTango-7b2e877a3220879b8dc790a65f0502a35ac36b0d.tar.gz
Tango-7b2e877a3220879b8dc790a65f0502a35ac36b0d.zip
VFT. Bugs in calculate delta LCH ( sign +/-)
Related Work Items: #8000
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs85
1 files changed, 43 insertions, 42 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs
index d6f457a90..5d3ab5504 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs
@@ -1577,53 +1577,54 @@ namespace Tango.PPC.Jobs.Dialogs
double DeltaE_CMC(double L1, double a1, double b1, double L2, double a2, double b2, out double dL, out double dC, out double dH)
{
- double h1 = Math.Atan2(b1, a1) * (180 / Math.PI);
- if (h1 < 0)
- h1 = h1 + 360;
- double h2 = Math.Atan2(b2, a2) * (180 / Math.PI);
- if (h2 < 0)
- h2 = h2 + 360;
- double refX_H = h1;
- //chroma calculation
- double refX_C = Math.Sqrt(a1 * a1 + b1 * b1);
- //reference SL parameter
- double refX_SL;
- if (L1 <= 16)
- refX_SL = 0.511;
+ double SL;
+ if (L1 < 16)
+ SL = 0.511;
else
- refX_SL = L1 * 0.040975 / (1 + 0.01765 * L1);
- //reference SC parameter
- double refX_SC = (0.638 + 0.0638 * refX_C / (1 + 0.0131 * refX_C));
- //reference CQ parameter
- double refX_CQ = Math.Pow(refX_C, 4);
- //reference F parameter
- double refX_F = Math.Sqrt(refX_CQ / (refX_CQ + 1900));
- // reference T parameter
- double refX_T = 0;
- if ((refX_H > 164) & (refX_H < 345))
- refX_T = 0.56 + Math.Abs(0.2 * Math.Cos(Math.PI * (refX_H + 168) / 180));
- else if ((refX_H >= 345) | (refX_H <= 164))
- refX_T = 0.36 + Math.Abs(0.4 * Math.Cos(Math.PI * (refX_H + 35) / 180));
- // reference SH parameter
- double refX_SH = refX_SC * (refX_T * refX_F + 1 - refX_F);
+ SL = L1 * 0.040975 / (1 + 0.01765 * L1);
- //sample parameter calculations
- //hue calculation
- double samX_H = h2;
- //chroma calculation
- double samX_C = Math.Sqrt(a2 * a2 + b2 * b2);
+ //chroma calculation
+ double C1 = Math.Sqrt(a1 * a1 + b1 * b1);
+ double C2 = Math.Sqrt(a2 * a2 + b2 * b2);
+ var deltaC = C1 - C2;
+
+ double SC = (0.0638 * C1 / (1 + 0.0131 * C1)) + 0.638;
+
+ double C1_P4 = Math.Pow(C1, 4);
+ double F = Math.Sqrt(C1_P4 / (C1_P4 + 1900));
+
+ double H1 = Math.Atan2(b1, a1) * (180 / Math.PI);
+ if (H1 < 0)
+ H1 = H1 + 360;
- var dl = L1 - L2;
- var dc = samX_C - refX_C;
- double da = a1 - a2;
- double db = b1 - b2;
- var dh = Math.Sqrt(Math.Max(da * da + db * db - dc * dc, 0.0));
+ double T;
+ if ((H1 >= 164) & (H1 <= 345))
+ T = 0.56 + Math.Abs(0.2 * Math.Cos((H1 + 168) *Math.PI / 180));
+ else //if ((H1 > 345) | (H1 < 164))
+ T = 0.36 + Math.Abs(0.4 * Math.Cos((H1 + 35) *Math.PI / 180));
+
+ double SH = SC * (T * F + 1 - F);
+
+ var deltaL = L1 - L2;
+ //hue calculation
+ double delta_a = a1 - a2;
+ double delta_b = b1 - b2;
+ var deltaH = Math.Sqrt(Math.Max(delta_a * delta_a + delta_b * delta_b - deltaC * deltaC, 0.0));
- double dECMC = Math.Sqrt(Math.Pow(dl / (2 * refX_SL), 2) + Math.Pow(dc / refX_SC, 2) + Math.Pow(dh / refX_SH, 2));
+ double dECMC = Math.Sqrt(Math.Pow(deltaL / (2 * SL), 2) + Math.Pow(deltaC / SC, 2) + Math.Pow(deltaH / SH, 2));
- dL = (dl / (2 * refX_SL));
- dC = (dc / refX_SC);
- dH = (dh / refX_SH);
+ dL = (deltaL / (2 * SL));
+ dC = (deltaC / SC);
+
+ LabColor labColor = new LabColor(L1, a1, b1);
+ LabColor trget_labColor = new LabColor(L2, a2, b2);
+ var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 };
+ var LCH_input = converter.ToLChab(labColor);
+ var LCH_target = converter.ToLChab(trget_labColor);
+ if(LCH_target.h > LCH_input.h)
+ dH = (deltaH / SH) * (-1);
+ else
+ dH = (deltaH / SH);
return dECMC;