Region filling

Share:

Description

Fill regions in images.

Usage

1
floodFill(x, pt, col, tolerance=0)

Arguments

x

An Image object or an array.

pt

Coordinates of the start filling point.

col

Fill color. This argument should be a numeric for Grayscale images and an R color for Color images.

tolerance

Color tolerance used during the fill.

Details

Flood fill is performed using the fast scan line algorithm. Filling starts at pt and grows in connected areas where the absolute difference of the pixels intensities (or colors) remains below tolerance.

Value

An Image object or an array, containing the transformed version of x.

Author(s)

Gregoire Pau, Oleg Sklyar; 2007

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  x = readImage(system.file("images", "shapes.png", package="EBImage"))
  y = floodFill(x, c(67, 146), 0.5)
  display(y)

  y = channel(y, 'rgb')
  y = floodFill(y, c(48, 78), 'red')
  y = floodFill(y, c(156, 52), 'orange')	
  display(y)

  x = readImage(system.file("images", "sample.png", package="EBImage"))
  y = floodFill(x, c(226, 121), 1, tolerance=0.1)
  display(y)