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
Put the points in a KD tree, after this it's very fast to find the nearest neighbor. See this article on wikipedia for details.