Note: An algorithm for contour-based region filling
A linear-time algorithm for filling regions defined by closed contours in raster format is proposed. The algorithm relies on a single pass contour labeling and the actual filling is done in a scan-line manner, visiting the interior pixels only once. The interior endpoints of the scan-lines are discovered solely on the basis of the labeled contour. Despite its simplicity and low computation cost, the proposed method fills-in arbitrary shapes correctly, with no obvious exceptions. Possible special cases may arise from the 8-connectivity, inner contour detection. However, in extensive tests on complicated images, the proposed labeling scheme has given correct results.
linear-time algorithm contour labeling raster region filling scan-line method