FUNCTION REFERENCE

imfill

Fill image regions and holes.

Fill image regions and holes.

Syntax

BW2 = imfill(BW, 'holes')

Syntax

BW2 = imfill(BW, conn, 'holes')

Syntax

BW2 = imfill(BW, locations)

Syntax

BW2 = imfill(BW, locations, conn)

Syntax

I2 = imfill(I)

Syntax

I2 = imfill(I, conn)

'holes' sets every background pixel that cannot be reached from the image border through background pixels (conn 4, the default, or 8). locations (linear indices, or a p-by-2 matrix of row and column subscripts) start a flood fill of the background region around each seed; a seed on a foreground pixel changes nothing. For a non-logical image without 'holes', grey holes are filled: each pixel becomes the smallest, over all paths to the border, of the largest value on the path (morphological reconstruction by erosion). Results keep the class of the input.

Example

imfill(logical([1 1 1; 1 0 1; 1 1 1]), 'holes')   % true(3)

Example

imfill(logical([0 0 0; 0 1 0; 0 0 0]), 1)   % true(3)

Example

imfill(uint8([5 5 5; 5 1 5; 5 5 5]))   % uint8(5*ones(3))

Differences from MATLAB: no interactive form; a binary image without 'holes' or locations is an error. 2-D only.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.