Closest point to a given point

前端 未结 8 2491
终归单人心
终归单人心 2020-11-30 03:22

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

8条回答
  •  误落风尘
    2020-11-30 03:38

    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.

提交回复
热议问题