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.
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
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);
}