Algorithm for Filling Regions with Small Gaps
This is clossing operator implemented as dilate-then-erode filter and then it is FloodFill.
Dilate filter is adding pixels that would became new hull.
Erode filter is cutting out pixels that are at the hull.
Here is try me link: Demo of operators
One thing that could be improved in this technique are gaps after filter.

You can get rid of it by applying dilation on color region.

This is one kind of solving, another would be to go along the edge and find pattern edge-gap-edge with given radius.
There are also caveats - if edge is not in single color, then operators must include that information or get binary representation (with binary data, e.g. 0 means empty, 1 means edge).
Clossing operator is easy to implement but slower than contour tracing.
You could trace edge by FloodFill starting from edge region, using BFS and going into counting mode after boundary is crossed, to check within gap radius.