Exemplo n.º 1
0
 private void delete(Feature.FType type, List<int> indicies)
 {
     for (int j = indicies.Count() - 1; j >= 0; j--) {
         features[type].RemoveAt(indicies[j]);
     }
 }
Exemplo n.º 2
0
        internal void Recombine(Feature.FType type1 = Feature.FType.unknown, Feature.FType type2 = Feature.FType.unknown)
        {
            int featuresTypeCount = recombine.Count();
            if (featuresTypeCount == 0) return;
            int type1Count = 0, type2Count = 0;
            if (type1 == Feature.FType.unknown) {
                type1 = getRandomType();
            }
            if (!recombine.ContainsKey(type1) && !recombine.ContainsKey(type2)) {
                return;
            }
            type1Count = recombine[type1].Count();

            if (type2 == Feature.FType.unknown) {
                type2 = getRandomType();
            }
            type2Count = recombine[type2].Count();

            int idx1 = recombine[type1][rand.Next(type1Count - 1)];
            int idx2 = recombine[type2][rand.Next(type2Count - 1)];
            addFeature(featureType, type1, idx1, type2, idx2);
            idx1 = recombine[type1][rand.Next(type1Count - 1)];
            idx2 = recombine[type2][rand.Next(type2Count - 1)];
            addFeature(featureType2, type1, idx1, type2, idx2);
        }
Exemplo n.º 3
0
 private void addFeature(string fType, Feature.FType type1, int idx1, Feature.FType type2, int idx2)
 {
     if (fType == null) {
         return;
     }
     var f1 = features[type1][idx1];
     var f2 = features[type2][idx2];
     var l1 = f1.Projection.GetPoint();
     var l2 = f2.Projection.GetPoint();
     Feature newFeature;
     var newType = (Feature.FType)Enum.Parse(typeof(Feature.FType), fType);
     switch (newType) {
         case Feature.FType.PixelProjection:
             newFeature = new Feature() {
                 Projection = new PixelProjection(new List<IntPoint>() { l2.Value }) {
                     Ref = f1.Projection,
                     Ref2 = f2.Projection,
                     GaussianDist = gaussian
                 },
                 FeatureType = Feature.FType.PixelProjection
             };
             break;
         case Feature.FType.PixelProjectionVarLength:
             List<Feature> refs = new List<Feature>();
             refs.Add(f1);
             refs.Add(f2);
             newFeature = new Feature() {
                 Projection = new PixelProjectionVarLength(new List<IntPoint>() { l2.Value }) {
                     Ref = f1.Projection,
                     Features = refs,
                     GaussianDist = gaussian
                 },
                 FeatureType = Feature.FType.PixelProjection
             };
             break;
         case Feature.FType.PixelDiff:
             newFeature = new Feature() {
                 Projection = new PixelDiff(l2.Value, f1.Projection),
                 FeatureType = Feature.FType.PixelDiff
             };
             break;
         case Feature.FType.SymmetricalPixelDiff:
             newFeature = new Feature() {
                 Projection = new SymmetricalPixelDiff() { Ref = f1.Projection, Ref2 = f2.Projection },
                 FeatureType = Feature.FType.SymmetricalPixelDiff
             };
             break;
         case Feature.FType.PixelSum:
             newFeature = new Feature() {
                 Projection = new PixelSum(l2.Value) { Ref = f1.Projection },
                 FeatureType = Feature.FType.PixelSum
             };
             break;
         case Feature.FType.PixelQuot:
             newFeature = new Feature() {
                 Projection = new PixelQuot(l2.Value, f1.Projection),
                 FeatureType = Feature.FType.PixelQuot
             };
             break;
         case Feature.FType.SymmetricalPixelQuot:
             newFeature = new Feature() {
                 Projection = new SymmetricalPixelQuot() { Ref = f1.Projection, Ref2 = f2.Projection },
                 FeatureType = Feature.FType.SymmetricalPixelQuot
             };
             break;
         case Feature.FType.PixelProd:
             newFeature = new Feature() {
                 Projection = new PixelProd(l2.Value) { Ref = f1.Projection },
                 FeatureType = Feature.FType.PixelProd
             };
             break;
         case Feature.FType.SymmetricalPixelSum:
             newFeature = new Feature() {
                 Projection = new SymmetricalPixelSum() { Ref = f1.Projection, Ref2 = f2.Projection },
                 FeatureType = Feature.FType.SymmetricalPixelSum
             };
             break;
         default:
             throw new Exception("unknown feature type");
     }
     if (!this.features.ContainsKey(newType)) {
         this.features[newType] = new List<Feature>();
     }
     features[newType].Add(newFeature);
 }
Exemplo n.º 4
0
        private void addFeature(string fType, int idx1 ,int idx2)
        {
            if (fType == null) {
                return;
            }
            var f1 = features[idx1];
            var f2 = features[idx2];
            var l1 = f1.Projection.GetPoint();
            var l2 = f2.Projection.GetPoint();
            Feature newFeature;
            switch (fType) {
                case "PixelProjection":
                    newFeature = new Feature() {
                        Projection = new PixelProjection(new List<IntPoint>() { l2.Value }) {
                            Ref = f1.Projection, Ref2 = f2.Projection,
                        },
                        FeatureType = Feature.FType.PixelProjection
                    };
                    break;
                case "PixelDiff":
                    if (f1.FeatureType != Feature.FType.PixelEval) return;
                    newFeature = new Feature() {
                        Projection = new PixelDiff(l2.Value, f1.Projection),
                        FeatureType = Feature.FType.PixelDiff
                    };
                    break;
                case "SymmetricalPixelDiff":
                    newFeature = new Feature() {
                        Projection = new SymmetricalPixelDiff() { Ref = f1.Projection, Ref2 = f2.Projection },
                        FeatureType = Feature.FType.SymmetricalPixelDiff
                    };
                    break;
                case "PixelSum":
                    newFeature = new Feature() {
                        Projection = new PixelSum(l2.Value) { Ref = f1.Projection },
                        FeatureType = Feature.FType.PixelSum
                    };
                    break;
                case "PixelQuot":
                    if (f1.FeatureType != Feature.FType.PixelEval) return;
                    newFeature = new Feature() {
                        Projection = new PixelQuot(l2.Value, f1.Projection),
                        FeatureType = Feature.FType.PixelQuot
                    };
                    break;
                case "SymmetricalPixelQuot":
                    newFeature = new Feature() {
                        Projection = new SymmetricalPixelQuot() {  Ref = f1.Projection, Ref2 = f2.Projection },
                        FeatureType =  Feature.FType.SymmetricalPixelQuot
                    };
                    break;
                case "PixelProd":
                    newFeature = new Feature() {
                        Projection = new PixelProd(l2.Value) { Ref = f1.Projection },
                        FeatureType = Feature.FType.PixelProd
                    };
                    break;
                case "SymmetricalPixelSum":
                    newFeature = new Feature() {
                        Projection = new SymmetricalPixelSum() { Ref = f1.Projection, Ref2 = f2.Projection },
                        FeatureType = Feature.FType.SymmetricalPixelSum
                    };
                    break;
                default:
                    throw new Exception("unknown feature type");
            }

            features.Add(newFeature);
        }