/// <inheritdoc cref="object" /> public bool Equals(HunterLabColor other) => L.Equals(other.L) && a.Equals(other.a) && b.Equals(other.b);
private void colorMeasurment() { if (!IsRun) { return; } chart1.Series["palete"].Points.Clear(); // float[] T = dtAnalys.Transmittance(numSmoothing, darkData, refrenceData); float X = 0; float Y = 0; float Z = 0; float x = X; // ( X / (X + Y + Z)) ; float y = Y; // (Y / (X + Y + Z)); float z = Z; // =( 1 - (x + y) ); int k = 0; float Kcolor = 0; int[] colordt = new int[500]; if (dt1 == null) { return; } //int result; //int s = 0; //for (int m = 80; m < 1270; m++) //{ // Math.DivRem(Convert.ToInt32(xvalue [m]), 5, out result); // if (result == 0) // { // colordt [s] = Convert.ToInt32(xvalue [m]); // s++; // } //} colordt = colordt.Distinct().ToArray(); if (rdA.Checked && rd2.Checked) { for (int m = 0; m < 79; m++) { if (m == 78) { X = X + (A[m - 1] * X2[m - 1] * dt1[m]); Y = Y + (A[m - 1] * Y2[m - 1] * dt1[m]); Z = Z + (A[m - 1] * Z2[m - 1] * dt1[m]); Kcolor += (A[m - 1] * Y2[m - 1]); } else { X = X + (A[m] * X2[m] * dt1[m]); Y = Y + (A[m] * Y2[m] * dt1[m]); Z = Z + (A[m] * Z2[m] * dt1[m]); Kcolor += (A[m] * Y2[m]); } } Kcolor = 100 / Kcolor; X = Kcolor * X; Y = Kcolor * Y; Z = Kcolor * Z; x = X / (X + Y + Z); y = Y / (X + Y + Z); z = 1 - (x + y); } else if (rdA.Checked && rd10.Checked) { for (int i = 420; i <= 750; i = i + 5) { X = X + (A[k] * X10[k] * dt1[k]); Y = Y + (A[k] * Y10[k] * dt1[k]); Z = Z + (A[k] * Z10[k] * dt1[k]); Kcolor += (A[k] * Y10[k]); k = k + 1; } Kcolor = 100 / Kcolor; X = Kcolor * X; Y = Kcolor * Y; Z = Kcolor * Z; x = X / (X + Y + Z); y = Y / (X + Y + Z); z = 1 - (x + y); } else if (rdD65.Checked && rd10.Checked) { for (int i = 420; i <= 750; i = i + 5) { X = X + (D65[k] * X10[k] * dt1[k]); Y = Y + (D65[k] * Y10[k] * dt1[k]); Z = Z + (D65[k] * Z10[k] * dt1[k]); Kcolor += (D65[k] * Y10[k]); k = k + 1; } Kcolor = 100 / Kcolor; X = Kcolor * X; Y = Kcolor * Y; Z = Kcolor * Z; x = X / (X + Y + Z); y = Y / (X + Y + Z); z = 1 - (x + y); } else if (rdD65.Checked && rd2.Checked) { //float[] p = new float[200]; //int countC = 0; //for (int m = 0; m < pirple.Length; m = m + 16) //{ // p[countC] = pirple[m]; // countC++; //} for (int m = 0; m < 79; m++) { if (m == 78) { X = X + (A[m - 1] * X2[m - 1] * dt1[m]); Y = Y + (A[m - 1] * Y2[m - 1] * dt1[m]); Z = Z + (A[m - 1] * Z2[m - 1] * dt1[m]); Kcolor += (D65[m - 1] * Y2[m - 1]); } else { X = X + (D65[m] * X2[m] * dt1[m]); Y = Y + (D65[m] * Y2[m] * dt1[m]); Z = Z + (D65[m] * Z2[m] * dt1[m]); Kcolor += (D65[m] * Y2[m]); } } Kcolor = 100 / Kcolor; X = Kcolor * X; Y = Kcolor * Y; Z = Kcolor * Z; x = X / (X + Y + Z); y = Y / (X + Y + Z); z = 1 - (x + y); } XYZg.Visible = true; RGBg.Visible = true; CIELuvg.Visible = true; LABg.Visible = true; CIExyYg.Visible = true; CIElchuv.Visible = true; LCHABg.Visible = true; // fchart.LMSg.Visible = true; Hunterg.Visible = true; CIEXlbl.Text = "X=" + x.ToString("N4"); CIEYlbl.Text = "Y=" + y.ToString("N4"); CIEZlbl.Text = "Z=" + z.ToString("N4"); Colourful.Conversion.ColourfulConverter a = new ColourfulConverter(); Colourful.XYZColor xyz = new Colourful.XYZColor(x, y, z); ColourfulConverter a1 = new ColourfulConverter(); a1.ToLab(xyz); // lblWithepoint.Text = a1.WhitePoint.ToString(); LabColor la = a1.ToLab(xyz); CIELlbl.Text = "L=" + la.L.ToString("N4"); CIEAlbl.Text = "a=" + la.a.ToString("N4"); CIEBlbl.Text = "b=" + la.b.ToString("N4"); Colourful.LuvColor luvc = a1.ToLuv(xyz); CIELuvLlbl.Text = "L=" + luvc.L.ToString("N4"); CIELuvUlbl.Text = "u=" + luvc.u.ToString("N4"); CIELuvVlbl.Text = "v=" + luvc.v.ToString("N4"); Colourful.xyYColor xyY = a1.ToxyY(xyz); CIExyYxlbl.Text = "x=" + xyY.x.ToString("N4"); CIExyYylbl.Text = "y=" + xyY.y.ToString("N4"); CIExyYy1lbl.Text = "L=" + xyY.Luminance.ToString("N4"); Colourful.LChuvColor lchuv = a1.ToLChuv(xyz); LCHLlbl.Text = "L=" + lchuv.L.ToString("N4"); LCHClbl.Text = "C=" + lchuv.C.ToString("N4"); LCHHlbl.Text = "h=" + lchuv.h.ToString("N4"); Colourful.LChabColor lchab = a1.ToLChab(xyz); LCHabLlbl.Text = "L=" + lchab.L.ToString("N4"); LCHabClbl.Text = "C=" + lchab.C.ToString("N4"); LCHabhlbl.Text = "h=" + lchab.h.ToString("N4"); //Colourful.LMSColor lms = a1.ToLMS(xyz); //fchart.LMSLbl.Text = "L=" + lms.L.ToString("N4"); //fchart.LMSMlbl.Text = "M=" + lms.M.ToString("N4"); //fchart.LMSSlbl.Text = "S=" + lms.S.ToString("N4"); Colourful.HunterLabColor hunter = a1.ToHunterLab(xyz); hunterLlbl.Text = "L=" + hunter.L.ToString("N4"); Hunteralbl.Text = "a=" + hunter.a.ToString("N4"); hunterblbl.Text = "b=" + hunter.b.ToString("N4"); Color rgb = a.ToRGB(xyz); Rlbl.Text = "R=" + rgb.R.ToString(); Glbl.Text = "G=" + rgb.G.ToString(); Blbl.Text = "B=" + rgb.B.ToString(); double C = 1 - (rgb.R / 255f); double M = 1 - (rgb.G / 255f); double Y1 = 1 - (rgb.B / 255f); double K1 = 1; if (C < K1) { K1 = C; } if (M < K1) { K1 = M; } if (Y1 < K1) { K1 = Y1; } if (K1 == 1) { C = 0; M = 0; Y1 = 0; } else { C = (C - K1) / (1 - K1); M = (M - K1) / (1 - K1); Y1 = (Y1 - K1) / (1 - K1); } lblC.Text = "C=" + C.ToString("N4"); lblM.Text = "M=" + M.ToString("N4"); lblY.Text = "Y=" + Y1.ToString("N4"); lblK.Text = "K=" + K1.ToString("N4"); int match = FindNearestColor(colormach, rgb); chart1.Series["palete"].Points.AddXY(XvalColor[match], YvalColor[match]); measurment = false; }