public static PerceptionLib.Color XYZToLABLUV(CIEXYZ C1xyz, CIEXYZ C2xyz) { PerceptionLib.CIEXYZ C3XYZ = AddXYZ(C1xyz, C2xyz); PerceptionLib.Color colorObject = PerceptionLib.Color.ToLUV(C3XYZ); return(colorObject); }
private void BgCal_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\DataGrid\DataGrid\bin\value\Predicted_Bg_input.csv"); DataTable bin = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); bin = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); double OL, OA, OB, px, py, pz, LL, LA, LB; PerceptionLib.Color BgColor = new PerceptionLib.Color(); PerceptionLib.Color LBgColor = new PerceptionLib.Color(); foreach (DataRow dr in bin.Rows) { OL = Convert.ToDouble(dr["BGL"].ToString()); OA = Convert.ToDouble(dr["BGA"].ToString()); OB = Convert.ToDouble(dr["BGB"].ToString()); LL = Convert.ToDouble(dr["LumistyL"].ToString()); LA = Convert.ToDouble(dr["LumistyA"].ToString()); LB = Convert.ToDouble(dr["LumistyB"].ToString()); px = Convert.ToDouble(dr["PX"].ToString()); py = Convert.ToDouble(dr["PY"].ToString()); pz = Convert.ToDouble(dr["PZ"].ToString()); PerceptionLib.CIEXYZ xyz = new CIEXYZ(px, py, pz); PerceptionLib.Color PLBgColor = PerceptionLib.Color.ToLAB(xyz); BgColor.LA = OL; BgColor.A = OA; BgColor.B = OB; LBgColor.LA = LL; LBgColor.A = LA; LBgColor.B = LB; PerceptionLib.ColorRegion cr = PerceptionLib.Color.ToFindColorRegion(BgColor); dr["BGLValue"] = cr.LValueFlag.ToString(); dr["SaturationValue"] = cr.NetralValueFlag.ToString(); dr["Region"] = cr.RegionValue.ToString(); dr["PXYZ_EqDistance"] = (PerceptionLib.Color.ColorDistanceCalAB(PLBgColor, LBgColor)).ToString(); } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = bin.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); btn_ExportGrid.IsEnabled = true; }
//to find fg bin private Bin FindForegroundBin(Bin[, ,] profile, Matrix3D navigationMatrix, System.Drawing.Color foregroundRGB) { PerceptionLib.Color foregroundLAB = PerceptionLib.Color.ToLAB(foregroundRGB); int binL = ((int)(Math.Round(foregroundLAB.LA / 5.0)) * 5); int binA = ((int)(Math.Round(foregroundLAB.A / 5.0)) * 5); int binB = ((int)(Math.Round(foregroundLAB.B / 5.0)) * 5); if (binL < 0) { binL = 0; } if (binL > 100) { binL = 100; } if (binA < -86.17385493791946) { binA = -85; } if (binA > 98.2448002875424) { binA = 100; } if (binB < -107.8619171648283) { binB = -110; } if (binB > 94.47705120353054) { binB = 95; } Bin foregroundBin = GetProfileBin(profile, navigationMatrix.Transform(new Point3D(binL, binA, binB))); return(foregroundBin); }
//cat private void CatCal_Click(object sender, RoutedEventArgs e) { // PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\small pro cat mixture\SmallPro800.csv"); // PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\phone\PhonePredcition800_diff200.csv"); //PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\Reduscer_HEX.csv"); PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\PerceptionLib\bin\previous data\cs-200 data\color mixing\phone data pewdiction data 800\Bg4.csv"); DataTable bin = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); bin = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); PerceptionLib.CIEXYZ ColorToShowXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ ColorMeasuredXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.Color ColorMeasured_fordiff = new PerceptionLib.Color(); PerceptionLib.CIEXYZ DBg = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDBg = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ AXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ DAXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDAXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ BinXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDBinXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ DBinXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ BradXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ VonXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ ScalXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDBradXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDVonXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ TDScalXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ DBradXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ DVonXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ DScalXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.Color Acolor = new PerceptionLib.Color(); PerceptionLib.Color TDAcolor = new PerceptionLib.Color(); PerceptionLib.Color DAcolor = new PerceptionLib.Color(); PerceptionLib.Color Bin = new PerceptionLib.Color(); PerceptionLib.Color TDBin = new PerceptionLib.Color(); PerceptionLib.Color DBin = new PerceptionLib.Color(); PerceptionLib.Color Brad = new PerceptionLib.Color(); PerceptionLib.Color Von = new PerceptionLib.Color(); PerceptionLib.Color Scal = new PerceptionLib.Color(); PerceptionLib.Color TDBrad = new PerceptionLib.Color(); PerceptionLib.Color TDVon = new PerceptionLib.Color(); PerceptionLib.Color TDScal = new PerceptionLib.Color(); PerceptionLib.Color DBrad = new PerceptionLib.Color(); PerceptionLib.Color DVon = new PerceptionLib.Color(); PerceptionLib.Color DScal = new PerceptionLib.Color(); PerceptionLib.RGBValue ab; /// small pro //CIEXYZ screenWt = new CIEXYZ(0.265572, 0.282182, 0.481033); //CIEXYZ screenBgWt = new CIEXYZ(0.9504, 0.990041, 1.0888); //phone CIEXYZ screenWt = new CIEXYZ(0.383264, 0.395001, 0.369982); CIEXYZ screenBgWt = new CIEXYZ(0.724775, 0.759896, 0.727336); // ; //string Von ; //string Scaling ; //string TDBrad ; //string TDVon ; //string TDScaling; //string DBrad ; //string DVon ; //string DScaling ; PerceptionLib.Color ColorToShow = new PerceptionLib.Color(); PerceptionLib.Color ColorMeasured = new PerceptionLib.Color(); int i = 0; foreach (DataRow dr in bin.Rows) { //i++; DBg.X = Convert.ToDouble(dr["BX"].ToString()); DBg.Y = Convert.ToDouble(dr["BY"].ToString()); DBg.Z = Convert.ToDouble(dr["BZ"].ToString()); TDBg.X = Convert.ToDouble(dr["BMX"].ToString()); TDBg.Y = Convert.ToDouble(dr["BMY"].ToString()); TDBg.Z = Convert.ToDouble(dr["BMZ"].ToString()); //bin fg BinXYZ.X = Convert.ToDouble(dr["BinX"].ToString()); BinXYZ.Y = Convert.ToDouble(dr["BinY"].ToString()); BinXYZ.Z = Convert.ToDouble(dr["BinZ"].ToString()); Bin = PerceptionLib.Color.ToLAB(BinXYZ, screenWt); dr["BP_Fg_L"] = Bin.LA.ToString(); dr["BP_Fg_a"] = Bin.A.ToString(); dr["BP_Fg_b"] = Bin.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(Bin); String Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["BP_Fg_RRGGBB"] = "0x" + Hex; //pure AXYZ.X = Convert.ToDouble(dr["X"].ToString()); AXYZ.Y = Convert.ToDouble(dr["Y"].ToString()); AXYZ.Z = Convert.ToDouble(dr["Z"].ToString()); Acolor.LA = Convert.ToDouble(dr["Fg_L"].ToString()); Acolor.A = Convert.ToDouble(dr["Fg_A"].ToString()); Acolor.B = Convert.ToDouble(dr["Fg_B"].ToString()); ab = PerceptionLib.Color.ToRBGFromLAB(Acolor); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["Fg_RRGGBB"] = "0x" + Hex; BradXYZ.X = Convert.ToDouble(dr["BradX"].ToString()); BradXYZ.Y = Convert.ToDouble(dr["BradY"].ToString()); BradXYZ.Z = Convert.ToDouble(dr["BradZ"].ToString()); Brad = PerceptionLib.Color.ToLAB(BradXYZ, screenWt); dr["CAT1_Fg_L"] = Brad.LA.ToString(); dr["CAT1_Fg_a"] = Brad.A.ToString(); dr["CAT1_Fg_b"] = Brad.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(Brad); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT1_Fg_RRGGBB"] = "0x" + Hex; VonXYZ.X = Convert.ToDouble(dr["VonX"].ToString()); VonXYZ.Y = Convert.ToDouble(dr["VonY"].ToString()); VonXYZ.Z = Convert.ToDouble(dr["VonZ"].ToString()); Von = PerceptionLib.Color.ToLAB(VonXYZ, screenWt); dr["CAT2_Fg_L"] = Von.LA.ToString(); dr["CAT2_Fg_a"] = Von.A.ToString(); dr["CAT2_Fg_b"] = Von.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(Von); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT2_Fg_RRGGBB"] = "0x" + Hex; ScalXYZ.X = Convert.ToDouble(dr["ScalX"].ToString()); ScalXYZ.Y = Convert.ToDouble(dr["ScalY"].ToString()); ScalXYZ.Z = Convert.ToDouble(dr["ScalZ"].ToString()); Scal = PerceptionLib.Color.ToLAB(ScalXYZ, screenWt); dr["CAT3_Fg_L"] = Scal.LA.ToString(); dr["CAT3_Fg_a"] = Scal.A.ToString(); dr["CAT3_Fg_b"] = Scal.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(Scal); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT3_Fg_RRGGBB"] = "0x" + Hex; // color measured ColorMeasuredXYZ.X = Convert.ToDouble(dr["MX"].ToString()); ColorMeasuredXYZ.Y = Convert.ToDouble(dr["MY"].ToString()); ColorMeasuredXYZ.Z = Convert.ToDouble(dr["MZ"].ToString()); ColorMeasured = PerceptionLib.Color.ToLAB(ColorMeasuredXYZ, screenBgWt); ColorMeasured_fordiff = PerceptionLib.Color.ToLAB(ColorMeasuredXYZ, screenWt); dr["Bc_L"] = ColorMeasured.LA.ToString(); dr["Bc_a"] = ColorMeasured.A.ToString(); dr["Bc_b"] = ColorMeasured.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(ColorMeasured); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["Bc_RRGGBB"] = "0x" + Hex; //aCOLOR TDAXYZ.X = AXYZ.X + TDBg.X; TDAXYZ.Y = AXYZ.Y + TDBg.Y; TDAXYZ.Z = AXYZ.Z + TDBg.Z; TDAcolor = PerceptionLib.Color.ToLAB(TDAXYZ, screenBgWt); dr["P_Bc_TD_L"] = TDAcolor.LA.ToString(); dr["P_Bc_TD_a"] = TDAcolor.A.ToString(); dr["P_Bc_TD_b"] = TDAcolor.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(TDAcolor); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["P_Bc_TD_RRGGBB"] = "0x" + Hex; DAXYZ.X = AXYZ.X + DBg.X; DAXYZ.Y = AXYZ.Y + DBg.Y; DAXYZ.Z = AXYZ.Z + DBg.Z; DAcolor = PerceptionLib.Color.ToLAB(DAXYZ, screenBgWt); dr["P_Bc_ND_L"] = DAcolor.LA.ToString(); dr["P_Bc_ND_a"] = DAcolor.A.ToString(); dr["P_Bc_ND_b"] = DAcolor.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(DAcolor); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["P_Bc_ND_RRGGBB"] = "0x" + Hex; //brad TDBradXYZ.X = BradXYZ.X + TDBg.X; TDBradXYZ.Y = BradXYZ.Y + TDBg.Y; TDBradXYZ.Z = BradXYZ.Z + TDBg.Z; TDBrad = PerceptionLib.Color.ToLAB(TDBradXYZ, screenBgWt); dr["CAT1_P_Bc_TD_L"] = TDBrad.LA.ToString(); dr["CAT1_P_Bc_TD_a"] = TDBrad.A.ToString(); dr["CAT1_P_Bc_TD_b"] = TDBrad.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(TDBrad); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT1_P_Bc_TD_RRGGBB"] = "0x" + Hex; DBradXYZ.X = BradXYZ.X + DBg.X; DBradXYZ.Y = BradXYZ.Y + DBg.Y; DBradXYZ.Z = BradXYZ.Z + DBg.Z; DBrad = PerceptionLib.Color.ToLAB(DBradXYZ, screenBgWt); dr["CAT1_P_Bc_ND_L"] = DBrad.LA.ToString(); dr["CAT1_P_Bc_ND_a"] = DBrad.A.ToString(); dr["CAT1_P_Bc_ND_b"] = DBrad.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(DBrad); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT1_P_Bc_ND_RRGGBB"] = "0x" + Hex; //von TDVonXYZ.X = VonXYZ.X + TDBg.X; TDVonXYZ.Y = VonXYZ.Y + TDBg.Y; TDVonXYZ.Z = VonXYZ.Z + TDBg.Z; TDVon = PerceptionLib.Color.ToLAB(TDVonXYZ, screenBgWt); dr["CAT2_P_Bc_TD_L"] = TDVon.LA.ToString(); dr["CAT2_P_Bc_TD_a"] = TDVon.A.ToString(); dr["CAT2_P_Bc_TD_b"] = TDVon.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(TDVon); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT2_P_Bc_TD_RRGGBB"] = "0x" + Hex; DVonXYZ.X = VonXYZ.X + DBg.X; DVonXYZ.Y = VonXYZ.Y + DBg.Y; DVonXYZ.Z = VonXYZ.Z + DBg.Z; DVon = PerceptionLib.Color.ToLAB(DVonXYZ, screenBgWt); dr["CAT2_P_Bc_ND_L"] = DVon.LA.ToString(); dr["CAT2_P_Bc_ND_a"] = DVon.A.ToString(); dr["CAT2_P_Bc_ND_b"] = DVon.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(DVon); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT2_P_Bc_ND_RRGGBB"] = "0x" + Hex; // scal TDScalXYZ.X = ScalXYZ.X + TDBg.X; TDScalXYZ.Y = ScalXYZ.Y + TDBg.Y; TDScalXYZ.Z = ScalXYZ.Z + TDBg.Z; TDScal = PerceptionLib.Color.ToLAB(TDScalXYZ, screenBgWt); dr["CAT3_P_Bc_TD_L"] = TDScal.LA.ToString(); dr["CAT3_P_Bc_TD_a"] = TDScal.A.ToString(); dr["CAT3_P_Bc_TD_b"] = TDScal.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(TDScal); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT3_P_Bc_TD_RRGGBB"] = "0x" + Hex; DScalXYZ.X = ScalXYZ.X + DBg.X; DScalXYZ.Y = ScalXYZ.Y + DBg.Y; DScalXYZ.Z = ScalXYZ.Z + DBg.Z; DScal = PerceptionLib.Color.ToLAB(DScalXYZ, screenBgWt); dr["CAT3_P_Bc_ND_L"] = DScal.LA.ToString(); dr["CAT3_P_Bc_ND_a"] = DScal.A.ToString(); dr["CAT3_P_Bc_ND_b"] = DScal.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(DScal); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["CAT3_P_Bc_ND_RRGGBB"] = "0x" + Hex; //bin TDBinXYZ.X = BinXYZ.X + TDBg.X; TDBinXYZ.Y = BinXYZ.Y + TDBg.Y; TDBinXYZ.Z = BinXYZ.Z + TDBg.Z; TDBin = PerceptionLib.Color.ToLAB(TDBinXYZ, screenBgWt); dr["BP_P_Bc_TD_L"] = TDBin.LA.ToString(); dr["BP_P_Bc_TD_a"] = TDBin.A.ToString(); dr["BP_P_Bc_TD_b"] = TDBin.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(TDBin); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["BP_P_Bc_TD_RRGGBB"] = "0x" + Hex; DBinXYZ.X = BinXYZ.X + DBg.X; DBinXYZ.Y = BinXYZ.Y + DBg.Y; DBinXYZ.Z = BinXYZ.Z + DBg.Z; DBin = PerceptionLib.Color.ToLAB(DBinXYZ, screenBgWt); dr["BP_P_Bc_ND_L"] = DBin.LA.ToString(); dr["BP_P_Bc_ND_a"] = DBin.A.ToString(); dr["BP_P_Bc_ND_b"] = DBin.B.ToString(); ab = PerceptionLib.Color.ToRBGFromLAB(DBin); Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); dr["BP_P_Bc_ND_RRGGBB"] = "0x" + Hex; dr["Dist_DM_P_TD"] = (PerceptionLib.Color.ColorDistanceCalAB(TDAcolor, ColorMeasured)).ToString(); dr["Dist_DM_P_ND"] = (PerceptionLib.Color.ColorDistanceCalAB(DAcolor, ColorMeasured)).ToString(); dr["Dist_CAT1_P_TD"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, TDBrad)).ToString(); dr["Dist_CAT1_P_ND"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, DBrad)).ToString(); dr["Dist_CAT2_P_TD"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, TDVon)).ToString(); dr["Dist_CAT2_P_ND"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, DVon)).ToString(); dr["Dist_CAT3_P_TD"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, TDScal)).ToString(); dr["Dist_CAT3_P_ND"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, DScal)).ToString(); dr["Dist_BP_P_TD"] = (PerceptionLib.Color.ColorDistanceCalAB(TDBin, ColorMeasured)).ToString(); dr["Dist_BP_P_ND"] = (PerceptionLib.Color.ColorDistanceCalAB(DBin, ColorMeasured)).ToString(); dr["Dist_Fg"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured_fordiff, Acolor)).ToString(); dr["Dist_CAT1_Fg"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured_fordiff, Brad)).ToString(); dr["Dist_CAT2_Fg"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured_fordiff, Von)).ToString(); dr["Dist_CAT3_Fg"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured_fordiff, Scal)).ToString(); dr["Dist_BP_Fg"] = (PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured_fordiff, Bin)).ToString(); } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = bin.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); btn_ExportGrid.IsEnabled = true; }
private void button11_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\DataGrid\DataGrid\data\Ds_correction.txt"); DataTable DS = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); DS = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); List<LABbin> bin =PerceptionLib.Color.RGBBinneddData_David(); int count = bin.Count(); //int temp = -1; DataRow newRow; for (int i = 0; i < count; i++) { newRow = DS.NewRow(); newRow[0] = bin[i].L.ToString(); newRow[1] = bin[i].A.ToString(); newRow[2] = bin[i].B.ToString(); newRow[3] = PerceptionLib.Color.OriginalRGB[i].R.ToString(); newRow[4] = PerceptionLib.Color.OriginalRGB[i].G.ToString(); newRow[5] = PerceptionLib.Color.OriginalRGB[i].B.ToString(); DS.Rows.Add(newRow); } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = DS.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); PerceptionLib.Color lab = new PerceptionLib.Color(); RGBValue temp = new RGBValue(); for (int i = 0; i < DS.Rows.Count; i++) { lab.LA = bin[i].L; lab.A = bin[i].A; lab.B = bin[i].B; temp = PerceptionLib.Color.ToRBGFromLAB(lab); if (temp.R < 0 || temp.R > 255 || temp.B < 0 || temp.B > 255 || temp.G < 0 || temp.G > 255) { continue; } else { //BinRGB[binCount].R = (byte)temp.R; //BinRGB[binCount].G= (byte)temp.G; //BinRGB[binCount].B= (byte)temp.B; //binCount++; DS.Rows[i][6] = temp.R.ToString(); DS.Rows[i][7] = temp.G.ToString(); DS.Rows[i][8] = temp.B.ToString(); } } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = DS.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); }
private void PhoneCompensation_Click(object sender, RoutedEventArgs e) { dtgrid_corrDisplay.IsEnabled = true; double X, Y, Z; int binnumber = 0; int GammutRangeCheck3, GammutRangeCheck4; PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\phone\BaseBinFile.csv"); DataTable bin = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); bin = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); double minLLevel = double.MaxValue; double maxLLevel = double.MinValue; double minALevel = double.MaxValue; double maxALevel = double.MinValue; double minBLevel = double.MaxValue; double maxBLevel = double.MinValue; double minL = double.MaxValue; double maxL = double.MinValue; double minA = double.MaxValue; double maxA = double.MinValue; double minB = double.MaxValue; double maxB = double.MinValue; foreach (DataRow dr in bin.Rows) { double accountLevel = dr.Field<double>("MLA"); minLLevel = Math.Min(minLLevel, accountLevel); maxLLevel = Math.Max(maxLLevel, accountLevel); double ALevel = dr.Field<double>("MA"); minALevel = Math.Min(minALevel, ALevel); maxALevel = Math.Max(maxALevel, ALevel); double BLevel = dr.Field<double>("MlaB"); minBLevel = Math.Min(minBLevel, BLevel); maxBLevel = Math.Max(maxBLevel, BLevel); double account = dr.Field<double>("LA"); minL = Math.Min(minL, account); maxL = Math.Max(maxL, account); double ALvl = dr.Field<double>("A"); minA = Math.Min(minA, ALvl); maxA = Math.Max(maxA, ALvl); double BLvl = dr.Field<double>("LB"); minB = Math.Min(minBLevel, BLvl); maxB = Math.Max(maxBLevel, BLvl); } RGBValue BincolorRGB = new RGBValue(); CIEXYZ BINCOLOR = new CIEXYZ(0, 0, 0); CIEXYZ BgND = new CIEXYZ(0, 0, 0); CIEXYZ BgTD = new CIEXYZ(0, 0, 0); CIEXYZ BP_TD = new CIEXYZ(0, 0, 0); CIEXYZ BP_ND = new CIEXYZ(0, 0, 0); CIEXYZ MBgND = new CIEXYZ(0, 0, 0); CIEXYZ MBgTD = new CIEXYZ(0, 0, 0); CIEXYZ MBP_TD = new CIEXYZ(0, 0, 0); CIEXYZ MBP_ND = new CIEXYZ(0, 0, 0); PerceptionLib.Color BINColor; PerceptionLib.Color BINTDColor; PerceptionLib.Color BINNDColor; PerceptionLib.Color MBINColor; PerceptionLib.Color MBINTDColor; PerceptionLib.Color MBINNDColor; //FgNo = 400; PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\PerceptionLib\bin\previous data\cs-200 data\color compensation\phone input\17bg_ip.csv"); DataTable dt_DataCollection = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); dt_DataCollection = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); { PerceptionLib.RGBValue rgb = new PerceptionLib.RGBValue(); foreach (DataRow dr in dt_DataCollection.Rows) { X = Convert.ToDouble(dr["BGX"].ToString()); Y = Convert.ToDouble(dr["BGY"].ToString()); Z = Convert.ToDouble(dr["BGZ"].ToString()); BgND = new CIEXYZ(X, Y, Z); X = Convert.ToDouble(dr["BGsX"].ToString()); Y = Convert.ToDouble(dr["BGsY"].ToString()); Z = Convert.ToDouble(dr["BGsZ"].ToString()); BgTD = new CIEXYZ(X, Y, Z); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //bin model X = Convert.ToDouble(dr["Mx"].ToString()); Y = Convert.ToDouble(dr["My"].ToString()); Z = Convert.ToDouble(dr["Mz"].ToString()); BINCOLOR = new CIEXYZ(X, Y, Z); BincolorRGB = new RGBValue(); BINColor = new PerceptionLib.Color(); BINColor.LA = Convert.ToDouble(dr["Ml"].ToString()); BINColor.A = Convert.ToDouble(dr["Ma"].ToString()); BINColor.B = Convert.ToDouble(dr["Mlb"].ToString()); MBP_ND = ColorSpaceConverter.SubtractXYZ(BINCOLOR, BgND); MBINNDColor = PerceptionLib.Color.ToLUV(MBP_ND); dr["ComS_Fg_L"] = MBINNDColor.LA.ToString(); dr["ComS_Fg_a"] = MBINNDColor.A.ToString(); dr["ComS_Fg_b"] = MBINNDColor.B.ToString(); GammutRangeCheck3 = 1; if ((MBINNDColor.LA >= minLLevel) & (MBINNDColor.LA <= maxLLevel) & (MBINNDColor.A >= minALevel) & (MBINNDColor.A <= maxALevel) & (MBINNDColor.B >= minBLevel) & (MBINNDColor.B <= maxBLevel)) { for (int index = 0; index < bin.Rows.Count; index++) { double tempL, tempA, tempB; tempL = Convert.ToDouble(bin.Rows[index][9].ToString()); tempA = Convert.ToDouble(bin.Rows[index][10].ToString()); tempB = Convert.ToDouble(bin.Rows[index][11].ToString()); if ((MBINNDColor.LA >= tempL - 5) & (MBINNDColor.LA <= tempL + 5) & (MBINNDColor.A >= tempA - 5) & (MBINNDColor.A <= tempA + 5) & (MBINNDColor.B >= tempB - 5) & (MBINNDColor.B <= tempB + 5)) { GammutRangeCheck3 = 0; break; } GammutRangeCheck3 = 1; } } else GammutRangeCheck3 = 1; binnumber = CATCalulation.MatchWithBinnedColors(MBINNDColor, bin, BgND, BINColor); BINNDColor = new PerceptionLib.Color(); BINNDColor.LA = Convert.ToDouble(bin.Rows[binnumber][3].ToString()); BINNDColor.A = Convert.ToDouble(bin.Rows[binnumber][4].ToString()); BINNDColor.B = Convert.ToDouble(bin.Rows[binnumber][5].ToString()); dr["Com_Fg_L"] = BINNDColor.LA.ToString(); dr["Com_Fg_a"] = BINNDColor.A.ToString(); dr["Com_Fg_b"] = BINNDColor.B.ToString(); BincolorRGB = PerceptionLib.Color.ToRBGFromLAB(BINNDColor); string Hex = PerceptionLib.Color.RGBtoHEX(BincolorRGB.R, BincolorRGB.G, BincolorRGB.B); dr["Com_HEX"] = "0x" + Hex; dr["GammutFlag"] = GammutRangeCheck3.ToString(); MBP_TD = ColorSpaceConverter.SubtractXYZ(BINCOLOR, BgTD); MBINTDColor = PerceptionLib.Color.ToLUV(MBP_TD); dr["TDComS_Fg_L"] = MBINNDColor.LA.ToString(); dr["TDComS_Fg_a"] = MBINNDColor.A.ToString(); dr["TDComS_Fg_b"] = MBINNDColor.B.ToString(); GammutRangeCheck4 = 1; if ((MBINTDColor.LA >= minLLevel) & (MBINTDColor.LA <= maxLLevel) & (MBINTDColor.A >= minALevel) & (MBINTDColor.A <= maxALevel) & (MBINTDColor.B >= minBLevel) & (MBINTDColor.B <= maxBLevel)) { for (int index = 0; index < bin.Rows.Count; index++) { double tempL, tempA, tempB; tempL = Convert.ToDouble(bin.Rows[index][9].ToString()); tempA = Convert.ToDouble(bin.Rows[index][10].ToString()); tempB = Convert.ToDouble(bin.Rows[index][11].ToString()); if ((MBINTDColor.LA >= tempL - 5) & (MBINTDColor.LA <= tempL + 5) & (MBINTDColor.A >= tempA - 5) & (MBINTDColor.A <= tempA + 5) & (MBINTDColor.B >= tempB - 5) & (MBINTDColor.B <= tempB + 5)) { GammutRangeCheck4 = 0; break; } GammutRangeCheck4 = 1; } } else GammutRangeCheck4 = 1; binnumber = CATCalulation.MatchWithBinnedColors(MBINTDColor, bin, BgND, BINColor); BINTDColor = new PerceptionLib.Color(); BINTDColor.LA = Convert.ToDouble(bin.Rows[binnumber][3].ToString()); BINTDColor.A = Convert.ToDouble(bin.Rows[binnumber][4].ToString()); BINTDColor.B = Convert.ToDouble(bin.Rows[binnumber][5].ToString()); dr["TDCom_Fg_L"] = BINTDColor.LA.ToString(); dr["TDCom_Fg_a"] = BINTDColor.A.ToString(); dr["TDCom_Fg_b"] = BINTDColor.B.ToString(); BincolorRGB = PerceptionLib.Color.ToRBGFromLAB(BINTDColor); Hex = PerceptionLib.Color.RGBtoHEX(BincolorRGB.R, BincolorRGB.G, BincolorRGB.B); dr["TDCom_HEX"] = "0x" + Hex; dr["TDGammutFlag"] = GammutRangeCheck4.ToString(); } } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt_DataCollection.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); btn_ExportGrid.IsEnabled = true; }
private void MathCal_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\Reduscer_for_phoneCAT.csv"); DataTable bin = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); bin = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); PerceptionLib.CIEXYZ ColorToShowXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ BradXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ VonXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.CIEXYZ ScalingXYZ = new CIEXYZ(0, 0, 0); PerceptionLib.Color ColorToShow = new PerceptionLib.Color(); foreach (DataRow dr in bin.Rows) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CAT LAB caluclation //brad //ColorToShowXYZ.X = Convert.ToDouble(dr["bradX"].ToString()); //ColorToShowXYZ.Y = Convert.ToDouble(dr["bradY"].ToString()); //ColorToShowXYZ.Z = Convert.ToDouble(dr["bradZ"].ToString()); //ColorToShow = PerceptionLib.Color.ToLAB(ColorToShowXYZ); //dr["bradL"] = ColorToShow.LA.ToString(); //dr["bradA"] = ColorToShow.A.ToString(); //dr["bradB"] = ColorToShow.B.ToString(); ////Von //ColorToShowXYZ.X = Convert.ToDouble(dr["VonX"].ToString()); //ColorToShowXYZ.Y = Convert.ToDouble(dr["VonY"].ToString()); //ColorToShowXYZ.Z = Convert.ToDouble(dr["VonZ"].ToString()); //ColorToShow = PerceptionLib.Color.ToLAB(ColorToShowXYZ); ////scaling //dr["vonL"] = ColorToShow.LA.ToString(); //dr["vonA"] = ColorToShow.A.ToString(); //dr["vonB"] = ColorToShow.B.ToString(); //ColorToShowXYZ.X = Convert.ToDouble(dr["SX"].ToString()); //ColorToShowXYZ.Y = Convert.ToDouble(dr["SY"].ToString()); //ColorToShowXYZ.Z = Convert.ToDouble(dr["SZ"].ToString()); //ColorToShow = PerceptionLib.Color.ToLAB(ColorToShowXYZ); //dr["sL"] = ColorToShow.LA.ToString(); //dr["sA"] = ColorToShow.A.ToString(); //dr["sB"] = ColorToShow.B.ToString(); //////////////////////////////////////////////////////////////////////////////////////////////////////////// //xyz caluclation ColorToShowXYZ.X = Convert.ToDouble(dr["X"].ToString()); ColorToShowXYZ.Y = Convert.ToDouble(dr["Y"].ToString()); ColorToShowXYZ.Z = Convert.ToDouble(dr["Z"].ToString()); BradXYZ = CATCalulation.bradford(ColorToShowXYZ); VonXYZ = CATCalulation.VonKries(ColorToShowXYZ); ScalingXYZ = CATCalulation.XYZScaling(ColorToShowXYZ); dr["bradX"] = BradXYZ.X.ToString(); dr["bradY"] = BradXYZ.Y.ToString(); dr["bradZ"] = BradXYZ.Z.ToString(); dr["VonX"] = VonXYZ.X.ToString(); dr["VonY"] = VonXYZ.Y.ToString(); dr["VonZ"] = VonXYZ.Z.ToString(); dr["ScalX"] = ScalingXYZ.X.ToString(); dr["ScalY"] = ScalingXYZ.Y.ToString(); dr["ScalZ"] = ScalingXYZ.Z.ToString(); //////////////////////////////////////////////////////////////////////////////////////////////////////////// //ColorToShow.LA = Convert.ToDouble(dr["L"].ToString()); //ColorToShow.A = Convert.ToDouble(dr["A"].ToString()); //ColorToShow.B = Convert.ToDouble(dr["B"].ToString()); //PerceptionLib.RGBValue ab = PerceptionLib.Color.ToRBGFromLAB(ColorToShow); ////Hex color //String Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); //dr["HEX"] = "0x" + Hex; //////////////////////////////////////////////////////////////////////////////////////////////////////////// //ColorToShowXYZ = new CIEXYZ(0, 0, 0); //ColorToShowXYZ.X = Convert.ToDouble(dr["X"].ToString()); //ColorToShowXYZ.Y = Convert.ToDouble(dr["Y"].ToString()); //ColorToShowXYZ.Z = Convert.ToDouble(dr["Z"].ToString()); //ColorToShow = PerceptionLib.Color.ToLUV(ColorToShowXYZ); //PerceptionLib.RGBValue ab = PerceptionLib.Color.ToRBGFromLAB(ColorToShow); //dr["L"] = ColorToShow.LA.ToString(); //dr["A"] = ColorToShow.A.ToString(); //dr["LB"] = ColorToShow.B.ToString(); //dr["R"] = ab.R.ToString(); //dr["G"] = ab.G.ToString(); //dr["B"] = ab.B.ToString(); //String Hex = PerceptionLib.Color.RGBtoHEX(ab.R, ab.G, ab.B); //dr["HEX"] = "0x" + Hex; ////////////////////////////////////////////////////////////////////////////////////////////////////////// // hue calculation //ColorToShow.LA = Convert.ToDouble(dr["L"].ToString()); //ColorToShow.A = Convert.ToDouble(dr["A"].ToString()); //ColorToShow.B = Convert.ToDouble(dr["B"].ToString()); //double hue= CATCalulation.HueAngle(ColorToShow); //dr["Hue"] = hue.ToString(); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = bin.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } btn_ExportGrid.IsEnabled = true; }
public static PerceptionLib.Color ToGetLUV(int r, int g, int b) { System.Drawing.Color mRGB = ToGetRGB(r, g, b); PerceptionLib.Color colorObject = PerceptionLib.Color.ToLUV(mRGB); return(colorObject); }
private void Btn_UseGridData_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\bin8.csv"); dtgrid_corrDisplay.IsEnabled = false; btn_StartMeasurment.IsEnabled = false; txt_R.IsEnabled = false; txt_G.IsEnabled = false; txt_B.IsEnabled = false; DataTable dt = new DataTable(); DataTable new_dt = new DataTable(); dt = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); ThreadPool.QueueUserWorkItem(ignored => { //for (int i = 1; i < dt.Rows.Count; i++) for (int i = 0; i < dt.Rows.Count; i++) { mainW.R = Convert.ToByte(dt.Rows[i][0].ToString()); mainW.G = Convert.ToByte(dt.Rows[i][1].ToString()); mainW.B = Convert.ToByte(dt.Rows[i][2].ToString()); // converts rendered RGB to luv and displays the colour in to measure //NoArgDelegate fetcher = new NoArgDelegate( // this.ColorCapturedUpdate); //Dispatcher.BeginInvoke(); Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => { ColorCapturedUpdate(); })); // System.Threading.Thread.Sleep(1000); Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { //StartCapture(); colorMeasured = StartCapture1(); DisplayMeasuredValues(); })); // System.Windows.Forms.Application.DoEvents(); DifferenceCalculation(); //bradcolor= // assignes the data to a the datatable dt.Rows[i][3] = colorToShow.L.ToString(); dt.Rows[i][4] = colorToShow.U.ToString(); dt.Rows[i][5] = colorToShow.V.ToString(); dt.Rows[i][6] = colorToShow.UP.ToString(); dt.Rows[i][7] = colorToShow.VP.ToString(); dt.Rows[i][8] = ColorMeasured.L.ToString(); dt.Rows[i][9] = ColorMeasured.U.ToString(); dt.Rows[i][10] = ColorMeasured.V.ToString(); dt.Rows[i][11] = ColorMeasured.UP.ToString(); dt.Rows[i][12] = ColorMeasured.VP.ToString(); //dt.Rows[i][13] = ColorDifference.L.ToString(); //dt.Rows[i][14] = ColorDifference.U.ToString(); //dt.Rows[i][15] = ColorDifference.V.ToString(); //// dt.Rows[i][13] = colorToShow.LA.ToString(); dt.Rows[i][14] = colorToShow.A.ToString(); dt.Rows[i][15] = colorToShow.B.ToString(); dt.Rows[i][16] = ColorMeasured.LA.ToString(); dt.Rows[i][17] = ColorMeasured.A.ToString(); dt.Rows[i][18] = ColorMeasured.B.ToString(); // dt.Rows[i][19] = PerceptionLib.Color.ColorDistanceCal(colorToShow, ColorMeasured).ToString(); dt.Rows[i][20] = PerceptionLib.Color.ColorDistanceCalAB(colorToShow, ColorMeasured).ToString(); // dt.Rows[i][21] = ColorToShowXYZ.X.ToString(); dt.Rows[i][22] = ColorToShowXYZ.Y.ToString(); dt.Rows[i][23] = ColorToShowXYZ.Z.ToString(); dt.Rows[i][24] = ColorMeasuredXYZ.X.ToString(); dt.Rows[i][25] = ColorMeasuredXYZ.Y.ToString(); dt.Rows[i][26] = ColorMeasuredXYZ.Z.ToString(); dt.Rows[i][27] = MR.ToString(); dt.Rows[i][28] = MG.ToString(); dt.Rows[i][29] = MB.ToString(); //BradXYZ = Util.CATCalulation.bradford(ColorToShowXYZ); //VonXYZ = Util.CATCalulation.VonKries(ColorToShowXYZ); //ScalingXYZ = Util.CATCalulation.XYZScaling(ColorToShowXYZ); //Bradcolor = PerceptionLib.Color.ToLUV(BradXYZ); //Voncolor = PerceptionLib.Color.ToLUV(VonXYZ); //Scalingcolor = PerceptionLib.Color.ToLUV(ScalingXYZ); //bradRGB = PerceptionLib.Color.ToRBG(BradXYZ); //VonRGB = PerceptionLib.Color.ToRBG(VonXYZ); //scalingRGB = PerceptionLib.Color.ToRBG(ScalingXYZ); CalRGB = PerceptionLib.Color.ToRBG(ColorMeasuredXYZ); //dt.Rows[i][30] = BradXYZ.X.ToString(); //dt.Rows[i][31] = BradXYZ.Y.ToString(); //dt.Rows[i][32] = BradXYZ.Z.ToString(); //dt.Rows[i][33] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Bradcolor).ToString(); //dt.Rows[i][34] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Bradcolor).ToString(); //dt.Rows[i][35] = VonXYZ.X.ToString(); //dt.Rows[i][36] = VonXYZ.Y.ToString(); //dt.Rows[i][37] = VonXYZ.Z.ToString(); //dt.Rows[i][38] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Voncolor).ToString(); //dt.Rows[i][39] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Voncolor).ToString(); //dt.Rows[i][40] = ScalingXYZ.X.ToString(); //dt.Rows[i][41] = ScalingXYZ.Y.ToString(); //dt.Rows[i][42] = ScalingXYZ.Z.ToString(); //dt.Rows[i][43] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Scalingcolor).ToString(); //dt.Rows[i][44] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Scalingcolor).ToString(); //dt.Rows[i][45] = bradRGB.R.ToString(); //dt.Rows[i][46] = bradRGB.G.ToString(); //dt.Rows[i][47] = bradRGB.B.ToString(); //dt.Rows[i][48] = VonRGB.R.ToString(); //dt.Rows[i][49] = VonRGB.G.ToString(); //dt.Rows[i][50] = VonRGB.B.ToString(); //dt.Rows[i][51] = scalingRGB.R.ToString(); //dt.Rows[i][52] = scalingRGB.G.ToString(); //dt.Rows[i][53] = scalingRGB.B.ToString(); dt.Rows[i][54] = CalRGB.R.ToString(); dt.Rows[i][55] = CalRGB.G.ToString(); dt.Rows[i][56] = CalRGB.B.ToString(); //dt.Rows[i][57] = Bradcolor.UP.ToString(); //dt.Rows[i][58] = Bradcolor.VP.ToString(); //dt.Rows[i][59] = Voncolor.UP.ToString(); //dt.Rows[i][60] = Voncolor.VP.ToString(); //dt.Rows[i][61] = Scalingcolor.UP.ToString(); //dt.Rows[i][62] = Scalingcolor.VP.ToString(); pairs.Clear(); pairs.Add(new MeasurementPair() { ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][6].ToString()), VP = Convert.ToDouble(dt.Rows[i][7].ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][11].ToString()), VP = Convert.ToDouble(dt.Rows[i][12].ToString()) } }); //Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); //Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); // System.Threading.Thread.Sleep(10000); } // grid is populated with new datatable which has luv values Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); // to show all the pairs in cie graph //pairs.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { pairs.Add(new MeasurementPair() { ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][6].ToString()), VP = Convert.ToDouble(dt.Rows[i][7].ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][11].ToString()), VP = Convert.ToDouble(dt.Rows[i][12].ToString()) } }); } }); btn_ExportGrid.IsEnabled = true; dtgrid_corrDisplay.IsEnabled = true; dataTable = dt; }
private void Btn_StdColorData_Click(object sender, RoutedEventArgs e) { // PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\StdColor.txt"); PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\StdColortriangle.txt"); txt_R.IsEnabled = false; txt_G.IsEnabled = false; txt_B.IsEnabled = false; txt_BgNo.IsEnabled = false; txt_FgNo.IsEnabled = false; btn_MixedColour.IsEnabled = false; DataTable dt = new DataTable(); // DataTable new_dt = new DataTable(); DataRow newRow; dt = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); // to create a random number //BgNo = 5; BgNo = 20; //FgNo = 27; FgNo = 61; // this loop is too changfe the bg color // for (int i = 0; i < 5; i++) ThreadPool.QueueUserWorkItem(ignored => { PerceptionLib.RGBValue rgb = new PerceptionLib.RGBValue(); for (int i = 0; i < BgNo; i++) { // for the first set of vaule it tahes balck as the bg colour switch (i) { // black bg case 0: BgR = 0; BgG = 0; BgB = 0; break; //Brick case 1: BgColor = new PerceptionLib.Color(); bgcolour.L = 65; bgcolour.UP = 0.275; bgcolour.VP = 0.485; bgcolour.U = (13 * bgcolour.L) * (bgcolour.UP - bgcolour.UR); bgcolour.V = (13 * bgcolour.L) * (bgcolour.VP - bgcolour.VR); rgb = PerceptionLib.Color.ToRBG(bgcolour); BgR = rgb.R; BgG = rgb.G; BgB = rgb.B; break; //Foliage case 2: BgColor = new PerceptionLib.Color(); bgcolour.L = 65; bgcolour.UP = 0.123; bgcolour.VP = 0.531; bgcolour.U = (13 * bgcolour.L) * (bgcolour.UP - bgcolour.UR); bgcolour.V = (13 * bgcolour.L) * (bgcolour.VP - bgcolour.VR); rgb = PerceptionLib.Color.ToRBG(bgcolour); BgR = rgb.R; BgG = rgb.G; BgB = rgb.B; break; //Sidewalk case 3: BgColor = new PerceptionLib.Color(); bgcolour.L = 65; bgcolour.UP = 0.211; bgcolour.VP = 0.489; bgcolour.U = (13 * bgcolour.L) * (bgcolour.UP - bgcolour.UR); bgcolour.V = (13 * bgcolour.L) * (bgcolour.VP - bgcolour.VR); rgb = PerceptionLib.Color.ToRBG(bgcolour); BgR = rgb.R; BgG = rgb.G; BgB = rgb.B; break; //Pavement case 4: BgColor = new PerceptionLib.Color(); bgcolour.L = 65; bgcolour.UP = 0.203; bgcolour.VP = 0.470; bgcolour.U = (13 * bgcolour.L) * (bgcolour.UP - bgcolour.UR); bgcolour.V = (13 * bgcolour.L) * (bgcolour.VP - bgcolour.VR); rgb = PerceptionLib.Color.ToRBG(bgcolour); BgR = rgb.R; BgG = rgb.G; BgB = rgb.B; break; //vaiants of blue case 5: BgR = 0; BgG = 0; BgB = 255; break; case 6: BgR = 0; BgG = 0; BgB = 225; break; case 7: BgR = 100; BgG = 0; BgB = 255; break; case 8: BgR = 0; BgG = 100; BgB = 255; break; //variants of green case 9: BgR = 0; BgG = 255; BgB = 0; break; case 10: BgR = 0; BgG = 225; BgB = 0; break; case 11: BgR = 100; BgG = 255; BgB = 0; break; case 12: BgR = 0; BgG = 255; BgB = 100; break; //yellow case 13: BgR = 255; BgG = 255; BgB = 0; break; case 14: BgR = 200; BgG = 200; BgB = 0; break; case 15: BgR = 200; BgG = 255; BgB = 0; break; //red case 16: BgR = 255; BgG = 0; BgB = 0; break; case 17: BgR = 200; BgG = 0; BgB = 0; break; case 18: BgR = 255; BgG = 100; BgB = 0; break; case 19: BgR = 255; BgG = 0; BgB = 100; break; } for (int j = 0; j < FgNo; j++) { //if (i == 0) //{ // mainW.R = Convert.ToByte(dt.Rows[j][0].ToString()); // mainW.G = Convert.ToByte(dt.Rows[j][1].ToString()); // mainW.B = Convert.ToByte(dt.Rows[j][2].ToString()); //} //else //{ mainW.R = Convert.ToByte(dt.Rows[j][0].ToString()); mainW.G = Convert.ToByte(dt.Rows[j][1].ToString()); mainW.B = Convert.ToByte(dt.Rows[j][2].ToString()); //} //if (i != 0) // System.Threading.Thread.Sleep(500); Dispatcher.Invoke(new Action(() => ColorUpdateOnScreenWithBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); DifferenceCalculation(); if (i == 0) { dt.Rows[j][0] = R.ToString(); dt.Rows[j][1] = G.ToString(); dt.Rows[j][2] = B.ToString(); dt.Rows[j][3] = colorToShow.L.ToString(); dt.Rows[j][4] = colorToShow.U.ToString(); dt.Rows[j][5] = colorToShow.V.ToString(); dt.Rows[j][6] = colorToShow.UP.ToString(); dt.Rows[j][7] = colorToShow.VP.ToString(); dt.Rows[j][8] = ColorMeasured.L.ToString(); dt.Rows[j][9] = ColorMeasured.U.ToString(); dt.Rows[j][10] = ColorMeasured.V.ToString(); dt.Rows[j][11] = ColorMeasured.UP.ToString(); dt.Rows[j][12] = ColorMeasured.VP.ToString(); dt.Rows[j][13] = MR.ToString(); dt.Rows[j][14] = MG.ToString(); dt.Rows[j][15] = MB.ToString(); dt.Rows[j][16] = colorDifference.L.ToString(); dt.Rows[j][17] = colorDifference.U.ToString(); dt.Rows[j][18] = colorDifference.V.ToString(); dt.Rows[j][19] = BgR.ToString(); dt.Rows[j][20] = BgG.ToString(); dt.Rows[j][21] = BgB.ToString(); dt.Rows[j][22] = 0; dt.Rows[j][23] = 0; dt.Rows[j][24] = 0; dt.Rows[j][25] = 0; dt.Rows[j][26] = 0; dt.Rows[j][27] = 0; dt.Rows[j][28] = 0; dt.Rows[j][29] = 0; dt.Rows[j][30] = 0; dt.Rows[j][31] = 0; dt.Rows[j][32] = 0; dt.Rows[j][33] = 0; dt.Rows[j][34] = 0; dt.Rows[j][35] = 0; dt.Rows[j][36] = 0; dt.Rows[j][37] = 0; pairs.Clear(); pairs.Add(new MeasurementPair() { ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(colorToShow.UP.ToString()), VP = Convert.ToDouble(colorToShow.VP.ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } else { newRow = dt.NewRow(); newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = colorToShow.L.ToString(); newRow[4] = colorToShow.U.ToString(); newRow[5] = colorToShow.V.ToString(); newRow[6] = colorToShow.UP.ToString(); newRow[7] = colorToShow.VP.ToString(); newRow[8] = dt.Rows[j][8].ToString(); newRow[9] = dt.Rows[j][9].ToString(); newRow[10] = dt.Rows[j][10].ToString(); newRow[11] = dt.Rows[j][11].ToString(); newRow[12] = dt.Rows[j][12].ToString(); newRow[13] = dt.Rows[j][13].ToString(); newRow[14] = dt.Rows[j][14].ToString(); newRow[15] = dt.Rows[j][15].ToString(); newRow[16] = colorDifference.L.ToString(); newRow[17] = colorDifference.U.ToString(); newRow[18] = colorDifference.V.ToString(); newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = ColorMeasured.L.ToString(); newRow[31] = ColorMeasured.U.ToString(); newRow[32] = ColorMeasured.V.ToString(); newRow[33] = ColorMeasured.UP.ToString(); newRow[34] = ColorMeasured.VP.ToString(); newRow[35] = MR.ToString(); newRow[36] = MG.ToString(); newRow[37] = MB.ToString(); MixedColor = ColorMeasured; pairs.Clear(); pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[j][11].ToString()), VP = Convert.ToDouble(dt.Rows[j][12].ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); dt.Rows.Add(newRow); } R = 0; G = 0; B = 0; //dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } } // dtgrid_corrDisplay.ItemsSource = dt.DefaultView; //dtgrid_corrDisplay.Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); // for caluclating just bg colour,.. with fg & bg white conditions so this for loop should be 3 more than loop for bg color change for (int i = 1; i < BgNo + 3; i++) { if (i < BgNo) { R = 0; G = 0; B = 0; BgR = Convert.ToByte(dt.Rows[i * FgNo][19].ToString()); BgG = Convert.ToByte(dt.Rows[i * FgNo][20].ToString()); BgB = Convert.ToByte(dt.Rows[i * FgNo][21].ToString()); } // both white else if (i == BgNo) { R = 255; G = 255; B = 255; BgR = 255; BgG = 255; BgB = 255; } // fg white else if (i == BgNo + 1) { R = 255; G = 255; B = 255; BgR = 0; BgG = 0; BgB = 0; } // bg white else { R = 0; G = 0; B = 0; BgR = 255; BgG = 255; BgB = 255; } ////if (i != 0) //System.Threading.Thread.Sleep(500); //ColorCaptureJustBG(); //System.Windows.Forms.Application.DoEvents(); ////does all the caputure and difference calculations //System.Threading.Thread.Sleep(500); //// StartCapture(); Dispatcher.Invoke(new Action(() => ColorCaptureJustBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); DifferenceCalculation(); //just bg capture newRow = dt.NewRow(); if (i < BgNo) { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = MR.ToString(); newRow[23] = MG.ToString(); newRow[24] = MB.ToString(); newRow[25] = ColorMeasured.L.ToString(); newRow[26] = ColorMeasured.U.ToString(); newRow[27] = ColorMeasured.V.ToString(); newRow[28] = ColorMeasured.UP.ToString(); newRow[29] = ColorMeasured.VP.ToString(); newRow[30] = 0; newRow[31] = 0; newRow[32] = 0; newRow[33] = 0; newRow[34] = 0; newRow[35] = 0; newRow[36] = 0; newRow[37] = 0; pairs.Clear(); BgColor = ColorMeasured; pairs.Add(new MeasurementPair() {//THE COLOUR DISPLAYED HERE ARE THE BG COLOUR CAPTURED BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } //white point capture else { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = ColorMeasured.L.ToString(); newRow[31] = ColorMeasured.U.ToString(); newRow[32] = ColorMeasured.V.ToString(); newRow[33] = ColorMeasured.UP.ToString(); newRow[34] = ColorMeasured.VP.ToString(); newRow[35] = MR.ToString(); newRow[36] = MG.ToString(); newRow[37] = MB.ToString(); pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } R = 10; dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } //taking back the measured value of bg to all the data set int totalRow = BgNo * FgNo; for (int i = 1; i < BgNo; i++) { for (int j = 0; j < fgNo; j++) { int rowNo = (i * FgNo) + j; // i am doing -1 cos the data set starts from 0 ,.. so in the first one it will still b e bg*fg but i value will be 0 dt.Rows[rowNo][22] = dt.Rows[(totalRow) + i - 1][22].ToString(); dt.Rows[rowNo][23] = dt.Rows[(totalRow) + i - 1][23].ToString(); dt.Rows[rowNo][24] = dt.Rows[(totalRow) + i - 1][24].ToString(); dt.Rows[rowNo][25] = dt.Rows[(totalRow) + i - 1][25].ToString(); dt.Rows[rowNo][26] = dt.Rows[(totalRow) + i - 1][26].ToString(); dt.Rows[rowNo][27] = dt.Rows[(totalRow) + i - 1][27].ToString(); dt.Rows[rowNo][28] = dt.Rows[(totalRow) + i - 1][28].ToString(); dt.Rows[rowNo][29] = dt.Rows[(totalRow) + i - 1][29].ToString(); } } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); dataTable = dt; }); cmb_graph.IsEnabled = true; btn_ExportGrid.IsEnabled = true; // captureDevice.Dispose(); }
private void Btn_MixedColour_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\ColorMixing1.txt"); txt_R.IsEnabled = false; txt_G.IsEnabled = false; txt_B.IsEnabled = false; DataTable dt = new DataTable(); // DataTable new_dt = new DataTable(); DataRow newRow; dt = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); // to create a random number Random rnd = new Random(); // to form byte number for bg and fg color Byte[] b = new Byte[3]; Byte[] rgb = new Byte[3]; // this loop is too changfe the bg color // for (int i = 0; i < 5; i++) ThreadPool.QueueUserWorkItem(ignored => { for (int i = 0; i < BgNo; i++) { // for the first set of vaule it tahes balck as the bg colour if (i == 0) { BgR = 0; BgG = 0; BgB = 0; } // then it tahes randndom value for BG else { rnd.NextBytes(b); BgR = b[0]; BgG = b[1]; BgB = b[2]; } for (int j = 0; j < FgNo; j++) { if (i == 0) { rnd.NextBytes(rgb); R = rgb[0]; G = rgb[1]; B = rgb[2]; } else { mainW.R = Convert.ToByte(dt.Rows[j][0].ToString()); mainW.G = Convert.ToByte(dt.Rows[j][1].ToString()); mainW.B = Convert.ToByte(dt.Rows[j][2].ToString()); } //if (i != 0) // System.Threading.Thread.Sleep(500); Dispatcher.Invoke(new Action(() => ColorUpdateOnScreenWithBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); DifferenceCalculation(); newRow = dt.NewRow(); if (i == 0) { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = colorToShow.L.ToString(); newRow[4] = colorToShow.U.ToString(); newRow[5] = colorToShow.V.ToString(); newRow[6] = colorToShow.UP.ToString(); newRow[7] = colorToShow.VP.ToString(); newRow[8] = ColorMeasured.L.ToString(); newRow[9] = ColorMeasured.U.ToString(); newRow[10] = ColorMeasured.V.ToString(); newRow[11] = ColorMeasured.UP.ToString(); newRow[12] = ColorMeasured.VP.ToString(); newRow[13] = MR.ToString(); newRow[14] = MG.ToString(); newRow[15] = MB.ToString(); newRow[16] = colorDifference.L.ToString(); newRow[17] = colorDifference.U.ToString(); newRow[18] = colorDifference.V.ToString(); newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = 0; newRow[31] = 0; newRow[32] = 0; newRow[33] = 0; newRow[34] = 0; newRow[35] = 0; newRow[36] = 0; newRow[37] = 0; pairs.Clear(); pairs.Add(new MeasurementPair() { ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(colorToShow.UP.ToString()), VP = Convert.ToDouble(colorToShow.VP.ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } else { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = colorToShow.L.ToString(); newRow[4] = colorToShow.U.ToString(); newRow[5] = colorToShow.V.ToString(); newRow[6] = colorToShow.UP.ToString(); newRow[7] = colorToShow.VP.ToString(); newRow[8] = dt.Rows[j][8].ToString(); newRow[9] = dt.Rows[j][9].ToString(); newRow[10] = dt.Rows[j][10].ToString(); newRow[11] = dt.Rows[j][11].ToString(); newRow[12] = dt.Rows[j][12].ToString(); newRow[13] = dt.Rows[j][13].ToString(); newRow[14] = dt.Rows[j][14].ToString(); newRow[15] = dt.Rows[j][15].ToString(); newRow[16] = colorDifference.L.ToString(); newRow[17] = colorDifference.U.ToString(); newRow[18] = colorDifference.V.ToString(); newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = ColorMeasured.L.ToString(); newRow[31] = ColorMeasured.U.ToString(); newRow[32] = ColorMeasured.V.ToString(); newRow[33] = ColorMeasured.UP.ToString(); newRow[34] = ColorMeasured.VP.ToString(); newRow[35] = MR.ToString(); newRow[36] = MG.ToString(); newRow[37] = MB.ToString(); MixedColor = ColorMeasured; pairs.Clear(); pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[j][11].ToString()), VP = Convert.ToDouble(dt.Rows[j][12].ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } R = 0; G = 0; B = 0; dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } } // dtgrid_corrDisplay.ItemsSource = dt.DefaultView; //dtgrid_corrDisplay.Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); // for caluclating just bg colour,.. with fg & bg white conditions so this for loop should be 3 more than loop for bg color change for (int i = 1; i < BgNo + 3; i++) { if (i < BgNo) { R = 0; G = 0; B = 0; BgR = Convert.ToByte(dt.Rows[i * FgNo][19].ToString()); BgG = Convert.ToByte(dt.Rows[i * FgNo][20].ToString()); BgB = Convert.ToByte(dt.Rows[i * FgNo][21].ToString()); } // both white else if (i == BgNo) { R = 255; G = 255; B = 255; BgR = 255; BgG = 255; BgB = 255; } // fg white else if (i == BgNo + 1) { R = 255; G = 255; B = 255; BgR = 0; BgG = 0; BgB = 0; } // bg white else { R = 0; G = 0; B = 0; BgR = 255; BgG = 255; BgB = 255; } ////if (i != 0) //System.Threading.Thread.Sleep(500); //ColorCaptureJustBG(); //System.Windows.Forms.Application.DoEvents(); ////does all the caputure and difference calculations //System.Threading.Thread.Sleep(500); //// StartCapture(); Dispatcher.Invoke(new Action(() => ColorCaptureJustBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); DifferenceCalculation(); //just bg capture newRow = dt.NewRow(); if (i < BgNo) { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = MR.ToString(); newRow[23] = MG.ToString(); newRow[24] = MB.ToString(); newRow[25] = ColorMeasured.L.ToString(); newRow[26] = ColorMeasured.U.ToString(); newRow[27] = ColorMeasured.V.ToString(); newRow[28] = ColorMeasured.UP.ToString(); newRow[29] = ColorMeasured.VP.ToString(); newRow[30] = 0; newRow[31] = 0; newRow[32] = 0; newRow[33] = 0; newRow[34] = 0; newRow[35] = 0; newRow[36] = 0; newRow[37] = 0; pairs.Clear(); BgColor = ColorMeasured; pairs.Add(new MeasurementPair() {//THE COLOUR DISPLAYED HERE ARE THE BG COLOUR CAPTURED BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } //white point capture else { newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = BgR.ToString(); newRow[20] = BgG.ToString(); newRow[21] = BgB.ToString(); newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = ColorMeasured.L.ToString(); newRow[31] = ColorMeasured.U.ToString(); newRow[32] = ColorMeasured.V.ToString(); newRow[33] = ColorMeasured.UP.ToString(); newRow[34] = ColorMeasured.VP.ToString(); newRow[35] = MR.ToString(); newRow[36] = MG.ToString(); newRow[37] = MB.ToString(); pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } R = 10; dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } //taking back the measured value of bg to all the data set int totalRow = BgNo * FgNo; for (int i = 1; i < BgNo; i++) { for (int j = 0; j < fgNo; j++) { int rowNo = (i * FgNo) + j; // i am doing -1 cos the data set starts from 0 ,.. so in the first one it will still b e bg*fg but i value will be 0 dt.Rows[rowNo][22] = dt.Rows[(totalRow) + i - 1][22].ToString(); dt.Rows[rowNo][23] = dt.Rows[(totalRow) + i - 1][23].ToString(); dt.Rows[rowNo][24] = dt.Rows[(totalRow) + i - 1][24].ToString(); dt.Rows[rowNo][25] = dt.Rows[(totalRow) + i - 1][25].ToString(); dt.Rows[rowNo][26] = dt.Rows[(totalRow) + i - 1][26].ToString(); dt.Rows[rowNo][27] = dt.Rows[(totalRow) + i - 1][27].ToString(); dt.Rows[rowNo][28] = dt.Rows[(totalRow) + i - 1][28].ToString(); dt.Rows[rowNo][29] = dt.Rows[(totalRow) + i - 1][29].ToString(); } } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); dataTable = dt; }); cmb_graph.IsEnabled = true; btn_ExportGrid.IsEnabled = true; }
private void Btn_CSGammut_Click(object sender, RoutedEventArgs e) { ///add this sleep for phone //PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\color88ForPhone.txt"); //PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\colorForPhone.txt"); // PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\bin8000.csv"); //PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\bgcolor.csv"); PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\binforL.csv"); dtgrid_corrDisplay.IsEnabled = false; //Thread.Sleep(16500); btn_StartMeasurment.IsEnabled = false; txt_R.IsEnabled = false; txt_G.IsEnabled = false; txt_B.IsEnabled = false; DataTable dt = new DataTable(); DataTable new_dt = new DataTable(); dt = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); //int connect = PerceptionLib.Cs200Connection.ConnectToCS200(); //if not connected then connect will be 1 BgNo = dt.Rows.Count; ThreadPool.QueueUserWorkItem(ignored => { DateTime Start = DateTime.Now; { //for (int i = 1; i < dt.Rows.Count; i++) for (int i = 0; i < dt.Rows.Count; i++) { mainW.R = Convert.ToByte(dt.Rows[i][0].ToString()); mainW.G = Convert.ToByte(dt.Rows[i][1].ToString()); mainW.B = Convert.ToByte(dt.Rows[i][2].ToString()); // converts rendered RGB to luv and displays the colour in to measure //NoArgDelegate fetcher = new NoArgDelegate( // this.ColorCapturedUpdate); //Dispatcher.BeginInvoke(); // Dispatcher.Invoke(new Action(() => ColorCapturedUpdate())); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //take it out for any thing other than phone ColorCapturedUpdate(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// colorMeasured = StartCapture1(); //Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => DisplayMeasuredValuesFromCs200())); //Thread.Sleep(500); //DisplayMeasuredValuesFromCs200(); DifferenceCalculation(); //bradcolor= // if (i > 0) // assignes the data to a the datatable dt.Rows[i][3] = colorToShow.L.ToString(); dt.Rows[i][4] = colorToShow.U.ToString(); dt.Rows[i][5] = colorToShow.V.ToString(); dt.Rows[i][6] = colorToShow.UP.ToString(); dt.Rows[i][7] = colorToShow.VP.ToString(); dt.Rows[i][8] = ColorMeasured.L.ToString(); dt.Rows[i][9] = ColorMeasured.U.ToString(); dt.Rows[i][10] = ColorMeasured.V.ToString(); dt.Rows[i][11] = ColorMeasured.UP.ToString(); dt.Rows[i][12] = ColorMeasured.VP.ToString(); //dt.Rows][13] = ColorDifference.L.ToString(); //dt.Rows][14] = ColorDifference.U.ToString(); //dt.Rows][15] = ColorDifference.V.ToString(); //// dt.Rows[i][13] = colorToShow.LA.ToString(); dt.Rows[i][14] = colorToShow.A.ToString(); dt.Rows[i][15] = colorToShow.B.ToString(); dt.Rows[i][16] = ColorMeasured.LA.ToString(); dt.Rows[i][17] = ColorMeasured.A.ToString(); dt.Rows[i][18] = ColorMeasured.B.ToString(); // dt.Rows[i][19] = PerceptionLib.Color.ColorDistanceCal(colorToShow, ColorMeasured).ToString(); dt.Rows[i][20] = PerceptionLib.Color.ColorDistanceCalAB(colorToShow, ColorMeasured).ToString(); // dt.Rows[i][21] = ColorToShowXYZ.X.ToString(); dt.Rows[i][22] = ColorToShowXYZ.Y.ToString(); dt.Rows[i][23] = ColorToShowXYZ.Z.ToString(); dt.Rows[i][24] = ColorMeasuredXYZ.X.ToString(); dt.Rows[i][25] = ColorMeasuredXYZ.Y.ToString(); dt.Rows[i][26] = ColorMeasuredXYZ.Z.ToString(); dt.Rows[i][27] = MR.ToString(); dt.Rows[i][28] = MG.ToString(); dt.Rows[i][29] = MB.ToString(); BradXYZ = Util.CATCalulation.bradford(ColorToShowXYZ); VonXYZ = Util.CATCalulation.VonKries(ColorToShowXYZ); ScalingXYZ = Util.CATCalulation.XYZScaling(ColorToShowXYZ); Bradcolor = PerceptionLib.Color.ToLUV(BradXYZ); Voncolor = PerceptionLib.Color.ToLUV(VonXYZ); Scalingcolor = PerceptionLib.Color.ToLUV(ScalingXYZ); bradRGB = PerceptionLib.Color.ToRBG(Bradcolor); VonRGB = PerceptionLib.Color.ToRBG(Voncolor); scalingRGB = PerceptionLib.Color.ToRBG(Scalingcolor); CalRGB = PerceptionLib.Color.ToRBG(ColorMeasuredXYZ); dt.Rows[i][30] = BradXYZ.X.ToString(); dt.Rows[i][31] = BradXYZ.Y.ToString(); dt.Rows[i][32] = BradXYZ.Z.ToString(); dt.Rows[i][33] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Bradcolor).ToString(); dt.Rows[i][34] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Bradcolor).ToString(); dt.Rows[i][35] = VonXYZ.X.ToString(); dt.Rows[i][36] = VonXYZ.Y.ToString(); dt.Rows[i][37] = VonXYZ.Z.ToString(); dt.Rows[i][38] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Voncolor).ToString(); dt.Rows[i][39] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Voncolor).ToString(); dt.Rows[i][40] = ScalingXYZ.X.ToString(); dt.Rows[i][41] = ScalingXYZ.Y.ToString(); dt.Rows[i][42] = ScalingXYZ.Z.ToString(); dt.Rows[i][43] = PerceptionLib.Color.ColorDistanceCal(ColorMeasured, Scalingcolor).ToString(); dt.Rows[i][44] = PerceptionLib.Color.ColorDistanceCalAB(ColorMeasured, Scalingcolor).ToString(); dt.Rows[i][45] = bradRGB.R.ToString(); dt.Rows[i][46] = bradRGB.G.ToString(); dt.Rows[i][47] = bradRGB.B.ToString(); dt.Rows[i][48] = VonRGB.R.ToString(); dt.Rows[i][49] = VonRGB.G.ToString(); dt.Rows[i][50] = VonRGB.B.ToString(); dt.Rows[i][51] = scalingRGB.R.ToString(); dt.Rows[i][52] = scalingRGB.G.ToString(); dt.Rows[i][53] = scalingRGB.B.ToString(); dt.Rows[i][54] = CalRGB.R.ToString(); dt.Rows[i][55] = CalRGB.G.ToString(); dt.Rows[i][56] = CalRGB.B.ToString(); dt.Rows[i][57] = Bradcolor.UP.ToString(); dt.Rows[i][58] = Bradcolor.VP.ToString(); dt.Rows[i][59] = Voncolor.UP.ToString(); dt.Rows[i][60] = Voncolor.VP.ToString(); dt.Rows[i][61] = Scalingcolor.UP.ToString(); dt.Rows[i][62] = Scalingcolor.VP.ToString(); dt.Rows[i][63] = ColorMeasuredXYZ.stdx.ToString(); dt.Rows[i][64] = ColorMeasuredXYZ.stdy.ToString(); dt.Rows[i][65] = ColorMeasuredXYZ.stdz.ToString(); //pairs.Clear(); //pairs.Add(new MeasurementPair() //{ // ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][6].ToString()), VP = Convert.ToDouble(dt.Rows[i][7].ToString()) }, // ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][11].ToString()), VP = Convert.ToDouble(dt.Rows[i][12].ToString()) }, // BradColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dataTable.Rows[i][57].ToString()), VP = Convert.ToDouble(dataTable.Rows[i][58].ToString()) }, // VonColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dataTable.Rows[i][59].ToString()), VP = Convert.ToDouble(dataTable.Rows[i][60].ToString()) }, // Scalingcolor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dataTable.Rows[i][61].ToString()), VP = Convert.ToDouble(dataTable.Rows[i][62].ToString()) } //}); //if (i == 9) //{ Dispatcher.Invoke(new Action(() => { dtgrid_corrDisplay.ItemsSource = dt.DefaultView; dtgrid_corrDisplay.Items.Refresh(); })); //} //if (i == (dt.Rows.Count - 1)) //{ // int disconnect = PerceptionLib.Cs200Connection.DisconnectCS200(); //} } // System.Threading.Thread.Sleep(10000); // grid is populated with new datatable which has luv values Dispatcher.Invoke(new Action(() => { dtgrid_corrDisplay.ItemsSource = dt.DefaultView; dtgrid_corrDisplay.Items.Refresh(); })); // to show all the pairs in cie graph pairs.Clear(); //for (int i = 0; i < dt.Rows.Count; i++) //{ // pairs.Add(new MeasurementPair() // { // ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][6].ToString()), VP = Convert.ToDouble(dt.Rows[i][7].ToString()) }, // ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[i][11].ToString()), VP = Convert.ToDouble(dt.Rows[i][12].ToString()) } // }); //} } time = DateTime.Now.Subtract(Start).ToString(); }); btn_ExportGrid.IsEnabled = true; dtgrid_corrDisplay.IsEnabled = true; dataTable = dt; }
private void Btn_ColorPredictor_Click(object sender, RoutedEventArgs e) { // PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\StdColor.txt"); PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\predictor.csv"); txt_R.IsEnabled = false; txt_G.IsEnabled = false; txt_B.IsEnabled = false; txt_BgNo.IsEnabled = false; txt_FgNo.IsEnabled = false; btn_MixedColour.IsEnabled = false; DataTable dt = new DataTable(); // DataTable new_dt = new DataTable(); DataRow newRow; dt = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); // to create a random number //BgNo = 5; BgNo = 24; //FgNo = 27; FgNo = dt.Rows.Count; // this loop is too changfe the bg color // for (int i = 0; i < 5; i++) ThreadPool.QueueUserWorkItem(ignored => { PerceptionLib.RGBValue rgb = new PerceptionLib.RGBValue(); for (int i = 0; i < BgNo; i++) { // for the first set of vaule it tahes balck as the bg colour switch (i) { // black bg case 0: BgR = 0; BgG = 0; BgB = 0; break; //Brick case 1: BgR = 115; BgG = 80; BgB = 64; break; case 2: BgR = 195; BgG = 151; BgB = 130; break; //Pavement case 3: BgR = 94; BgG = 123; BgB = 156; break; //vaiants of blue case 4: BgR = 88; BgG = 108; BgB = 65; break; case 5: BgR = 100; BgG = 190; BgB = 171; break; case 6: BgR = 217; BgG = 122; BgB = 37; break; case 7: BgR = 72; BgG = 91; BgB = 165; break; //variants of green case 8: BgR = 194; BgG = 84; BgB = 98; break; case 9: BgR = 91; BgG = 59; BgB = 107; break; case 10: BgR = 115; BgG = 80; BgB = 64; break; case 11: BgR = 160; BgG = 188; BgB = 60; break; //yellow case 12: BgR = 230; BgG = 163; BgB = 42; break; case 13: BgR = 46; BgG = 60; BgB = 153; break; case 14: BgR = 71; BgG = 150; BgB = 69; break; //red case 15: BgR = 177; BgG = 44; BgB = 56; break; case 16: BgR = 238; BgG = 200; BgB = 27; break; case 17: BgR = 187; BgG = 82; BgB = 148; break; case 18: BgR = 243; BgG = 242; BgB = 237; break; case 19: BgR = 201; BgG = 201; BgB = 201; break; case 20: BgR = 161; BgG = 161; BgB = 161; break; case 21: BgR = 122; BgG = 122; BgB = 121; break; case 22: BgR = 83; BgG = 83; BgB = 83; break; case 23: BgR = 50; BgG = 49; BgB = 50; break; } for (int j = 0; j < FgNo; j++) { //if (i == 0) //{ // mainW.R = Convert.ToByte(dt.Rows[j][0].ToString()); // mainW.G = Convert.ToByte(dt.Rows[j][1].ToString()); // mainW.B = Convert.ToByte(dt.Rows[j][2].ToString()); //} //else //{ mainW.R = Convert.ToByte(dt.Rows[j][0].ToString()); mainW.G = Convert.ToByte(dt.Rows[j][1].ToString()); mainW.B = Convert.ToByte(dt.Rows[j][2].ToString()); //} //if (i != 0) // System.Threading.Thread.Sleep(500); Dispatcher.Invoke(new Action(() => ColorUpdateOnScreenWithBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); Dispatcher.Invoke(new Action(() => progress(i))); DifferenceCalculation(); BradXYZ = Util.CATCalulation.bradford(ColorToShowXYZ); VonXYZ = Util.CATCalulation.VonKries(ColorToShowXYZ); ScalingXYZ = Util.CATCalulation.XYZScaling(ColorToShowXYZ); Bradcolor = PerceptionLib.Color.ToLUV(BradXYZ); Voncolor = PerceptionLib.Color.ToLUV(VonXYZ); Scalingcolor = PerceptionLib.Color.ToLUV(ScalingXYZ); bradRGB = PerceptionLib.Color.ToRBG(BradXYZ); VonRGB = PerceptionLib.Color.ToRBG(VonXYZ); scalingRGB = PerceptionLib.Color.ToRBG(ScalingXYZ); CalRGB = PerceptionLib.Color.ToRBG(ColorMeasuredXYZ); if (i == 0) { //dt.Rows[j][0] = R.ToString(); //dt.Rows[j][1] = G.ToString(); //dt.Rows[j][2] = B.ToString(); //dt.Rows[j][3] = colorToShow.L.ToString(); //dt.Rows[j][4] = colorToShow.U.ToString(); //dt.Rows[j][5] = colorToShow.V.ToString(); //dt.Rows[j][6] = colorToShow.UP.ToString(); //dt.Rows[j][7] = colorToShow.VP.ToString(); //dt.Rows[j][8] = ColorMeasured.L.ToString(); //dt.Rows[j][9] = ColorMeasured.U.ToString(); //dt.Rows[j][10] = ColorMeasured.V.ToString(); //dt.Rows[j][11] = ColorMeasured.UP.ToString(); //dt.Rows[j][12] = ColorMeasured.VP.ToString(); //dt.Rows[j][13] = MR.ToString(); //dt.Rows[j][14] = MG.ToString(); //dt.Rows[j][15] = MB.ToString(); //dt.Rows[j][16] = colorDifference.L.ToString(); //dt.Rows[j][17] = colorDifference.U.ToString(); //dt.Rows[j][18] = colorDifference.V.ToString(); //dt.Rows[j][19] = BgR.ToString(); //dt.Rows[j][20] = BgG.ToString(); //dt.Rows[j][21] = BgB.ToString(); //dt.Rows[j][22] = 0; //dt.Rows[j][23] = 0; //dt.Rows[j][24] = 0; //dt.Rows[j][25] = 0; //dt.Rows[j][26] = 0; //dt.Rows[j][27] = 0; //dt.Rows[j][28] = 0; //dt.Rows[j][29] = 0; //dt.Rows[j][30] = 0; //dt.Rows[j][31] = 0; //dt.Rows[j][32] = 0; //dt.Rows[j][33] = 0; //dt.Rows[j][34] = 0; //dt.Rows[j][35] = 0; //dt.Rows[j][36] = 0; //dt.Rows[j][37] = 0; dt.Rows[j][0] = R.ToString(); dt.Rows[j][1] = G.ToString(); dt.Rows[j][2] = B.ToString(); dt.Rows[j][3] = colorToShow.L.ToString(); dt.Rows[j][4] = colorToShow.U.ToString(); dt.Rows[j][5] = colorToShow.V.ToString(); dt.Rows[j][6] = colorToShow.UP.ToString(); dt.Rows[j][7] = colorToShow.VP.ToString(); dt.Rows[j][8] = colorToShow.LA.ToString(); dt.Rows[j][9] = colorToShow.A.ToString(); dt.Rows[j][10] = colorToShow.B.ToString(); dt.Rows[j][11] = ColorToShowXYZ.X.ToString(); dt.Rows[j][12] = ColorToShowXYZ.Y.ToString(); dt.Rows[j][13] = ColorToShowXYZ.Z.ToString(); dt.Rows[j][14] = MR.ToString(); dt.Rows[j][15] = MG.ToString(); dt.Rows[j][16] = MB.ToString(); dt.Rows[j][17] = ColorMeasured.L.ToString(); dt.Rows[j][18] = ColorMeasured.U.ToString(); dt.Rows[j][19] = ColorMeasured.V.ToString(); dt.Rows[j][20] = ColorMeasured.UP.ToString(); dt.Rows[j][21] = ColorMeasured.VP.ToString(); dt.Rows[j][22] = ColorMeasured.LA.ToString(); dt.Rows[j][23] = ColorMeasured.A.ToString(); dt.Rows[j][24] = ColorMeasured.B.ToString(); dt.Rows[j][25] = ColorMeasuredXYZ.X.ToString(); dt.Rows[j][26] = ColorMeasuredXYZ.Y.ToString(); dt.Rows[j][27] = ColorMeasuredXYZ.Z.ToString(); BradXYZ = Util.CATCalulation.bradford(ColorToShowXYZ); VonXYZ = Util.CATCalulation.VonKries(ColorToShowXYZ); ScalingXYZ = Util.CATCalulation.XYZScaling(ColorToShowXYZ); Bradcolor = PerceptionLib.Color.ToLUV(BradXYZ); Voncolor = PerceptionLib.Color.ToLUV(VonXYZ); Scalingcolor = PerceptionLib.Color.ToLUV(ScalingXYZ); bradRGB = PerceptionLib.Color.ToRBG(BradXYZ); VonRGB = PerceptionLib.Color.ToRBG(VonXYZ); scalingRGB = PerceptionLib.Color.ToRBG(ScalingXYZ); dt.Rows[j][28] = Bradcolor.L.ToString(); dt.Rows[j][29] = Bradcolor.U.ToString(); dt.Rows[j][30] = Bradcolor.V.ToString(); dt.Rows[j][31] = Bradcolor.UP.ToString(); dt.Rows[j][32] = Bradcolor.VP.ToString(); dt.Rows[j][33] = Bradcolor.LA.ToString(); dt.Rows[j][34] = Bradcolor.A.ToString(); dt.Rows[j][35] = Bradcolor.B.ToString(); dt.Rows[j][36] = BradXYZ.X.ToString(); dt.Rows[j][37] = BradXYZ.Y.ToString(); dt.Rows[j][38] = BradXYZ.Z.ToString(); dt.Rows[j][39] = bradRGB.R.ToString(); dt.Rows[j][40] = bradRGB.G.ToString(); dt.Rows[j][41] = bradRGB.B.ToString(); dt.Rows[j][42] = Voncolor.L.ToString(); dt.Rows[j][43] = Voncolor.U.ToString(); dt.Rows[j][44] = Voncolor.V.ToString(); dt.Rows[j][45] = Voncolor.UP.ToString(); dt.Rows[j][46] = Voncolor.VP.ToString(); dt.Rows[j][47] = Voncolor.LA.ToString(); dt.Rows[j][48] = Voncolor.A.ToString(); dt.Rows[j][49] = Voncolor.B.ToString(); dt.Rows[j][50] = VonXYZ.X.ToString(); dt.Rows[j][51] = VonXYZ.Y.ToString(); dt.Rows[j][52] = VonXYZ.Z.ToString(); dt.Rows[j][53] = VonRGB.R.ToString(); dt.Rows[j][54] = VonRGB.G.ToString(); dt.Rows[j][55] = VonRGB.B.ToString(); dt.Rows[j][57] = Scalingcolor.L.ToString(); dt.Rows[j][57] = Scalingcolor.U.ToString(); dt.Rows[j][58] = Scalingcolor.V.ToString(); dt.Rows[j][59] = Scalingcolor.UP.ToString(); dt.Rows[j][60] = Scalingcolor.VP.ToString(); dt.Rows[j][61] = Scalingcolor.LA.ToString(); dt.Rows[j][62] = Scalingcolor.A.ToString(); dt.Rows[j][63] = Scalingcolor.B.ToString(); dt.Rows[j][64] = ScalingXYZ.X.ToString(); dt.Rows[j][65] = ScalingXYZ.Y.ToString(); dt.Rows[j][66] = ScalingXYZ.Z.ToString(); dt.Rows[j][67] = scalingRGB.R.ToString(); dt.Rows[j][68] = scalingRGB.G.ToString(); dt.Rows[j][69] = scalingRGB.B.ToString(); dt.Rows[j][71] = BgR.ToString(); dt.Rows[j][71] = BgG.ToString(); dt.Rows[j][72] = BgB.ToString(); dt.Rows[j][73] = ColorBackGround.L.ToString(); dt.Rows[j][74] = ColorBackGround.U.ToString(); dt.Rows[j][75] = ColorBackGround.V.ToString(); dt.Rows[j][76] = ColorBackGround.UP.ToString(); dt.Rows[j][77] = ColorBackGround.VP.ToString(); dt.Rows[j][78] = ColorBackGround.LA.ToString(); dt.Rows[j][79] = ColorBackGround.A.ToString(); dt.Rows[j][80] = ColorBackGround.B.ToString(); dt.Rows[j][81] = ColorBackGroundXYZ.X.ToString(); dt.Rows[j][82] = ColorBackGroundXYZ.Y.ToString(); dt.Rows[j][83] = ColorBackGroundXYZ.Z.ToString(); dt.Rows[j][84] = 0; dt.Rows[j][85] = 0; dt.Rows[j][86] = 0; dt.Rows[j][87] = 0; dt.Rows[j][88] = 0; dt.Rows[j][89] = 0; dt.Rows[j][90] = 0; dt.Rows[j][91] = 0; dt.Rows[j][92] = 0; dt.Rows[j][93] = 0; dt.Rows[j][94] = 0; dt.Rows[j][95] = 0; dt.Rows[j][96] = 0; dt.Rows[j][97] = 0; dt.Rows[j][98] = 0; dt.Rows[j][99] = 0; dt.Rows[j][100] = 0; dt.Rows[j][101] = 0; dt.Rows[j][102] = 0; dt.Rows[j][103] = 0; dt.Rows[j][104] = 0; dt.Rows[j][105] = 0; dt.Rows[j][106] = 0; dt.Rows[j][107] = 0; dt.Rows[j][108] = 0; dt.Rows[j][109] = 0; dt.Rows[j][110] = 0; dt.Rows[j][111] = 0; dt.Rows[j][112] = 0; dt.Rows[j][113] = 0; dt.Rows[j][114] = 0; dt.Rows[j][115] = 0; dt.Rows[j][116] = 0; dt.Rows[j][117] = 0; dt.Rows[j][118] = 0; dt.Rows[j][119] = 0; dt.Rows[j][120] = 0; dt.Rows[j][121] = 0; dt.Rows[j][122] = 0; dt.Rows[j][123] = 0; dt.Rows[j][124] = 0; dt.Rows[j][125] = 0; dt.Rows[j][126] = 0; dt.Rows[j][127] = 0; dt.Rows[j][128] = 0; dt.Rows[j][129] = 0; dt.Rows[j][130] = 0; dt.Rows[j][131] = 0; dt.Rows[j][132] = 0; dt.Rows[j][133] = 0; dt.Rows[j][134] = 0; dt.Rows[j][135] = 0; dt.Rows[j][136] = 0; dt.Rows[j][137] = 0; dt.Rows[j][138] = 0; dt.Rows[j][139] = 0; dt.Rows[j][140] = 0; dt.Rows[j][141] = 0; dt.Rows[j][142] = 0; dt.Rows[j][143] = 0; dt.Rows[j][144] = 0; dt.Rows[j][145] = 0; dt.Rows[j][146] = 0; dt.Rows[j][147] = 0; dt.Rows[j][148] = 0; dt.Rows[j][149] = 0; dt.Rows[j][150] = 0; dt.Rows[j][151] = 0; dt.Rows[j][152] = 0; dt.Rows[j][153] = 0; dt.Rows[j][154] = 0; dt.Rows[j][155] = 0; dt.Rows[j][156] = 0; dt.Rows[j][157] = 0; dt.Rows[j][158] = 0; dt.Rows[j][159] = 0; dt.Rows[j][160] = 0; dt.Rows[j][161] = 0; dt.Rows[j][162] = 0; dt.Rows[j][163] = 0; dt.Rows[j][164] = 0; dt.Rows[j][165] = 0; dt.Rows[j][166] = 0; dt.Rows[j][167] = 0; dt.Rows[j][168] = 0; dt.Rows[j][169] = 0; dt.Rows[j][170] = 0; dt.Rows[j][171] = 0; dt.Rows[j][172] = 0; dt.Rows[j][173] = 0; dt.Rows[j][174] = 0; dt.Rows[j][175] = 0; dt.Rows[j][176] = 0; dt.Rows[j][177] = 0; dt.Rows[j][178] = 0; dt.Rows[j][179] = 0; dt.Rows[j][180] = 0; ///////////////// pairs.Clear(); pairs.Add(new MeasurementPair() { ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(colorToShow.UP.ToString()), VP = Convert.ToDouble(colorToShow.VP.ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } else { newRow = dt.NewRow(); //newRow[0] = R.ToString(); //newRow[1] = G.ToString(); //newRow[2] = B.ToString(); //newRow[3] = colorToShow.L.ToString(); //newRow[4] = colorToShow.U.ToString(); //newRow[5] = colorToShow.V.ToString(); //newRow[6] = colorToShow.UP.ToString(); //newRow[7] = colorToShow.VP.ToString(); //newRow[8] = dt.Rows[j][8].ToString(); //newRow[9] = dt.Rows[j][9].ToString(); //newRow[10] = dt.Rows[j][10].ToString(); //newRow[11] = dt.Rows[j][11].ToString(); //newRow[12] = dt.Rows[j][12].ToString(); //newRow[13] = dt.Rows[j][13].ToString(); //newRow[14] = dt.Rows[j][14].ToString(); //newRow[15] = dt.Rows[j][15].ToString(); //newRow[16] = colorDifference.L.ToString(); //newRow[17] = colorDifference.U.ToString(); //newRow[18] = colorDifference.V.ToString(); //newRow[19] = BgR.ToString(); //newRow[20] = BgG.ToString(); //newRow[21] = BgB.ToString(); //newRow[22] = 0; //newRow[23] = 0; //newRow[24] = 0; //newRow[25] = 0; //newRow[26] = 0; //newRow[27] = 0; //newRow[28] = 0; //newRow[29] = 0; //newRow[30] = ColorMeasured.L.ToString(); //newRow[31] = ColorMeasured.U.ToString(); //newRow[32] = ColorMeasured.V.ToString(); //newRow[33] = ColorMeasured.UP.ToString(); //newRow[34] = ColorMeasured.VP.ToString(); //newRow[35] = MR.ToString(); //newRow[36] = MG.ToString(); //newRow[37] = MB.ToString(); newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = colorToShow.L.ToString(); newRow[4] = colorToShow.U.ToString(); newRow[5] = colorToShow.V.ToString(); newRow[6] = colorToShow.UP.ToString(); newRow[7] = colorToShow.VP.ToString(); newRow[8] = colorToShow.LA.ToString(); newRow[9] = colorToShow.A.ToString(); newRow[10] = colorToShow.B.ToString(); newRow[11] = ColorToShowXYZ.X.ToString(); newRow[12] = ColorToShowXYZ.Y.ToString(); newRow[13] = ColorToShowXYZ.Z.ToString(); newRow[14] = dt.Rows[j][14].ToString(); newRow[15] = dt.Rows[j][15].ToString(); newRow[16] = dt.Rows[j][16].ToString(); newRow[17] = dt.Rows[j][17].ToString(); newRow[18] = dt.Rows[j][18].ToString(); newRow[19] = dt.Rows[j][19].ToString(); newRow[20] = dt.Rows[j][20].ToString(); newRow[21] = dt.Rows[j][21].ToString(); newRow[22] = dt.Rows[j][22].ToString(); newRow[23] = dt.Rows[j][23].ToString(); newRow[24] = dt.Rows[j][24].ToString(); newRow[25] = dt.Rows[j][25].ToString(); newRow[26] = dt.Rows[j][26].ToString(); newRow[27] = dt.Rows[j][27].ToString(); newRow[28] = dt.Rows[j][28].ToString(); newRow[29] = dt.Rows[j][29].ToString(); newRow[30] = dt.Rows[j][30].ToString(); newRow[31] = dt.Rows[j][31].ToString(); newRow[32] = dt.Rows[j][32].ToString(); newRow[33] = dt.Rows[j][33].ToString(); newRow[34] = dt.Rows[j][34].ToString(); newRow[35] = dt.Rows[j][35].ToString(); newRow[36] = dt.Rows[j][36].ToString(); newRow[37] = dt.Rows[j][37].ToString(); newRow[38] = dt.Rows[j][38].ToString(); newRow[39] = dt.Rows[j][39].ToString(); newRow[40] = dt.Rows[j][40].ToString(); newRow[41] = dt.Rows[j][41].ToString(); newRow[42] = dt.Rows[j][42].ToString(); newRow[43] = dt.Rows[j][43].ToString(); newRow[44] = dt.Rows[j][44].ToString(); newRow[45] = dt.Rows[j][45].ToString(); newRow[46] = dt.Rows[j][46].ToString(); newRow[47] = dt.Rows[j][47].ToString(); newRow[48] = dt.Rows[j][48].ToString(); newRow[49] = dt.Rows[j][49].ToString(); newRow[50] = dt.Rows[j][50].ToString(); newRow[51] = dt.Rows[j][51].ToString(); newRow[52] = dt.Rows[j][52].ToString(); newRow[53] = dt.Rows[j][53].ToString(); newRow[54] = dt.Rows[j][54].ToString(); newRow[55] = dt.Rows[j][55].ToString(); newRow[56] = dt.Rows[j][56].ToString(); newRow[57] = dt.Rows[j][57].ToString(); newRow[58] = dt.Rows[j][58].ToString(); newRow[59] = dt.Rows[j][59].ToString(); newRow[60] = dt.Rows[j][60].ToString(); newRow[61] = dt.Rows[j][61].ToString(); newRow[62] = dt.Rows[j][62].ToString(); newRow[63] = dt.Rows[j][63].ToString(); newRow[64] = dt.Rows[j][64].ToString(); newRow[65] = dt.Rows[j][65].ToString(); newRow[66] = dt.Rows[j][66].ToString(); newRow[67] = dt.Rows[j][67].ToString(); newRow[68] = dt.Rows[j][68].ToString(); newRow[69] = dt.Rows[j][69].ToString(); newRow[70] = BgR.ToString(); newRow[71] = BgG.ToString(); newRow[72] = BgB.ToString(); newRow[73] = ColorBackGround.L.ToString(); newRow[74] = ColorBackGround.U.ToString(); newRow[75] = ColorBackGround.V.ToString(); newRow[76] = ColorBackGround.UP.ToString(); newRow[77] = ColorBackGround.VP.ToString(); newRow[78] = ColorBackGround.LA.ToString(); newRow[79] = ColorBackGround.A.ToString(); newRow[80] = ColorBackGround.B.ToString(); newRow[81] = ColorBackGroundXYZ.X.ToString(); newRow[82] = ColorBackGroundXYZ.Y.ToString(); newRow[83] = ColorBackGroundXYZ.Z.ToString(); newRow[84] = 0; newRow[85] = 0; newRow[86] = 0; newRow[87] = 0; newRow[88] = 0; newRow[89] = 0; newRow[90] = 0; newRow[91] = 0; newRow[92] = 0; newRow[93] = 0; newRow[94] = 0; newRow[95] = 0; newRow[96] = 0; newRow[97] = 0; newRow[98] = ColorMeasured.L.ToString(); newRow[99] = ColorMeasured.U.ToString(); newRow[100] = ColorMeasured.V.ToString(); newRow[101] = ColorMeasured.UP.ToString(); newRow[102] = ColorMeasured.VP.ToString(); newRow[103] = ColorMeasured.LA.ToString(); newRow[104] = ColorMeasured.A.ToString(); newRow[105] = ColorMeasured.B.ToString(); newRow[106] = ColorMeasuredXYZ.X.ToString(); newRow[107] = ColorMeasuredXYZ.Y.ToString(); newRow[108] = ColorMeasuredXYZ.Z.ToString(); newRow[109] = MR.ToString(); newRow[110] = MG.ToString(); newRow[111] = MB.ToString(); newRow[112] = 0; newRow[113] = 0; newRow[114] = 0; newRow[115] = 0; newRow[116] = 0; newRow[117] = 0; newRow[118] = 0; newRow[119] = 0; newRow[120] = 0; newRow[121] = 0; newRow[122] = 0; newRow[123] = 0; newRow[124] = 0; newRow[125] = 0; newRow[126] = 0; newRow[127] = 0; newRow[128] = 0; newRow[129] = 0; newRow[130] = 0; newRow[131] = 0; newRow[132] = 0; newRow[133] = 0; newRow[134] = 0; newRow[135] = 0; newRow[136] = 0; newRow[137] = 0; newRow[138] = 0; newRow[139] = 0; newRow[140] = 0; newRow[141] = 0; newRow[142] = 0; newRow[143] = 0; newRow[144] = 0; newRow[145] = 0; newRow[146] = 0; newRow[147] = 0; newRow[148] = 0; newRow[149] = 0; newRow[150] = 0; newRow[151] = 0; newRow[152] = 0; newRow[153] = 0; newRow[154] = 0; newRow[155] = 0; newRow[156] = 0; newRow[157] = 0; newRow[158] = 0; newRow[159] = 0; newRow[160] = 0; newRow[161] = 0; newRow[162] = 0; newRow[163] = 0; newRow[164] = 0; newRow[165] = 0; newRow[166] = 0; newRow[167] = 0; newRow[168] = 0; newRow[169] = 0; newRow[170] = 0; newRow[171] = 0; newRow[172] = 0; newRow[173] = 0; newRow[174] = 0; newRow[175] = 0; newRow[176] = 0; newRow[177] = 0; newRow[178] = 0; newRow[179] = 0; newRow[180] = 0; MixedColor = ColorMeasured; pairs.Clear(); pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS ColorToShow = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(dt.Rows[j][20].ToString()), VP = Convert.ToDouble(dt.Rows[j][21].ToString()) }, ColorCaptured = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); dt.Rows.Add(newRow); } R = 0; G = 0; B = 0; //dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } } // dtgrid_corrDisplay.ItemsSource = dt.DefaultView; //dtgrid_corrDisplay.Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); // for caluclating just bg colour,.. with fg & bg white conditions so this for loop should be 3 more than loop for bg color change for (int i = 1; i < BgNo + 3; i++) { if (i < BgNo) { R = 0; G = 0; B = 0; BgR = Convert.ToByte(dt.Rows[i * FgNo][70].ToString()); BgG = Convert.ToByte(dt.Rows[i * FgNo][71].ToString()); BgB = Convert.ToByte(dt.Rows[i * FgNo][72].ToString()); } // both white else if (i == BgNo) { R = 255; G = 255; B = 255; BgR = 255; BgG = 255; BgB = 255; } // fg white else if (i == BgNo + 1) { R = 255; G = 255; B = 255; BgR = 0; BgG = 0; BgB = 0; } // bg white else { R = 0; G = 0; B = 0; BgR = 255; BgG = 255; BgB = 255; } ////if (i != 0) //System.Threading.Thread.Sleep(500); //ColorCaptureJustBG(); //System.Windows.Forms.Application.DoEvents(); ////does all the caputure and difference calculations //System.Threading.Thread.Sleep(500); //// StartCapture(); Dispatcher.Invoke(new Action(() => ColorCaptureJustBG())); // System.Windows.Forms.Application.DoEvents(); colorMeasured = StartCapture1(); Dispatcher.Invoke(new Action(() => DisplayMeasuredValues())); DifferenceCalculation(); //just bg capture newRow = dt.NewRow(); if (i < BgNo) { //newRow[0] = R.ToString(); //newRow[1] = G.ToString(); //newRow[2] = B.ToString(); //newRow[3] = 0; //newRow[4] = 0; //newRow[5] = 0; //newRow[6] = 0; //newRow[7] = 0; //newRow[8] = 0; //newRow[9] = 0; //newRow[10] = 0; //newRow[11] = 0; //newRow[12] = 0; //newRow[13] = 0; //newRow[14] = 0; //newRow[15] = 0; //newRow[16] = 0; //newRow[17] = 0; //newRow[18] = 0; //newRow[19] = BgR.ToString(); //newRow[20] = BgG.ToString(); //newRow[21] = BgB.ToString(); //newRow[22] = MR.ToString(); //newRow[23] = MG.ToString(); //newRow[24] = MB.ToString(); //newRow[25] = ColorMeasured.L.ToString(); //newRow[26] = ColorMeasured.U.ToString(); //newRow[27] = ColorMeasured.V.ToString(); //newRow[28] = ColorMeasured.UP.ToString(); //newRow[29] = ColorMeasured.VP.ToString(); //newRow[30] = 0; //newRow[31] = 0; //newRow[32] = 0; //newRow[33] = 0; //newRow[34] = 0; //newRow[35] = 0; //newRow[36] = 0; //newRow[37] = 0; newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = 0; newRow[20] = 0; newRow[21] = 0; newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = 0; newRow[31] = 0; newRow[32] = 0; newRow[33] = 0; newRow[34] = 0; newRow[35] = 0; newRow[36] = 0; newRow[37] = 0; newRow[38] = 0; newRow[39] = 0; newRow[40] = 0; newRow[41] = 0; newRow[42] = 0; newRow[43] = 0; newRow[44] = 0; newRow[45] = 0; newRow[46] = 0; newRow[47] = 0; newRow[48] = 0; newRow[49] = 0; newRow[50] = 0; newRow[51] = 0; newRow[52] = 0; newRow[53] = 0; newRow[54] = 0; newRow[55] = 0; newRow[56] = 0; newRow[57] = 0; newRow[58] = 0; newRow[59] = 0; newRow[60] = 0; newRow[61] = 0; newRow[62] = 0; newRow[63] = 0; newRow[64] = 0; newRow[65] = 0; newRow[66] = 0; newRow[67] = 0; newRow[68] = 0; newRow[69] = 0; newRow[70] = BgR.ToString(); newRow[71] = BgG.ToString(); newRow[72] = BgB.ToString(); newRow[73] = ColorBackGround.L.ToString(); newRow[74] = ColorBackGround.U.ToString(); newRow[75] = ColorBackGround.V.ToString(); newRow[76] = ColorBackGround.UP.ToString(); newRow[77] = ColorBackGround.VP.ToString(); newRow[78] = ColorBackGround.LA.ToString(); newRow[79] = ColorBackGround.A.ToString(); newRow[80] = ColorBackGround.B.ToString(); newRow[81] = ColorBackGroundXYZ.X.ToString(); newRow[82] = ColorBackGroundXYZ.Y.ToString(); newRow[83] = ColorBackGroundXYZ.Z.ToString(); newRow[84] = MR.ToString(); newRow[85] = MG.ToString(); newRow[86] = MB.ToString(); newRow[87] = ColorMeasured.L.ToString(); newRow[88] = ColorMeasured.U.ToString(); newRow[89] = ColorMeasured.V.ToString(); newRow[90] = ColorMeasured.UP.ToString(); newRow[91] = ColorMeasured.VP.ToString(); newRow[92] = ColorMeasured.LA.ToString(); newRow[93] = ColorMeasured.A.ToString(); newRow[94] = ColorMeasured.B.ToString(); newRow[95] = ColorMeasuredXYZ.X.ToString(); newRow[96] = ColorMeasuredXYZ.Y.ToString(); newRow[97] = ColorMeasuredXYZ.Z.ToString(); newRow[98] = 0; newRow[99] = 0; newRow[100] = 0; newRow[101] = 0; newRow[102] = 0; newRow[103] = 0; newRow[104] = 0; newRow[105] = 0; newRow[106] = 0; newRow[107] = 0; newRow[108] = 0; newRow[109] = 0; newRow[110] = 0; newRow[111] = 0; newRow[112] = 0; newRow[113] = 0; newRow[114] = 0; newRow[115] = 0; newRow[116] = 0; newRow[117] = 0; newRow[118] = 0; newRow[119] = 0; newRow[120] = 0; newRow[121] = 0; newRow[122] = 0; newRow[123] = 0; newRow[124] = 0; newRow[125] = 0; newRow[126] = 0; newRow[127] = 0; newRow[128] = 0; newRow[129] = 0; newRow[130] = 0; newRow[131] = 0; newRow[132] = 0; newRow[133] = 0; newRow[134] = 0; newRow[135] = 0; newRow[136] = 0; newRow[137] = 0; newRow[138] = 0; newRow[139] = 0; newRow[140] = 0; newRow[141] = 0; newRow[142] = 0; newRow[143] = 0; newRow[144] = 0; newRow[145] = 0; newRow[146] = 0; newRow[147] = 0; newRow[148] = 0; newRow[149] = 0; newRow[150] = 0; newRow[151] = 0; newRow[152] = 0; newRow[153] = 0; newRow[154] = 0; newRow[155] = 0; newRow[156] = 0; newRow[157] = 0; newRow[158] = 0; newRow[159] = 0; newRow[160] = 0; newRow[161] = 0; newRow[162] = 0; newRow[163] = 0; newRow[164] = 0; newRow[165] = 0; newRow[166] = 0; newRow[167] = 0; newRow[168] = 0; newRow[169] = 0; newRow[170] = 0; newRow[171] = 0; newRow[172] = 0; newRow[173] = 0; newRow[174] = 0; newRow[175] = 0; newRow[176] = 0; newRow[177] = 0; newRow[178] = 0; newRow[179] = 0; newRow[180] = 0; pairs.Clear(); BgColor = ColorMeasured; pairs.Add(new MeasurementPair() {//THE COLOUR DISPLAYED HERE ARE THE BG COLOUR CAPTURED BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } //white point capture else { //newRow[0] = R.ToString(); //newRow[1] = G.ToString(); //newRow[2] = B.ToString(); //newRow[3] = 0; //newRow[4] = 0; //newRow[5] = 0; //newRow[6] = 0; //newRow[7] = 0; //newRow[8] = 0; //newRow[9] = 0; //newRow[10] = 0; //newRow[11] = 0; //newRow[12] = 0; //newRow[13] = 0; //newRow[14] = 0; //newRow[15] = 0; //newRow[16] = 0; //newRow[17] = 0; //newRow[18] = 0; //newRow[19] = BgR.ToString(); //newRow[20] = BgG.ToString(); //newRow[21] = BgB.ToString(); //newRow[22] = 0; //newRow[23] = 0; //newRow[24] = 0; //newRow[25] = 0; //newRow[26] = 0; //newRow[27] = 0; //newRow[28] = 0; //newRow[29] = 0; //newRow[30] = ColorMeasured.L.ToString(); //newRow[31] = ColorMeasured.U.ToString(); //newRow[32] = ColorMeasured.V.ToString(); //newRow[33] = ColorMeasured.UP.ToString(); //newRow[34] = ColorMeasured.VP.ToString(); //newRow[35] = MR.ToString(); //newRow[36] = MG.ToString(); //newRow[37] = MB.ToString(); newRow[0] = R.ToString(); newRow[1] = G.ToString(); newRow[2] = B.ToString(); newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; newRow[6] = 0; newRow[7] = 0; newRow[8] = 0; newRow[9] = 0; newRow[10] = 0; newRow[11] = 0; newRow[12] = 0; newRow[13] = 0; newRow[14] = 0; newRow[15] = 0; newRow[16] = 0; newRow[17] = 0; newRow[18] = 0; newRow[19] = 0; newRow[20] = 0; newRow[21] = 0; newRow[22] = 0; newRow[23] = 0; newRow[24] = 0; newRow[25] = 0; newRow[26] = 0; newRow[27] = 0; newRow[28] = 0; newRow[29] = 0; newRow[30] = 0; newRow[31] = 0; newRow[32] = 0; newRow[33] = 0; newRow[34] = 0; newRow[35] = 0; newRow[36] = 0; newRow[37] = 0; newRow[38] = 0; newRow[39] = 0; newRow[40] = 0; newRow[41] = 0; newRow[42] = 0; newRow[43] = 0; newRow[44] = 0; newRow[45] = 0; newRow[46] = 0; newRow[47] = 0; newRow[48] = 0; newRow[49] = 0; newRow[50] = 0; newRow[51] = 0; newRow[52] = 0; newRow[53] = 0; newRow[54] = 0; newRow[55] = 0; newRow[56] = 0; newRow[57] = 0; newRow[58] = 0; newRow[59] = 0; newRow[60] = 0; newRow[61] = 0; newRow[62] = 0; newRow[63] = 0; newRow[64] = 0; newRow[65] = 0; newRow[66] = 0; newRow[67] = 0; newRow[68] = 0; newRow[69] = 0; newRow[70] = BgR.ToString(); newRow[71] = BgG.ToString(); newRow[72] = BgB.ToString(); newRow[73] = 0; newRow[74] = 0; newRow[75] = 0; newRow[76] = 0; newRow[77] = 0; newRow[78] = 0; newRow[79] = 0; newRow[80] = 0; newRow[81] = 0; newRow[82] = 0; newRow[83] = 0; newRow[84] = 0; newRow[85] = 0; newRow[86] = 0; newRow[87] = 0; newRow[88] = 0; newRow[89] = 0; newRow[90] = 0; newRow[91] = 0; newRow[92] = 0; newRow[93] = 0; newRow[94] = 0; newRow[95] = 0; newRow[96] = 0; newRow[97] = 0; newRow[98] = ColorMeasured.L.ToString(); newRow[99] = ColorMeasured.U.ToString(); newRow[100] = ColorMeasured.V.ToString(); newRow[101] = ColorMeasured.UP.ToString(); newRow[102] = ColorMeasured.VP.ToString(); newRow[103] = ColorMeasured.LA.ToString(); newRow[104] = ColorMeasured.A.ToString(); newRow[105] = ColorMeasured.B.ToString(); newRow[106] = ColorMeasuredXYZ.X.ToString(); newRow[107] = ColorMeasuredXYZ.Y.ToString(); newRow[108] = ColorMeasuredXYZ.Z.ToString(); newRow[109] = MR.ToString(); newRow[110] = MG.ToString(); newRow[111] = MB.ToString(); newRow[112] = 0; newRow[113] = 0; newRow[114] = 0; newRow[115] = 0; newRow[116] = 0; newRow[117] = 0; newRow[118] = 0; newRow[119] = 0; newRow[120] = 0; newRow[121] = 0; newRow[122] = 0; newRow[123] = 0; newRow[124] = 0; newRow[125] = 0; newRow[126] = 0; newRow[127] = 0; newRow[128] = 0; newRow[129] = 0; newRow[130] = 0; newRow[131] = 0; newRow[132] = 0; newRow[133] = 0; newRow[134] = 0; newRow[135] = 0; newRow[136] = 0; newRow[137] = 0; newRow[138] = 0; newRow[139] = 0; newRow[140] = 0; newRow[141] = 0; newRow[142] = 0; newRow[143] = 0; newRow[144] = 0; newRow[145] = 0; newRow[146] = 0; newRow[147] = 0; newRow[148] = 0; newRow[149] = 0; newRow[150] = 0; newRow[151] = 0; newRow[152] = 0; newRow[153] = 0; newRow[154] = 0; newRow[155] = 0; newRow[156] = 0; newRow[157] = 0; newRow[158] = 0; newRow[159] = 0; newRow[160] = 0; newRow[161] = 0; newRow[162] = 0; newRow[163] = 0; newRow[164] = 0; newRow[165] = 0; newRow[166] = 0; newRow[167] = 0; newRow[168] = 0; newRow[169] = 0; newRow[170] = 0; newRow[171] = 0; newRow[172] = 0; newRow[173] = 0; newRow[174] = 0; newRow[175] = 0; newRow[176] = 0; newRow[177] = 0; newRow[178] = 0; newRow[179] = 0; newRow[180] = 0; pairs.Add(new MeasurementPair() { // HERE 11 AND 12 ARE THE COLOUR CATPTURED BY THE CAMERA FOR DISPLAY 33 AND 34 ARE MIXED COLOURS BgColor = new PerceptionLib.Color() { L = 0, UP = Convert.ToDouble(ColorMeasured.UP.ToString()), VP = Convert.ToDouble(ColorMeasured.VP.ToString()) } }); } R = 10; dt.Rows.Add(newRow); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); } //taking back the measured value of bg to all the data set // adding mixed valued for cat and absolute back to all int totalRow = BgNo * FgNo; for (int i = 1; i < BgNo; i++) { for (int j = 0; j < fgNo; j++) { int rowNo = (i * FgNo) + j; // i am doing -1 cos the data set starts from 0 ,.. so in the first one it will still b e bg*fg but i value will be 0 dt.Rows[rowNo][84] = dt.Rows[(totalRow) + i - 1][84].ToString(); dt.Rows[rowNo][85] = dt.Rows[(totalRow) + i - 1][85].ToString(); dt.Rows[rowNo][86] = dt.Rows[(totalRow) + i - 1][86].ToString(); dt.Rows[rowNo][87] = dt.Rows[(totalRow) + i - 1][87].ToString(); dt.Rows[rowNo][88] = dt.Rows[(totalRow) + i - 1][88].ToString(); dt.Rows[rowNo][89] = dt.Rows[(totalRow) + i - 1][89].ToString(); dt.Rows[rowNo][90] = dt.Rows[(totalRow) + i - 1][90].ToString(); dt.Rows[rowNo][91] = dt.Rows[(totalRow) + i - 1][91].ToString(); dt.Rows[rowNo][92] = dt.Rows[(totalRow) + i - 1][92].ToString(); dt.Rows[rowNo][93] = dt.Rows[(totalRow) + i - 1][93].ToString(); dt.Rows[rowNo][94] = dt.Rows[(totalRow) + i - 1][94].ToString(); dt.Rows[rowNo][95] = dt.Rows[(totalRow) + i - 1][95].ToString(); dt.Rows[rowNo][96] = dt.Rows[(totalRow) + i - 1][96].ToString(); dt.Rows[rowNo][97] = dt.Rows[(totalRow) + i - 1][97].ToString(); ColorToShowXYZ.X = Convert.ToDouble(dt.Rows[rowNo][11].ToString()); ColorToShowXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][12].ToString()); ColorToShowXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][13].ToString()); ColorMeasuredXYZ.X = Convert.ToDouble(dt.Rows[rowNo][25].ToString()); ColorMeasuredXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][26].ToString()); ColorMeasuredXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][27].ToString()); ColorBackGroundXYZ.X = Convert.ToDouble(dt.Rows[rowNo][81].ToString()); ColorBackGroundXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][82].ToString()); ColorBackGroundXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][83].ToString()); // //McolorBackGroundXYZ.X = Convert.ToDouble(dt.Rows[rowNo][95].ToString()); //McolorBackGroundXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][96].ToString()); //McolorBackGroundXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][97].ToString()); ColorToShow.L = Convert.ToDouble(dt.Rows[rowNo][3].ToString()); ColorToShow.U = Convert.ToDouble(dt.Rows[rowNo][4].ToString()); ColorToShow.V = Convert.ToDouble(dt.Rows[rowNo][5].ToString()); ColorToShow.LA = Convert.ToDouble(dt.Rows[rowNo][8].ToString()); ColorToShow.A = Convert.ToDouble(dt.Rows[rowNo][9].ToString()); ColorToShow.B = Convert.ToDouble(dt.Rows[rowNo][10].ToString()); ColorMeasured.L = Convert.ToDouble(dt.Rows[rowNo][17].ToString()); ColorMeasured.U = Convert.ToDouble(dt.Rows[rowNo][18].ToString()); ColorMeasured.V = Convert.ToDouble(dt.Rows[rowNo][19].ToString()); ColorMeasured.LA = Convert.ToDouble(dt.Rows[rowNo][22].ToString()); ColorMeasured.A = Convert.ToDouble(dt.Rows[rowNo][23].ToString()); ColorMeasured.B = Convert.ToDouble(dt.Rows[rowNo][24].ToString()); // HERE I CHOSE TO USE BG COLOR IN PLACES OF MEASURE COLOR !! BgColor.L = Convert.ToDouble(dt.Rows[rowNo][98].ToString()); BgColor.U = Convert.ToDouble(dt.Rows[rowNo][99].ToString()); BgColor.V = Convert.ToDouble(dt.Rows[rowNo][100].ToString()); BgColor.LA = Convert.ToDouble(dt.Rows[rowNo][103].ToString()); BgColor.A = Convert.ToDouble(dt.Rows[rowNo][104].ToString()); BgColor.B = Convert.ToDouble(dt.Rows[rowNo][105].ToString()); BradXYZ.X = Convert.ToDouble(dt.Rows[rowNo][36].ToString()); BradXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][37].ToString()); BradXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][38].ToString()); VonXYZ.X = Convert.ToDouble(dt.Rows[rowNo][50].ToString()); VonXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][51].ToString()); VonXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][52].ToString()); ScalingXYZ.X = Convert.ToDouble(dt.Rows[rowNo][64].ToString()); ScalingXYZ.Y = Convert.ToDouble(dt.Rows[rowNo][65].ToString()); ScalingXYZ.Z = Convert.ToDouble(dt.Rows[rowNo][66].ToString()); AcolorXYZ = Util.ColorSpaceConverter.AddXYZ(ColorToShowXYZ, ColorBackGroundXYZ); Acolor = Util.ColorSpaceConverter.XYZToLABLUV(ColorToShowXYZ, ColorBackGroundXYZ); acolorRGB = Util.ColorSpaceConverter.XYZToRGB(ColorToShowXYZ, ColorBackGroundXYZ); // i use original bg color not captured bg color MBradXYZ = Util.ColorSpaceConverter.AddXYZ(BradXYZ, ColorBackGroundXYZ); MBradcolor = Util.ColorSpaceConverter.XYZToLABLUV(BradXYZ, ColorBackGroundXYZ); MbradRGB = Util.ColorSpaceConverter.XYZToRGB(BradXYZ, ColorBackGroundXYZ); MVonXYZ = Util.ColorSpaceConverter.AddXYZ(VonXYZ, ColorBackGroundXYZ); MVoncolor = Util.ColorSpaceConverter.XYZToLABLUV(VonXYZ, ColorBackGroundXYZ); MVonRGB = Util.ColorSpaceConverter.XYZToRGB(VonXYZ, ColorBackGroundXYZ); MScalingXYZ = Util.ColorSpaceConverter.AddXYZ(ScalingXYZ, ColorBackGroundXYZ); MScalingcolor = Util.ColorSpaceConverter.XYZToLABLUV(ScalingXYZ, ColorBackGroundXYZ); MscalingRGB = Util.ColorSpaceConverter.XYZToRGB(ScalingXYZ, ColorBackGroundXYZ); dt.Rows[rowNo][112] = Acolor.L.ToString(); dt.Rows[rowNo][113] = Acolor.U.ToString(); dt.Rows[rowNo][114] = Acolor.V.ToString(); dt.Rows[rowNo][115] = Acolor.UP.ToString(); dt.Rows[rowNo][116] = Acolor.VP.ToString(); dt.Rows[rowNo][117] = Acolor.LA.ToString(); dt.Rows[rowNo][118] = Acolor.A.ToString(); dt.Rows[rowNo][119] = Acolor.B.ToString(); dt.Rows[rowNo][120] = AcolorXYZ.X.ToString(); dt.Rows[rowNo][121] = AcolorXYZ.Y.ToString(); dt.Rows[rowNo][122] = AcolorXYZ.Z.ToString(); dt.Rows[rowNo][123] = acolorRGB.R.ToString(); dt.Rows[rowNo][124] = acolorRGB.G.ToString(); dt.Rows[rowNo][125] = acolorRGB.B.ToString(); dt.Rows[rowNo][126] = MBradcolor.L.ToString(); dt.Rows[rowNo][127] = MBradcolor.U.ToString(); dt.Rows[rowNo][128] = MBradcolor.V.ToString(); dt.Rows[rowNo][129] = MBradcolor.UP.ToString(); dt.Rows[rowNo][130] = MBradcolor.VP.ToString(); dt.Rows[rowNo][131] = MBradcolor.LA.ToString(); dt.Rows[rowNo][132] = MBradcolor.A.ToString(); dt.Rows[rowNo][133] = MBradcolor.B.ToString(); dt.Rows[rowNo][134] = MBradXYZ.X.ToString(); dt.Rows[rowNo][135] = MBradXYZ.Y.ToString(); dt.Rows[rowNo][136] = MBradXYZ.Z.ToString(); dt.Rows[rowNo][137] = MbradRGB.R.ToString(); dt.Rows[rowNo][138] = MbradRGB.G.ToString(); dt.Rows[rowNo][139] = MbradRGB.B.ToString(); dt.Rows[rowNo][140] = MVoncolor.L.ToString(); dt.Rows[rowNo][141] = MVoncolor.U.ToString(); dt.Rows[rowNo][142] = MVoncolor.V.ToString(); dt.Rows[rowNo][143] = MVoncolor.UP.ToString(); dt.Rows[rowNo][144] = MVoncolor.VP.ToString(); dt.Rows[rowNo][145] = MVoncolor.LA.ToString(); dt.Rows[rowNo][146] = MVoncolor.A.ToString(); dt.Rows[rowNo][147] = MVoncolor.B.ToString(); dt.Rows[rowNo][148] = MVonXYZ.X.ToString(); dt.Rows[rowNo][149] = MVonXYZ.Y.ToString(); dt.Rows[rowNo][150] = MVonXYZ.Z.ToString(); dt.Rows[rowNo][151] = MVonRGB.R.ToString(); dt.Rows[rowNo][152] = MVonRGB.G.ToString(); dt.Rows[rowNo][153] = MVonRGB.B.ToString(); dt.Rows[rowNo][154] = MScalingcolor.L.ToString(); dt.Rows[rowNo][155] = MScalingcolor.U.ToString(); dt.Rows[rowNo][156] = MScalingcolor.V.ToString(); dt.Rows[rowNo][157] = MScalingcolor.UP.ToString(); dt.Rows[rowNo][158] = MScalingcolor.VP.ToString(); dt.Rows[rowNo][159] = MScalingcolor.LA.ToString(); dt.Rows[rowNo][160] = MScalingcolor.A.ToString(); dt.Rows[rowNo][161] = MScalingcolor.B.ToString(); dt.Rows[rowNo][162] = MScalingXYZ.X.ToString(); dt.Rows[rowNo][163] = MScalingXYZ.Y.ToString(); dt.Rows[rowNo][164] = MScalingXYZ.Z.ToString(); dt.Rows[rowNo][165] = MscalingRGB.R.ToString(); dt.Rows[rowNo][166] = MscalingRGB.G.ToString(); dt.Rows[rowNo][167] = MscalingRGB.B.ToString(); dt.Rows[rowNo][168] = 0; dt.Rows[rowNo][169] = acolorRGB.gmt; dt.Rows[rowNo][170] = MbradRGB.gmt; dt.Rows[rowNo][171] = MVonRGB.gmt; dt.Rows[rowNo][172] = MscalingRGB.gmt; dt.Rows[rowNo][173] = PerceptionLib.Color.ColorDistanceCal(BgColor, Acolor).ToString(); dt.Rows[rowNo][174] = PerceptionLib.Color.ColorDistanceCalAB(BgColor, Acolor).ToString(); dt.Rows[rowNo][175] = PerceptionLib.Color.ColorDistanceCal(BgColor, Bradcolor).ToString(); dt.Rows[rowNo][176] = PerceptionLib.Color.ColorDistanceCalAB(BgColor, Bradcolor).ToString(); dt.Rows[rowNo][177] = PerceptionLib.Color.ColorDistanceCal(BgColor, Voncolor).ToString(); dt.Rows[rowNo][178] = PerceptionLib.Color.ColorDistanceCalAB(BgColor, Voncolor).ToString(); dt.Rows[rowNo][179] = PerceptionLib.Color.ColorDistanceCal(BgColor, Scalingcolor).ToString(); dt.Rows[rowNo][180] = PerceptionLib.Color.ColorDistanceCalAB(BgColor, Scalingcolor).ToString(); dt.Rows[rowNo][181] = PerceptionLib.Color.ColorDistanceCalAB(ColorToShow, ColorMeasured).ToString(); dt.Rows[rowNo][182] = PerceptionLib.Color.ColorDistanceCalAB(BgColor, ColorMeasured).ToString(); } } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = dt.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); dataTable = dt; }); cmb_graph.IsEnabled = true; btn_ExportGrid.IsEnabled = true; // captureDevice.Dispose(); }
private void btn_1024x768_Click(object sender, RoutedEventArgs e) { Matrix3D navigationMatrix = new Matrix3D(); navigationMatrix.Translate(new Vector3D(0, 100, 110)); navigationMatrix.Scale(new Vector3D((double)1 / 5, (double)1 / 5, (double)1 / 5)); //2- Load the profile in a three dimensional array Bin[, ,] p3700 = new Bin[RANGEL, RANGEA, RANGEB]; for (int l = 0; l < RANGEL; l++) { for (int a = 0; a < RANGEA; a++) { for (int b = 0; b < RANGEB; b++) { p3700[l, a, b] = new Bin(l, a, b); } } } try { // add the csv bin file using (GenericParserAdapter parser = new GenericParserAdapter(@"C:\Users\jhincapie\Desktop\Projects\STColorCorrection\Data\PROFILE\p3700.csv")) { System.Data.DataSet dsResult = parser.GetDataSet(); profile = dsResult.Tables[0]; } } catch { } for (int i = 1; i < profile.Rows.Count; i++) { //lab vale as got form profile index Point3D labBin = new Point3D(); labBin.X = Convert.ToDouble(profile.Rows[i][0].ToString()); labBin.Y = Convert.ToDouble(profile.Rows[i][1].ToString()); labBin.Z = Convert.ToDouble(profile.Rows[i][2].ToString()); //trasfered points Point3D labCoordinate = navigationMatrix.Transform(labBin); //gets the bin to fill up Bin actualBin = GetProfileBin(p3700, labCoordinate); //bin RGB Value actualBin.binRGB.X = Convert.ToByte(profile.Rows[i][9].ToString()); actualBin.binRGB.Y = Convert.ToByte(profile.Rows[i][10].ToString()); actualBin.binRGB.Z = Convert.ToByte(profile.Rows[i][11].ToString()); //Measure Lab Values actualBin.measuredLAB.X = Convert.ToDouble(profile.Rows[i][3].ToString()); actualBin.measuredLAB.Y = Convert.ToDouble(profile.Rows[i][4].ToString()); actualBin.measuredLAB.Z = Convert.ToDouble(profile.Rows[i][5].ToString()); //measured XYZ Values actualBin.measuredXYZ.X = Convert.ToDouble(profile.Rows[i][6].ToString()); actualBin.measuredXYZ.Y = Convert.ToDouble(profile.Rows[i][7].ToString()); actualBin.measuredXYZ.Z = Convert.ToDouble(profile.Rows[i][8].ToString()); //is empty check actualBin.isEmpty = false; } Stopwatch stop2 = new Stopwatch(); stop2.Start(); // to create a random number Random randomGenerater = new Random(); for (int i = 0; i < 1024; i++) { for (int j = 0; j < 768; j++) { Byte[] rgb = new Byte[3]; randomGenerater.NextBytes(rgb); System.Drawing.Color foreground = System.Drawing.Color.FromArgb(rgb[0], rgb[1], rgb[2]); PerceptionLib.CIEXYZ backgroundCIEXYZ = new CIEXYZ(0, 0, 0); backgroundCIEXYZ.X = randomGenerater.NextDouble() * 0.9504; backgroundCIEXYZ.Y = randomGenerater.NextDouble() * 1.0000; backgroundCIEXYZ.Z = randomGenerater.NextDouble() * 1.0888; Point3D background = new Point3D(backgroundCIEXYZ.X, backgroundCIEXYZ.Y, backgroundCIEXYZ.Z); Bin foregroundBin = FindForegroundBin(p3700, navigationMatrix, foreground); PerceptionLib.Color fg = new PerceptionLib.Color(); //fg measured LAB value fg.LA = foregroundBin.measuredLAB.X; fg.A = foregroundBin.measuredLAB.Y; fg.B = foregroundBin.measuredLAB.Z; Bin corretedColorQCHS = QuickCorrection(p3700, navigationMatrix, foreground, background, HalfTheStep); } } stop2.Stop(); Console.WriteLine(stop2.ElapsedMilliseconds); }
private void DifferenceCalculation() { ColorDifference = new PerceptionLib.Color(); colorDifference.L = ColorToShow.L - ColorMeasured.L; colorDifference.U = ColorToShow.U - ColorMeasured.U; colorDifference.V = ColorToShow.V - ColorMeasured.V; colorDifference.UP = ColorToShow.UP - ColorMeasured.UP; colorDifference.VP = ColorToShow.VP - ColorMeasured.VP; }
private void HueDifference_Click(object sender, RoutedEventArgs e) { PopulateGrid(@"C:\see-through-project\gt\STColorCorrection\Src\STColorPerception\bin\value\Reduscer_angles.csv"); DataTable bin = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); bin = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); double m, l, p, aa, am, al, ap; PerceptionLib.Color Acolor = new PerceptionLib.Color(); PerceptionLib.Color Mcolor = new PerceptionLib.Color(); PerceptionLib.Color Lcolor = new PerceptionLib.Color(); PerceptionLib.Color Pcolor = new PerceptionLib.Color(); foreach (DataRow dr in bin.Rows) { //i++; Acolor.LA = Convert.ToDouble(dr["AL"].ToString()); Acolor.A = Convert.ToDouble(dr["AA"].ToString()); Acolor.B = Convert.ToDouble(dr["AB"].ToString()); Mcolor.LA = Convert.ToDouble(dr["ML"].ToString()); Mcolor.A = Convert.ToDouble(dr["MA"].ToString()); Mcolor.B = Convert.ToDouble(dr["MB"].ToString()); Lcolor.LA = Convert.ToDouble(dr["LL"].ToString()); Lcolor.A = Convert.ToDouble(dr["LA"].ToString()); Lcolor.B = Convert.ToDouble(dr["LB"].ToString()); Pcolor.LA = Convert.ToDouble(dr["PL"].ToString()); Pcolor.A = Convert.ToDouble(dr["PA"].ToString()); Pcolor.B = Convert.ToDouble(dr["PB"].ToString()); m = CATCalulation.hueDifference(Mcolor, Acolor); l = CATCalulation.hueDifference(Mcolor, Lcolor); p = CATCalulation.hueDifference(Mcolor, Pcolor); aa = CATCalulation.HueAngle(Acolor); am = CATCalulation.HueAngle(Mcolor); al = CATCalulation.HueAngle(Lcolor); ap = CATCalulation.HueAngle(Pcolor); dr["m"] = m.ToString(); dr["l"] = l.ToString(); dr["p"] = p.ToString(); dr["aacc"] = aa.ToString(); dr["am"] = am.ToString(); dr["alum"] = al.ToString(); dr["ap"] = ap.ToString(); } Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.ItemsSource = bin.DefaultView)); Dispatcher.Invoke(new Action(() => dtgrid_corrDisplay.Items.Refresh())); btn_ExportGrid.IsEnabled = true; }
private void btn_Start_Click(object sender, RoutedEventArgs e) { Matrix3D navigationMatrix = new Matrix3D(); navigationMatrix.Translate(new Vector3D(0, 100, 110)); navigationMatrix.Scale(new Vector3D((double)1 / 5, (double)1 / 5, (double)1 / 5)); //2- Load the profile in a three dimensional array Bin[, ,] p3700 = new Bin[RANGEL, RANGEA, RANGEB]; for (int l = 0; l < RANGEL; l++) { for (int a = 0; a < RANGEA; a++) { for (int b = 0; b < RANGEB; b++) { p3700[l, a, b] = new Bin(l, a, b); } } } try { // add the csv bin file using (GenericParserAdapter parser = new GenericParserAdapter(Environment.CurrentDirectory + @"\..\..\..\..\..\Data\PROFILE\IdealProfile.csv")) { System.Data.DataSet dsResult = parser.GetDataSet(); profile = dsResult.Tables[0]; } } catch { } for (int i = 1; i < profile.Rows.Count; i++) { //lab vale as got form profile index Point3D labBin = new Point3D(); labBin.X = Convert.ToDouble(profile.Rows[i][0].ToString()); labBin.Y = Convert.ToDouble(profile.Rows[i][1].ToString()); labBin.Z = Convert.ToDouble(profile.Rows[i][2].ToString()); //trasfered points Point3D labCoordinate = navigationMatrix.Transform(labBin); //gets the bin to fill up Bin actualBin = GetProfileBin(p3700, labCoordinate); //bin RGB Value actualBin.binRGB.X = Convert.ToByte(profile.Rows[i][9].ToString()); actualBin.binRGB.Y = Convert.ToByte(profile.Rows[i][10].ToString()); actualBin.binRGB.Z = Convert.ToByte(profile.Rows[i][11].ToString()); //Measure Lab Values actualBin.measuredLAB.X = Convert.ToDouble(profile.Rows[i][3].ToString()); actualBin.measuredLAB.Y = Convert.ToDouble(profile.Rows[i][4].ToString()); actualBin.measuredLAB.Z = Convert.ToDouble(profile.Rows[i][5].ToString()); //measured XYZ Values actualBin.measuredXYZ.X = Convert.ToDouble(profile.Rows[i][6].ToString()); actualBin.measuredXYZ.Y = Convert.ToDouble(profile.Rows[i][7].ToString()); actualBin.measuredXYZ.Z = Convert.ToDouble(profile.Rows[i][8].ToString()); //is empty check actualBin.isEmpty = false; } //3- Get the parameters: foreground and background //System.Drawing.Color foreground = System.Drawing.Color.FromArgb(150, 150, 150); //PerceptionLib.CIEXYZ background = new CIEXYZ(0.2146, 0.43125, 0.07595); //RGB: 0 199 0 - greenish ///////////////// //code for comarison //populate template in datagrid PopulateGrid(Environment.CurrentDirectory + @"\..\..\..\..\..\Data\PROFILE\Comparison_Template.txt"); DataTable template = new DataTable(); Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { dtgrid_corrDisplay.Items.Refresh(); template = ((DataView)dtgrid_corrDisplay.ItemsSource).ToTable(); })); // to create a random number Random randomGenerater = new Random(); for (int i = 0; i < 1000; i++) { Byte[] rgb = new Byte[3]; randomGenerater.NextBytes(rgb); System.Drawing.Color foreground = System.Drawing.Color.FromArgb(rgb[0], rgb[1], rgb[2]); PerceptionLib.CIEXYZ backgroundCIEXYZ = new CIEXYZ(0, 0, 0); backgroundCIEXYZ.X = randomGenerater.NextDouble() * 0.9504; backgroundCIEXYZ.Y = randomGenerater.NextDouble() * 1.0000; backgroundCIEXYZ.Z = randomGenerater.NextDouble() * 1.0888; Point3D background = new Point3D(backgroundCIEXYZ.X, backgroundCIEXYZ.Y, backgroundCIEXYZ.Z); try { Bin foregroundBin = FindForegroundBin(p3700, navigationMatrix, foreground); PerceptionLib.Color foregroundLAB = new PerceptionLib.Color(); //fg measured LAB value foregroundLAB.LA = foregroundBin.measuredLAB.X; foregroundLAB.A = foregroundBin.measuredLAB.Y; foregroundLAB.B = foregroundBin.measuredLAB.Z; Stopwatch stop1 = new Stopwatch(); stop1.Start(); Bin corretedColorBF = null; corretedColorBF = BruteForceCorrection(p3700, navigationMatrix, foreground, background); stop1.Stop(); Stopwatch stop2 = new Stopwatch(); stop2.Start(); Bin corretedColorQCHS = QuickCorrection(p3700, navigationMatrix, foreground, background, HalfTheStep); stop2.Stop(); Stopwatch stop3 = new Stopwatch(); stop3.Start(); Bin corretedColorQCD = QuickCorrection(p3700, navigationMatrix, foreground, background, DecreaseTheStep); stop3.Stop(); Stopwatch stop4 = new Stopwatch(); stop4.Start(); Bin corretedColorSC = SnakeCorrection(p3700, navigationMatrix, foreground, background); stop4.Stop(); DataRow newRow = template.NewRow(); newRow["FgR"] = foreground.R.ToString(); newRow["FgG"] = foreground.G.ToString(); newRow["FgB"] = foreground.B.ToString(); newRow["BgX"] = background.X.ToString(); newRow["BgY"] = background.Y.ToString(); newRow["BgZ"] = background.Z.ToString(); newRow["FgL"] = foregroundLAB.LA.ToString(); newRow["FgA"] = foregroundLAB.A.ToString(); newRow["Fg_B"] = foregroundLAB.B.ToString(); newRow["BFL"] = corretedColorBF.binLAB.X.ToString(); newRow["BFA"] = corretedColorBF.binLAB.Y.ToString(); newRow["BFB"] = corretedColorBF.binLAB.Z.ToString(); newRow["BFDis"] = corretedColorBF.distanceLAB.ToString(); newRow["BFTime"] = stop1.ElapsedTicks.ToString(); newRow["QCHSL"] = corretedColorQCHS.binLAB.X.ToString(); newRow["QCHSA"] = corretedColorQCHS.binLAB.Y.ToString(); newRow["QCHSB"] = corretedColorQCHS.binLAB.Z.ToString(); newRow["QCHSCycles"] = corretedColorQCHS.cycles; newRow["QCHSDis"] = corretedColorQCHS.distanceLAB.ToString(); newRow["QCHSOffSet"] = Math.Abs(corretedColorBF.distanceLAB - corretedColorQCHS.distanceLAB); newRow["QCHSTime"] = stop2.ElapsedTicks.ToString(); newRow["QCHSRatio"] = (stop1.ElapsedTicks / stop2.ElapsedTicks).ToString(); newRow["QCDL"] = corretedColorQCD.binLAB.X.ToString(); newRow["QCDA"] = corretedColorQCD.binLAB.Y.ToString(); newRow["QCDB"] = corretedColorQCD.binLAB.Z.ToString(); newRow["QCDCycles"] = corretedColorQCD.cycles; newRow["QCDDis"] = corretedColorQCD.distanceLAB.ToString(); newRow["QCDOffSet"] = Math.Abs(corretedColorBF.distanceLAB - corretedColorQCD.distanceLAB); newRow["QCDTime"] = stop3.ElapsedTicks.ToString(); newRow["QCDRatio"] = (stop1.ElapsedTicks / stop3.ElapsedTicks).ToString(); newRow["SCL"] = corretedColorSC.binLAB.X.ToString(); newRow["SCA"] = corretedColorSC.binLAB.Y.ToString(); newRow["SCB"] = corretedColorSC.binLAB.Z.ToString(); newRow["SCCycles"] = corretedColorSC.cycles; newRow["SCDis"] = corretedColorSC.distanceLAB.ToString(); newRow["SCOffSet"] = Math.Abs(corretedColorBF.distanceLAB - corretedColorSC.distanceLAB); newRow["SCTime"] = stop4.ElapsedTicks.ToString(); newRow["SCRatio"] = (stop1.ElapsedTicks / stop4.ElapsedTicks).ToString(); template.Rows.Add(newRow); } catch { Console.WriteLine(""); } } Dispatcher.Invoke(new Action(() => { dtgrid_corrDisplay.ItemsSource = template.DefaultView; dtgrid_corrDisplay.Items.Refresh(); })); }