示例#1
0
        protected override MyImageD GetImageDInternal()
        {
            MyImageD imgd   = new MyImageD(imgd_provider.GetImageD());
            var      points = points_provider.GetPoints();

            LogPanel.Log($"[PlotPoints] {points.Count} points.");
            if (points.Count > 0)
            {
                MyImageD cross_img = new MyImageD(new double[imgd.data.Length], imgd);
                double
                    mn = points.Min(p => p.importance),
                    mx = points.Max(p => p.importance);
                foreach (var p in points.Reverse <ImagePoint>())
                {
                    Utils.GetHeatColor((p.importance - mn) / (mx - mn), out double r, out double g, out double b);
                    plot_cross(cross_img, p.x, p.y, r, g, b);
                }
                Parallel.For(0, imgd.height, i =>
                {
                    for (int j = 0; j < imgd.width; j++)
                    {
                        int k            = i * imgd.stride + j * 4;
                        double ratio     = cross_img.data[k + 3];
                        imgd.data[k + 0] = (1 - ratio) * imgd.data[k + 0] + cross_img.data[k + 0];
                        imgd.data[k + 1] = (1 - ratio) * imgd.data[k + 1] + cross_img.data[k + 1];
                        imgd.data[k + 2] = (1 - ratio) * imgd.data[k + 2] + cross_img.data[k + 2];
                    }
                });
            }
            return(imgd);
        }
 protected override List<ImagePoint> GetPointsInternal()
 {
     double[,] data = mat_provider.GetMatrix().data;
     List<ImagePoint>
         points = points_provider.GetPoints(),
         ans = new List<ImagePoint>();
     foreach(var p in points)
     {
         int x0 = (int)p.x, y0 = (int)p.y;
         int xn = Math.Max(0, x0 - 1), yn = Math.Max(0, y0 - 1);
         int xp = Math.Min(data.GetLength(1) - 1, x0 + 1), yp = Math.Min(data.GetLength(0) - 1, y0 + 1);
         double
             fnn = data[yn, xn],
             fn0 = data[y0, xn],
             fnp = data[yp, xn],
             f0n = data[yn, x0],
             f00 = data[y0, x0],
             f0p = data[yp, x0],
             fpn = data[yn, xp],
             fp0 = data[y0, xp],
             fpp = data[yp, xp];
         double
             dfx = (fp0 - fn0) / 2,
             dfy = (f0p - f0n) / 2,
             dfxx = fp0 - 2 * f00 + fn0,
             dfyy = f0p - 2 * f00 + f0n,
             dfxy = (fnn - fnp - fpn + fpp) / 4;
         // -[[dfxx,dfxy],[dfxy,dfyy]]^-1[[dfx],[dfy]]
         double det = dfxx * dfyy - dfxy * dfxy;
         // -1/det[[dfyy,-dfxy],[-dfxy,dfxx]][[dfx],[dfy]]
         double
             dx = -(dfyy * dfx + (-dfxy) * dfy) / det,
             dy = -((-dfxy) * dfx + dfxx * dfy) / det;
         //if (Math.Sqrt(dx * dx + dy * dy) < 0.5) dx = dy = 0;
         double x = x0 + dx, y = y0 + dy;
         ans.Add(new ImagePoint(x, y, p.importance + dx * dfx + dy * dfy + 0.5 * (dx * dx * dfxx + 2 * dx * dy * dfxy + dy * dy * dfyy)));
     }
     return ans;
 }
        protected override List <ImagePoint> GetPointsInternal()
        {
            List <ImagePoint> ps = provider.GetPoints();

            if (ps.Count == 0)
            {
                return(ps);
            }
            double l = 0, r = Math.Sqrt(Math.Pow(ps.Max(p => p.x), 2) + Math.Pow(ps.Max(p => p.y), 2));

            while (r - l > 1e-9)
            {
                double mid = (l + r) / 2;
                if (eliminate_with_radius(ps, mid).Count > max_points_to_keep)
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }
            return(eliminate_with_radius(ps, r)); // guaranteed that the count <= max_points_to_keep
        }
示例#4
0
 protected override List <ImagePoint> GetPointsInternal()
 {
     return(points_provider.GetPoints());
 }