I have a set K of randomly selected pixels in a 2D image. For every other pixel in the image I need to find out which pixel in set K is closest to it (using the standard sqr
what you are trying to do is construct a voronoi diagram this can be done in O(n log n) using a plane sweep
Depending on how densely this graphic is filled with pixels, you might be better off just searching outward from your pixel of origin.
I programmed something like this for a graphic terminal emulation. What I ended up doing was programming a search pattern in the shape of a square-sided spiral that grew out from the center point, and I let it grow until it hit something. That was sufficiently fast for the purpose, even on an old CPU.