how to generate heat maps given the points

前端 未结 8 1687
猫巷女王i
猫巷女王i 2021-02-06 07:59

I want to generate a heat map in windows form. I have a set of points as the input. How to go about doing this in the simplest way? Thanks.

相关标签:
8条回答
  • 2021-02-06 08:52

    Divide the surface up into a grid of cells, and count the points inside each cell.

    Given the count of points, calculate a color for each cell

    0 讨论(0)
  • 2021-02-06 08:57

    This worked well for me.

    public Color HeatMap(float value, float max)
        {
            int r, g, b;
            float val = value / max; // Assuming that range starts from 0
            if (val > 1)
                val = 1;
            if (val > 0.5f)
            {
                val = (val - 0.5f) * 2;
                r = Convert.ToByte(255 * val);
                g = Convert.ToByte(255 * (1 - val));
                b = 0;
            }
            else
            {
                val = val * 2;
                r = 0;
                g = Convert.ToByte(255 * val);
                b = Convert.ToByte(255 * (1 - val));
            }
            return Color.FromArgb(255, r, g, b);
        }
    
    0 讨论(0)
提交回复
热议问题