Exemplo n.º 1
0
        public Ptype.Mutable BuildPrototype(IBuildPrototypeArgs args)
        {
            Examples      eargs     = args.Examples;
            List <Bitmap> positives = eargs.Positives;
            List <Bitmap> negatives = eargs.Negatives;

            Bitmap feature = Utils.CombineBitmapsAndMakeDifferencesTransparent(positives);

            foreach (Bitmap neg in negatives)
            {
                if (Utils.MatchesIgnoringTransparentPixels(feature, neg))
                {
                    return(null);
                }
            }

            Dictionary <string, Bitmap> dict = new Dictionary <string, Bitmap>();

            dict.Add("part", feature);


            try {
                return(new Ptype.Mutable(dict, new Dictionary <String, Region>()));
            } catch {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parameterizes a prototype using a branch and bound search algorithm.
        /// </summary>
        /// <param name="positives">Positive example bitmaps</param>
        /// <param name="negatives">Negative example bitmaps</param>
        /// <returns></returns>
        public Ptype.Mutable BuildPrototype(IBuildPrototypeArgs args)
        {
            Examples             eargs     = args.Examples;
            IEnumerable <Bitmap> positives = eargs.Positives;
            IEnumerable <Bitmap> negatives = eargs.Negatives;

            Dictionary <string, Part> parts       = _partGetter.GetParts(positives, negatives);
            IEnumerable <Constraint>  constraints = _constraintGetter.GetConstraints(parts, positives, negatives);

            State state = new State(parts, constraints, positives, negatives);


            //Run an initial constraint propagation to reduce the branching factor
            AC_3(false, constraints);


            return(Search(state));
        }
Exemplo n.º 3
0
		public Ptype.Mutable BuildPrototype(IBuildPrototypeArgs args)
		{
			Examples eargs = args.Examples;
			List<Bitmap> positives = eargs.Positives;
			List<Bitmap> negatives = eargs.Negatives;

			Bitmap feature = Utils.CombineBitmapsAndMakeDifferencesTransparent(positives);
			foreach (Bitmap neg in negatives)
			{
				if (Utils.MatchesIgnoringTransparentPixels(feature, neg))
					return null;
			}

			Dictionary<string, Bitmap> dict = new Dictionary<string,Bitmap>();
			dict.Add("part", feature);


			try {
				return new Ptype.Mutable(dict, new Dictionary<String, Region>());
			} catch{
				return null;
			}

		}
Exemplo n.º 4
0
        /// <summary>
        /// Parameterizes a prototype using a branch and bound search algorithm.
        /// </summary>
        /// <param name="positives">Positive example bitmaps</param>
        /// <param name="negatives">Negative example bitmaps</param>
        /// <returns></returns>
        public Ptype.Mutable BuildPrototype(IBuildPrototypeArgs args)
        {
            Examples eargs = args.Examples;
            IEnumerable<Bitmap> positives = eargs.Positives;
            IEnumerable<Bitmap> negatives = eargs.Negatives;

            Dictionary<string, Part> parts = _partGetter.GetParts(positives, negatives);
            IEnumerable<Constraint> constraints = _constraintGetter.GetConstraints(parts, positives, negatives);

            State state = new State(parts, constraints, positives, negatives);


            //Run an initial constraint propagation to reduce the branching factor
            AC_3(false, constraints);


            return Search(state);
        }