示例#1
0
        /// <summary>
        /// Creates a copy of this <see cref="SmoothProperties"/> object.
        /// </summary>
        /// <returns>A new instance of the <see cref="SmoothProperties"/>
        /// class with the same values as the current instance.</returns>
        public object Clone()
        {
            SmoothProperties s = new SmoothProperties();

            s.SmoothMode = SmoothMode;
            s.Smoother   = (ISmoother)Smoother.Clone();
            return(s);
        }
示例#2
0
        /// <summary>
        /// Executes the algorithm represented by this <see cref="AlgorithmPlugin"/>.
        /// </summary>
        /// <param name="parameterObject">An object of the type provided by the
        /// <see cref="AlgorithmAttribute"/> describing the properties used by this
        /// <see cref="AlgorithmPlugin"/>.</param>
        /// <exception cref="AlgorithmException">an internal exception has occured. This
        /// is accessed through the inner exception property.</exception>
        public override void Run(object parameterObject)
        {
            if (parameterObject is SmoothProperties == false)
            {
                throw new AlgorithmException("Parameter object is not a SmoothProperties instance");
            }

            SmoothProperties  p      = parameterObject as SmoothProperties;
            Bitmap            bmp    = new Bitmap(Input);
            Image <Rgb, byte> img    = new Image <Rgb, byte>(bmp);
            IImage            output = p.Smoother.Smooth(img);

            Output = output.Bitmap;
        }
示例#3
0
        /// <summary>
        /// Converts the provided Xml back into the appropriate parameter
        /// object for the algorithm
        /// </summary>
        /// <param name="parameterXml">The <see cref="XElement"/> describing the properties
        /// within the object.</param>
        /// <returns>The appropriate object used to describe the parameters
        /// for the process.</returns>
        public ICloneable CreateObject(XElement parameterXml)
        {
            if (parameterXml == null)
            {
                return(new SmoothProperties());
            }

            SmoothProperties p            = new SmoothProperties();
            XAttribute       smootherAttr = parameterXml.Attribute("smoother");

            if (smootherAttr != null)
            {
                p.SmoothMode = smootherAttr.Value;
            }

            _populateSmoother(p.Smoother, parameterXml.Descendants("property"));
            return(p);
        }
示例#4
0
        /// <summary>
        /// Converts the parameter object provided by the
        /// <see cref="AlgorithmDefinition"/> containing the properties
        /// to persist.
        /// </summary>
        /// <param name="parameterObject">The value of the algorithms
        /// parameter object</param>
        /// <returns>The <see cref="XElement"/> describing the properties
        /// within the object.</returns>
        public XElement CreateXml(ICloneable parameterObject)
        {
            if (parameterObject is SmoothProperties == false)
            {
                return(new XElement("properties"));
            }

            SmoothProperties s = parameterObject as SmoothProperties;

            // Save the state of the public properties in the smoother
            string     smootherID   = s.SmoothMode;
            XAttribute smootherAttr = new XAttribute("smoother", smootherID);

            Type smootherType  = s.Smoother.GetType();
            var  propertyInfos = smootherType.GetProperties();
            var  properties    = from property in propertyInfos
                                 select new XElement("property",
                                                     new XAttribute("name", property.Name),
                                                     _objtoBinString(property.GetValue(s.Smoother)));

            return(new XElement("properties", smootherAttr, properties));;
        }