DIPlib Documentation - ©1995-2013 Quantitative Imaging Group, Delft University of Technology.

# The connectivity parameter

DIPlib uses a different name for the various possible connectivites than you might be used to. This is to generalize this parameter to images of any dimensionality. It is defined as follows: if `connectivity` is 1 all pixels for which only one coordinate differs from the pixel's coordinates by maximally 1 are considered neighbours; if it is 2, all pixels for which one or two coordinates differ maximally 1 are considered neighbours. The connectivity can never be larger than the image dimensionality.

In terms of the obsolete connectivity definitions we have:

In 2-D | this connectivity | corresponds to | and forms this structuring element
| 1 | 4 connectivity | diamond
| 2 | 8 connectivity | square
| -1 | 4-8 connectivity | octagon
| -2 | 8-4 connectivity | octagon
In 3-D | this connectivity | corresponds to | and forms this structuring element
| 1 | 6 connectivity | octahedron
| 2 | 18 connectivity | cuboctahedron
| 3 | 26 connectivity | cube
| -1 | 6-26 connectivity | small rhombicuboctahedron
| -3 | 26-6 connectivity | small rhombicuboctahedron

The negative connectivities are only defined for the functions in binary morphology such as `BinaryDilation` and `BinaryErosion`. These alternate steps with different connectivity to produce a better approximation to an isotropic structuring element.