I've difficulties in looking for an answer by myself because I don't know the jargon. I need somebody who'll points me in the right direction.

Assume I have 100000 points with coordinates in the unit square, so points like (0.55313, 0.236831).

I want to create a B/W picture with a given side in pixels (say 1000 x 1000) which shows these points.

The naive approach is to multiply by the side the coordinates and round, so point (0.55313, 0.236831) becomes pixel (553, 237) and to turn pixel (553,237) on.

This is rather unsatisfactory. If the points are many, say millions, I could easily fill all the area with a black blob that gives me 0 information.

So, what I thought was to have an array 1000x1000 of floating point numbers that I can update somehow when I add a point, and at the end I can normalize the values and obtain a grayscale image, which will be "blacker" where more points are.

Now the question: which algorithms are used to add a "blurred" point? I.e., I would like to take into account the real coordinates, so that, if a point is near the border of a "pixel" I would like its addition to my array to "smudge" a little the nearby pixels. Like when you draw a point in a drawing program and it actually adds a little disk with decreasing (linear? Gaussian?) intensity.

Surely it is a problem that has been already been studied and solved, just I don't know how it is called...



1 Answer 1


Instead of having a binary on/off per pixel you can instead make a heat map. The more points fall within the pixel the brighter the pixel is. Essentially create a 2D histogram which you then renormalize to get the grayscale for the output.

If you want to blur the points then you can move a portion of the brightness to the next pixel based on the remaining fraction after multiplying to the resolution. If it the coordinate is (0.55313, 0.236831) and your resolution is 1000x1000 then 0.87*0.17 goes to 553, 236, 0.87*0.83 goes to 553, 237, 0.13*0.17 goes to 554, 236 and 0.13*0.83 goes to 554, 237. This is distributed linearly but there are other options.

  • $\begingroup$ Thanks, this kind of method for fractionally distributing brightness among pixels is what I was looking for. Has this technique a name? I thought to add brightness to pixels based on the distance between their center and the point coordinates (up to a certain threshold) but this is simpler. $\endgroup$ Feb 16, 2017 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.