I am looking for an algorithm that fills a region with one color, but the edge of the region is not completely closed (i.e. one or more gaps are being left). The result is like the use of the Paint Bucket Tool with Gap Size option in Adobe Flash. We can assume that the input of the algorithm has to specify the largest size (straight line distance) of the gap.
My straightforward idea is (1) to fill the gaps in the edges (as shown in this webpage), and then (2) use the flood fill algorithm to perform the filling on a closed region. I have done (2) by using a recursive algorithm, but how should (1) be done?
Any alternative idea are also welcomed. Thanks!