Fills a connected component with the given color.
The functions floodFill
fill a connected component starting from
the seed point with the specified color. The connectivity is determined by
the color/brightness closeness of the neighbor pixels. The pixel at
(x,y) is considered to belong to the repainted domain if:
in case of a grayscale image and floating range
- src(seedPoint.x, seedPoint.y)- loDiff
in case of a grayscale image and fixed range
src(x',y')_g- loDiff _g
and
src(x',y')_b- loDiff _b
in case of a color image and floating range
- src(seedPoint.x, seedPoint.y)_r- loDiff _r
src(seedPoint.x, seedPoint.y)_g- loDiff _g
and
src(seedPoint.x, seedPoint.y)_b- loDiff _b
in case of a color image and fixed range
where src(x',y') is the value of one of pixel neighbors that is
already known to belong to the component. That is, to be added to the
connected component, a color/brightness of the pixel should be close enough
to:
- Color/brightness of one of its neighbors that already belong to the
connected component in case of a floating range.
- Color/brightness of the seed point in case of a fixed range.
Use these functions to either mark a connected component with the specified
color in-place, or build a mask and then extract the contour, or copy the
region to another image, and so on.
Note:
- An example using the FloodFill technique can be found at
opencv_source_code/samples/cpp/ffilldemo.cpp
- (Python) An example using the FloodFill technique can be found at
opencv_source_code/samples/python2/floodfill.cpp