Skip to content

Region growing

Fact Value
Also called Seeded region growing, Flood fill segmentation
Status Implemented and tested
Family Segmentation and regions
Engine Browser
Type Nonlinear, spatial, connected flood from a seed
Output Mask
Operator shown as algorithm (exact)
Support radius global
Code web/src/core/filters/segmentation/regions.ts, regionGrowingFilter
Operator code web/src/core/filters/segmentation/regions.ts, growRegion

Overview

Region growing starts from one pixel, the seed, and spreads to the neighbors that look like it. It stops where the image becomes too different from the seed. The result is a mask of one connected area, such as an object or a background.

Four panels: noisy gray disks on a dark background, then the region grown from the largest disk with three tolerances: a disk full of holes, the whole disk, and a large area that has leaked into the background. Four panels: noisy gray disks on a dark background, then the region grown from the largest disk with three tolerances: a disk full of holes, the whole disk, and a large area that has leaked into the background.
Noisy disks, and the region grown from a seed in the largest disk with tolerances 20, 80 and 200.

How it works

  1. Find the seed pixel from its position.
  2. Mark every pixel whose value is within the tolerance of the seed's value.
  3. Keep only the marked pixels that connect to the seed through marked pixels.

Mathematical foundation

\[ R = \text{the pixels } p \text{ connected to } s \text{ through pixels with } |Y(p) - Y(s)| \le T, \qquad T = 20 \]

The formula shows the default parameter values.

where

  • \(s\): The seed pixel
  • \(Y\): The brightness
  • \(T\): The tolerance

s is the seed pixel and Y the brightness. A pixel joins the region when it matches the seed and a path of matching pixels joins it to the seed. Each step of the path goes to one of the 4 or 8 neighbors. This is how skimage.segmentation.flood grows a region. It is also the region growing with a fixed seed value that Gonzalez and Woods describe. With the color measure, the test is the largest of the three channel differences. The seed is at a percent of the width and height, rounded down to a pixel, so it stays on the same spot when the image is resized.

The tolerance trades holes against leaks. A pixel inside the object is left out when noise moves it more than the tolerance from the seed. A pixel outside joins when the tolerance reaches across the step between object and background. A good tolerance is larger than the noise and smaller than that step.

Kernel or operator

The Inspector shows the seed, the match test and the growth rule with the current settings.

Algorithm

  1. Find the seed pixel from its position in percent.
  2. Mark every pixel that matches the seed within the tolerance.
  3. Keep only the marked pixels connected to the seed, and make them white.

Parameters

Parameter Default Values Meaning
Seed x seedX 50 0 to 100 % The seed's position across the image, in percent of the width.
Seed y seedY 50 0 to 100 % The seed's position down the image, in percent of the height.
Tolerance tolerance 20 0 to 255 How far a pixel's value may be from the seed's and still join the region.
Compare by measure Brightness Brightness, Color Compare the brightness of the pixels, or their red, green and blue values.
Neighbors connectivity 8 (sides and corners) 8 (sides and corners), 4 (sides only) Which neighbors the region grows into.

Implementation

regionGrowingFilter in web/src/core/filters/segmentation/regions.ts marks the matching pixels and keeps the component of the seed with labelComponents.

Worked example

Tolerance Region area (pixels)
20 1213
40 1550
80 1567
120 1595
160 1634
200 5286

The test disks with Gaussian noise of sigma 12 (seed 7), 160 by 160 pixels, and the seed at 25 % of the width and 62.5 % of the height, the center of the largest disk. Brightness and 8 neighbors are the defaults. A small tolerance leaves noisy pixels out, so the region has holes. Once the tolerance covers the noise, the region is the disk, about 1590 pixels. The disk is 220 and the background 30, so when the tolerance nears that gap of 190, noisy background pixels start to match, and the region leaks into the background.

Complexity

  • Time: \(O(N)\)
  • Memory: \(O(N)\)

N is the number of pixels.

Artifacts and limitations

Limitations

  • Compares with the seed only, so slow changes of brightness across an area can stop it early.
  • A single noisy seed pixel can give a poor region. Smooth the image first.

Artifacts

  • Holes where noise pushes pixels past the tolerance.
  • Leaks through thin gaps in a boundary.

Tests

The fixture cases compare every pixel with skimage.segmentation.flood on the brightness, with 4 and 8 neighbors. For the color measure, they use the same flood on the largest channel difference. No brightness lies on the tolerance, so rounding cannot move a pixel across it. Unit tests check the seed position and that a matching area not connected to the seed stays out.

References