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
Another hint: The distance is always greater than or equal to each coordinate difference, and always less than or equal to their sum, i.e.
d >= dx, d >= dy, d <= dx + dy.
This might help you doing the sorting more efficiently.