public ImageProcessing() { byte Ri = (int)FilterColors.R; byte Gi = (int)FilterColors.G; byte Bi = (int)FilterColors.B; byte Yi = (int)FilterColors.Y; BaseColors = new Color[4]; BaseColors[Ri] = Color.FromArgb(237, 120, 188); BaseColors[Gi] = Color.FromArgb(99, 221, 135); BaseColors[Bi] = Color.FromArgb(44, 207, 254); BaseColors[Yi] = Color.FromArgb(215, 234, 112); Ratios = new ColorRatios[4]; for (int i = 0; i < 4; i++) { Ratios[i].RatioRG = (float)BaseColors[i].R / (float)BaseColors[i].G; Ratios[i].RatioRB = (float)BaseColors[i].R / (float)BaseColors[i].B; Ratios[i].RatioGB = (float)BaseColors[i].G / (float)BaseColors[i].B; Ratios[i].LimitRG = 0.5f; Ratios[i].LimitRB = 0.5f; Ratios[i].LimitGB = 0.5f; } // Default settings RedHSVCoef = new HSVCoefficients(154, 255, 106, 255, 160, 255); GreenHSVCoef = new HSVCoefficients(39, 75, 111, 255, 100, 255); BlueHSVCoef = new HSVCoefficients(75, 122, 173, 255, 186, 255); YellowHSVCoef = new HSVCoefficients(20, 43, 27, 255, 181, 255); }
private void WriteHSVcoefficient(RegistryKey rk, HSVCoefficients coefficients, string colorName) { rk.SetValue(colorName + "HueDown", coefficients.HueDown.ToString()); rk.SetValue(colorName + "HueUp", coefficients.HueUp.ToString()); rk.SetValue(colorName + "SatDown", coefficients.SatDown.ToString()); rk.SetValue(colorName + "SatUp", coefficients.SatUp.ToString()); rk.SetValue(colorName + "ValueDown", coefficients.ValueDown.ToString()); rk.SetValue(colorName + "ValueUp", coefficients.ValueUp.ToString()); }
private void ReadHSVCoefficient(RegistryKey rk, HSVCoefficients coefficients, string colorName) { string result = (string)rk.GetValue(colorName + "HueDown"); if (result != null) { byte.TryParse(result, out coefficients.HueDown); } result = (string)rk.GetValue(colorName + "HueUp"); if (result != null) { byte.TryParse(result, out coefficients.HueUp); } result = (string)rk.GetValue(colorName + "SatDown"); if (result != null) { byte.TryParse(result, out coefficients.SatDown); } result = (string)rk.GetValue(colorName + "SatUp"); if (result != null) { byte.TryParse(result, out coefficients.SatUp); } result = (string)rk.GetValue(colorName + "ValueDown"); if (result != null) { byte.TryParse(result, out coefficients.ValueDown); } result = (string)rk.GetValue(colorName + "ValueUp"); if (result != null) { byte.TryParse(result, out coefficients.ValueUp); } }