When the number is high the pixel grid of the input image becomes visible, do you think there's anything that could be done to avoid that? Other than resorting to a (probably heavyweight) higher resolution for the PNG
To be complete here's an earlier version of this code, where I used the grayscale density of the image to project (instead of the black and white I'm using now).
I removed it because it made the code more complex to read and reason about, but I'll probably get back to it later since it's much better in terms of "features".
https://observablehq.com/@fil/transport-to-grayscale