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)); } }
/// <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))); } }
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); } } }
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]); } } }
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]); } }
/// <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))); }
public virtual void Output(Floatarray outv, int i) { outv.Resize(nClasses()); outv.Fill(limit); outv.Put1d(Cls(i), 1 - limit); }
public virtual void Output(Floatarray outv, int i) { outv.Resize(nClasses()); outv.Fill(limit); outv.Put1d(Cls(i), 1 - limit); }