Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Fill image regions and holes

`BW2 = imfill(BW,locations)`

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

`I2 = imfill(I)`

`BW2 = imfill(BW)`

`BW2 = imfill(BW,0,conn)`

`[BW2, locations_out] = imfill(BW)`

`BW2 = imfill(BW,locations,conn)`

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

`I2 = imfill(I,conn)`

`gpuarrayB = imfill(gpuarrayA,___)`

performs a flood-fill operation on background pixels of the input binary
image `BW2`

= imfill(`BW`

,`locations`

)`BW`

, starting from the points specified in
`locations`

. If `locations`

is a
*p*-by-1 vector, it contains the linear indices of
the starting locations. If `locations`

is a
*p*-by-`ndims(BW)`

matrix, each row
contains the array indices of one of the starting locations.

displays
the binary image `BW2`

= imfill(`BW`

)`BW`

on the screen and lets you
define the region to fill by selecting points interactively with the
mouse. To use this syntax, `BW`

must be a 2-D image.
Press **Backspace** or **Delete** to
remove the previously selected point. Shift-click, right-click, or
double-click to select a final point and start the fill operation.
Press **Return** to finish the selection without
adding a point.

`[`

returns the locations of points selected interactively in
`BW2`

, `locations_out`

] = imfill(`BW`

)`locations_out`

. The return value
`locations_out`

is a vector of linear indices into
the input image. To use this syntax, `BW`

must be a 2-D
image.

`imfill`

uses an algorithm based on morphological
reconstruction [1].

[1] Soille, P., *Morphological Image
Analysis: Principles and Applications*, Springer-Verlag,
1999, pp. 173-174.

Was this topic helpful?