MATLAB File Help: cv.floodFill Index
cv.floodFill

Fills a connected component with the given color

dst = cv.floodFill(src, seed, newVal)
[dst, rect, area] = cv.floodFill(src, seed, newVal)
[dst, rect, area, mask] = cv.floodFill(..., 'Mask',mask, 'MaskOnly',true)
[...] = cv.floodFill(..., 'OptionName',optionValue, ...)

Input

Output

Options

The function cv.floodFill fills 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:

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:

Use this function to either mark a connected component with the specified color, or build a mask and then extract the contour, or copy the region to another image, and so on.

Note: Since the mask is larger than the filled image, a pixel (x,y) in image corresponds to the pixel (x+1,y+1) in the mask.

See also