Skip to content

Thickening

Fact Value
Status Implemented and tested
Family Morphological filters
Engine Browser
Type Nonlinear, spatial, thinning of the complement
Output Mask
Operator shown as algorithm (exact)
Support radius global
Code web/src/core/filters/morphology/binary.ts, thickeningFilter
Operator code web/src/core/filters/morphology/binary.ts, thin
Channels Brightness only, RGB

Overview

Thickening grows white shapes by thinning the black background between them. Since thinning never breaks the background apart, the shapes grow toward each other but never merge.

Two panels: white shapes on black, a bar, an L, a ring, a triangle with a bump and a few specks, and the thickened result, with larger shapes separated by thin black lines. Two panels: white shapes on black, a bar, an L, a ring, a triangle with a bump and a few specks, and the thickened result, with larger shapes separated by thin black lines.
Thickening with 3 iterations grows the shapes by thinning the background, so they grow but do not merge.

How it works

  1. Swap black and white.
  2. Thin the new white areas for the chosen number of iterations.
  3. Swap back.

Mathematical foundation

\[ A \odot = \left(\operatorname{thin}_n(A^c)\right)^c \]

The formula shows the default parameter values.

where

  • \(A^c\): The background
  • \(n\): The number of iterations

Thickening is the dual of thinning: the background is thinned for n iterations and the result is complemented. The background never breaks apart, so shapes never merge.

Thickening is the dual of thinning. Thinning the background removes background pixels next to the shapes, which adds them to the shapes, but never where that would join two shapes.

Kernel or operator

There is no kernel. The Inspector lists the complement, the thinning and the second complement.

Algorithm

  1. Make the image binary and take the complement.
  2. Thin the complement for the chosen number of iterations.
  3. Take the complement again.

Parameters

Parameter Default Values Meaning
Method method Zhang-Suen Zhang-Suen, Guo-Hall The thinning algorithm. Both remove pixels in two sub-iterations per iteration.
Iterations iterations 3 1 to 50 How many thinning iterations run on the background.
Channels channelScope Brightness only RGB, Brightness only Which part of the color image the filter changes.

Implementation

thickeningFilter in web/src/core/filters/morphology/binary.ts thins the complement with thin. Pixels outside the image count as black in the original image, so the background is not peeled from the image edge. It is a global filter, so it always runs on the whole image in one tile, and a selection is cut out of the result. The filter runs in the browser engine through the shared filter framework in web/src/core/filters/run.ts, which handles the channel scope and alpha. Values at or above 128 count as white, and the result is 255 or 0.

Worked example

Row Input Result
0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
2 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1
3 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1
4 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
6 0 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1
7 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0
8 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0

A small binary image, 1 for white and 0 for black. Three iterations of thinning on the black background grow the white shapes. The background between them thins to lines, so the shapes do not merge.

Complexity

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

N is the number of pixels per channel and n the number of iterations.

Artifacts and limitations

Limitations

  • Growth follows the thinning rules, not a round shape.

Artifacts

  • Thin background lines remain between shapes.

Tests

The reference thins the complement, framed by background, with the same references as thinning. The cases cover both methods.

References

  • Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 9, morphological image processing.
  • Zhang, T. Y. and Suen, C. Y. A fast parallel algorithm for thinning digital patterns. Communications of the ACM 27(3), 236 to 239, 1984. DOI 10.1145/357994.358023.