I have a raster image with a number of arbitrary shapes (blobs). I am interested to find, for every blob, its immediate neighbors, i.e. those that are visible from it in a straight line. The search can stop after a few neighbors (say 3) have been found, by decreasing closeness.
I imagine that a growing process around every shape (i.e. constructing offset curves of the boundary with increasing offset size) could work, excluding shadow areas created by the obstacles.
I allow myself a computing budget proportional to the image size (number of pixels), not more. So the above procedure will probably not achieve that goal, as the shapes will have "zones of influence" that overlap each other, and the total workload risks to be proportional to the number of shapes as well.
I am looking for suggestions on ways to reduce the processing time. Vectorizing the scene and working with discrete segments is allowed. Approximate solutions are allowed. In particular exact distance computation is not required. The exact visible area on the neighbors is not required, only mutual visibility matters.