Exemplo n.º 1
0
 public static void fill_random(Floatarray v, float lo, float hi)
 {
     for (int i = 0; i < v.Length1d(); i++)
     {
         v.Put1d(i, (float)((hi - lo) * DRandomizer.Default.drand() + lo));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Brushfire transformation using 2-norm.
 /// </summary>
 public static void brushfire_2(ref Floatarray distance, ref Narray <Point> source, float maxdist)
 {
     BrushFire.Go(Metric2.Default, ref distance, ref source, maxdist);
     for (int i = 0; i < distance.Length1d(); i++)
     {
         distance.Put1d(i, (float)Math.Sqrt(distance.At1d(i)));
     }
 }
Exemplo n.º 3
0
        public static void Sparsify(Floatarray a, int n)
        {
            NBest nbest = new NBest(n);

            for (int i = 0; i < a.Length1d(); i++)
            {
                nbest.Add(i, Math.Abs(a.At1d(i)));
            }
            double threshold = nbest.Value(n - 1);

            for (int i = 0; i < a.Length1d(); i++)
            {
                if (Math.Abs(a.At1d(i)) < threshold)
                {
                    a.Put1d(i, 0f);
                }
            }
        }
Exemplo n.º 4
0
        public static void remove_dontcares(ref Intarray image)
        {
            Floatarray     dist   = new Floatarray();
            Narray <Point> source = new Narray <Point>();

            dist.Resize(image.Dim(0), image.Dim(1));
            for (int i = 0; i < dist.Length1d(); i++)
            {
                if (!dontcare(image.At1d(i)))
                {
                    dist.Put1d(i, (image.At1d(i) > 0 ? 1 : 0));
                }
            }
            BrushFire.brushfire_2(ref dist, ref source, 1000000);
            for (int i = 0; i < dist.Length1d(); i++)
            {
                Point p = source.At1d(i);
                if (dontcare(image.At1d(i)))
                {
                    image.Put1d(i, image[p.X, p.Y]);
                }
            }
        }
Exemplo n.º 5
0
 public static void remove_dontcares(ref Intarray image)
 {
     Floatarray dist = new Floatarray();
     Narray<Point> source = new Narray<Point>();
     dist.Resize(image.Dim(0), image.Dim(1));
     for (int i = 0; i < dist.Length1d(); i++)
         if (!dontcare(image.At1d(i))) dist.Put1d(i, (image.At1d(i) > 0 ? 1 : 0));
     BrushFire.brushfire_2(ref dist, ref source, 1000000);
     for (int i = 0; i < dist.Length1d(); i++)
     {
         Point p = source.At1d(i);
         if (dontcare(image.At1d(i))) image.Put1d(i, image[p.X, p.Y]);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Brushfire transformation using 2-norm.
 /// </summary>
 public static void brushfire_2(ref Floatarray distance, ref Narray<Point> source, float maxdist)
 {
     BrushFire.Go(Metric2.Default, ref distance, ref source, maxdist);
     for (int i = 0; i < distance.Length1d(); i++)
         distance.Put1d(i, (float)Math.Sqrt(distance.At1d(i)));
 }
Exemplo n.º 7
0
 public virtual void Output(Floatarray outv, int i)
 {
     outv.Resize(nClasses());
     outv.Fill(limit);
     outv.Put1d(Cls(i), 1 - limit);
 }
Exemplo n.º 8
0
 public virtual void Output(Floatarray outv, int i)
 {
     outv.Resize(nClasses());
     outv.Fill(limit);
     outv.Put1d(Cls(i), 1 - limit);
 }