There is no single way of mapping a random set of samples to a regular grid (which may be displayed as a greyscale graphic) - it really depends on the nature of your data and what you want to do with the end result.
There's a good overview here which describes the common techniques used in GIS applications. The easiest one to implement is "Inverse Distance Weighted" where you calculate the height at each grid point as a weighted sum of the closest sample points. The other techniques like "kriging" give better results, but are much more involved.