I am detecting a shape with roughly known orientation (obtained by using Hough line transform) in thresholded binary image by convolving the image with line with that orientation, and counting the ratio of pixels which match; this line is swept across the image, and lines which have hit ratio higher than some threshold (like 0.9) are considered belonging to the object completely.
The motivation is not only to remove holes but also discontinuities across the object; how a hole is removed is shown in the image, where grey line parts are not-matching and red are matching; blue lines are from Hough transform:
This routine was found by intuition and I wonder whether there is some name for it, or perhaps a more sophisticated algorithm based on similar idea. In that case I could use an optimized implementation instead of the hand-written code (I am using python, OpenCV and scikit-image).