Finding closest non-black pixel in an image fast

前端 未结 9 1804
青春惊慌失措
青春惊慌失措 2020-12-16 21:22

I have a 2D image randomly and sparsely scattered with pixels.
given a point on the image, I need to find the distance to the closest pixel that is not in the background

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 22:09

    Search "Nearest neighbor search", first two links in Google should help you.

    If you are only doing this for 1 pixel per image, I think your best bet is just a linear search, 1 pixel width box at time outwards. You can't take the first point you find, if your search box is square. You have to be careful

提交回复
热议问题