/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new SaltPepperParameter FromProto(RawProto rp) { SaltPepperParameter p = new SaltPepperParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("fraction")) != null) { p.fraction = float.Parse(strVal); } p.value = new List <float>(); RawProtoCollection col = rp.FindChildren("value"); foreach (RawProto rp1 in col) { if ((strVal = rp.FindValue("value")) != null) { p.value.Add(float.Parse(strVal)); } } return(p); }
/// <summary> /// Copy the object. /// </summary> /// <param name="src">The copy is placed in this parameter.</param> public void Copy(SaltPepperParameter src) { m_fFraction = src.fraction; m_rgValue = new List <float>(); foreach (float fVal in src.value) { m_rgValue.Add(fVal); } }
/// <summary> /// Copy the object. /// </summary> /// <param name="src">The copy is placed in this parameter.</param> public override void Copy(OptionalParameter src) { base.Copy(src); if (src is SaltPepperParameter) { SaltPepperParameter p = (SaltPepperParameter)src; m_fFraction = p.fraction; m_rgValue = new List <float>(); foreach (float fVal in p.value) { m_rgValue.Add(fVal); } } }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static SaltPepperParameter FromProto(RawProto rp) { SaltPepperParameter p = new SaltPepperParameter(); string strVal; if ((strVal = rp.FindValue("fraction")) != null) { p.fraction = float.Parse(strVal); } p.value = new List <float>(); RawProtoCollection col = rp.FindChildren("value"); foreach (RawProto rp1 in col) { if ((strVal = rp.FindValue("value")) != null) { p.value.Add(float.Parse(strVal)); } } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new NoiseParameter FromProto(RawProto rp) { NoiseParameter p = new NoiseParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("prob")) != null) { p.prob = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("hist_eq")) != null) { p.hist_eq = bool.Parse(strVal); } if ((strVal = rp.FindValue("inverse")) != null) { p.inverse = bool.Parse(strVal); } if ((strVal = rp.FindValue("decolorize")) != null) { p.decolorize = bool.Parse(strVal); } if ((strVal = rp.FindValue("gauss_blur")) != null) { p.gauss_blur = bool.Parse(strVal); } if ((strVal = rp.FindValue("jpeg")) != null) { p.jpeg = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("posterize")) != null) { p.posterize = bool.Parse(strVal); } if ((strVal = rp.FindValue("erode")) != null) { p.erode = bool.Parse(strVal); } if ((strVal = rp.FindValue("saltpepper")) != null) { p.saltpepper = bool.Parse(strVal); } RawProto rp1 = rp.FindChild("saltpepper_param"); if (rp1 != null) { p.saltpepper_param = SaltPepperParameter.FromProto(rp1); } if ((strVal = rp.FindValue("clahe")) != null) { p.clahe = bool.Parse(strVal); } if ((strVal = rp.FindValue("convert_to_hsv")) != null) { p.convert_to_hsv = bool.Parse(strVal); } if ((strVal = rp.FindValue("convert_to_lab")) != null) { p.convert_to_lab = bool.Parse(strVal); } return(p); }