Пример #1
0
        void add_good_ori_features(ref List<Feature> features, double[] hist, int n,
                           double mag_thr, Feature feat)
        {
            Feature new_feat;
            double bin, PI2 = Math.PI * 2.0;
            int l, r, i;

            for (i = 0; i < n; i++)
            {
                l = (i == 0) ? n - 1 : i - 1;
                r = (i + 1) % n;

                if (hist[i] > hist[l] && hist[i] > hist[r] && hist[i] >= mag_thr)
                {
                    bin = i + interp_hist_peak(hist[l], hist[i], hist[r]);
                    bin = (bin < 0) ? n + bin : (bin >= n) ? bin - n : bin;
                    new_feat = (Feature)feat.Clone();
                    new_feat.ori = ((PI2 * bin) / n) - Math.PI;
                    features.Add(new_feat);
                    //free( new_feat );
                }
            }
        }
Пример #2
0
        void normalize_descr(Feature feat)
        {
            double cur, len_inv, len_sq = 0.0;
            int i, d = feat.d;

            for (i = 0; i < d; i++)
            {
                cur = feat.descr[i];
                len_sq += cur * cur;
            }
            len_inv = 1.0 / Math.Sqrt(len_sq);
            for (i = 0; i < d; i++)
                feat.descr[i] *= len_inv;
        }
Пример #3
0
        void hist_to_descr(float[, ,] hist, int d, int n, ref Feature feat)
        {
            int int_val, i, r, c, o, k = 0;
            feat.descr = new double[d * d * n];

            for (r = 0; r < d; r++)
                for (c = 0; c < d; c++)
                    for (o = 0; o < n; o++)
                        feat.descr[k++] = hist[r, c, o];

            feat.d = k;
            normalize_descr(feat);
            for (i = 0; i < k; i++)
                if (feat.descr[i] > SIFT_DESCR_MAG_THR)
                    feat.descr[i] = SIFT_DESCR_MAG_THR;
            normalize_descr(feat);

            /* convert floating-point descriptor to integer valued descriptor */
            for (i = 0; i < k; i++)
            {
                int_val = (int)(SIFT_INT_DESCR_FCTR * feat.descr[i]);
                feat.descr[i] = Math.Min(255, int_val);
            }
        }
Пример #4
0
        Feature new_feature()
        {
            Feature feat = new Feature();
            detection_data ddata = new detection_data();

            feat.feature_data = ddata;
            feat.type = feature_type.FEATURE_LOWE;

            return feat;
        }
Пример #5
0
 public object Clone()
 {
     Feature feat = new Feature();
     feat.a = a;
     feat.b = b;
     feat.bck_match = bck_match;
     feat.c = c;
     feat.category = category;
     feat.d = d;
     feat.descr = (double[])descr.Clone();
     feat.feature_data = (detection_data)feature_data.Clone();
     feat.fwd_match = fwd_match;
     feat.img_pt = img_pt;
     feat.mdl_match = mdl_match;
     feat.mdl_pt = mdl_pt;
     feat.ori = ori;
     feat.scl = scl;
     feat.type = type;
     feat.x = x;
     feat.y = y;
     return feat;
 }