Flood Fill
Flood fill [Heckbert00; Shaw04; Vandevenne04] is an extremely useful function that is
often used to mark or isolate portions of an image for further processing or analysis. Flood
fill can also be used to derive, from an input image, masks that can be used for subsequent routines to speed or restrict processing
to only those pixels indicated by the mask. The function cvFloodFill()
itself takes an optional mask that can be further used to control
where filling is done (e.g., when doing multiple fills of the same image).
In OpenCV, flood fill is a more general version of the sort of fill functionality which
you probably already associate with typical computer painting programs. For both, a
seed point is selected from an image and then all
similar neighboring points are colored with a uniform color. The difference here is that the
neighboring pixels need not all be identical in color.[55] The result of a flood fill operation will always be a single contiguous region. The cvFloodFill()
function will color a neighboring pixel if it is
within a specified range (lo Diff
to up Diff
) of either the current pixel or if (depending on the
settings of flags
) the neighboring pixel is within a
specified range of the original seedPoint
value. Flood
filling can also be constrained by an optional mask argument. The prototype for the flood
fill routine is:
Figure 5-15. Results of the morphological ...
Get Learning OpenCV now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.