In image processing, pixel connectivity is the way in which pixels in 2-dimensional (or hypervoxels in n-dimensional) images relate to their neighbors.
Formulation
In order to specify a set of connectivities, the dimension N and the width of the neighborhood n, must be specified. The dimension of a neighborhood is valid for any dimension n ≥ 1 {\displaystyle n\geq 1} . A common width is 3, which means along each dimension, the central cell will be adjacent to 1 cell on either side for all dimensions. Let M N n {\displaystyle M_{N}^{n}} represent a N-dimensional hypercubic neighborhood with size on each dimension of n = 2 k + 1 , k ∈ Z {\displaystyle n=2k+1,k\in \mathbb {Z} }
Let q → {\displaystyle {\vec {q}}} represent a discrete vector in the first orthant from the center structuring element to a point on the boundary of M N n {\displaystyle M_{N}^{n}} . This implies that each element q i ∈ { 0 , 1 , . . . , k } , ∀ i ∈ { 1 , 2 , . . . , N } {\displaystyle q_{i}\in \{0,1,...,k\},\forall i\in \{1,2,...,N\}} and that at least one component q i = k {\displaystyle q_{i}=k}
Let S N d {\displaystyle S_{N}^{d}} represent a N-dimensional hypersphere with radius of d = ‖ q → ‖ {\displaystyle d=\left\Vert {\vec {q}}\right\Vert } . Define the amount of elements on the hypersphere S N d {\displaystyle S_{N}^{d}} within the neighborhood M N n {\displaystyle M_{N}^{n}} as E. For a given q → {\displaystyle {\vec {q}}} , E will be equal to the amount of permutations of q → {\displaystyle {\vec {q}}} multiplied by the number of orthants. Let n j {\displaystyle n_{j}} represent the amount of elements in vector q → {\displaystyle {\vec {q}}} which take the value j. n j = ∑ i = 1 N ( q i = j ) {\displaystyle n_{j}=\sum _{i=1}^{N}(q_{i}=j)}
The total number of permutation of q → {\displaystyle {\vec {q}}} can be represented by a multinomial as N ! ∏ j = 0 k n j ! {\displaystyle {\frac {N!}{\prod _{j=0}^{k}n_{j}!}}}
If any q i = 0 {\displaystyle q_{i}=0} , then the vector q → {\displaystyle {\vec {q}}} is shared in common between orthants. Because of this, the multiplying factor on the permutation must be adjusted from 2 N {\displaystyle 2^{N}} to be 2 N − n 0 {\displaystyle 2^{N-n_{0}}}
Multiplying the number of amount of permutations by the adjusted amount of orthants yields,
… excerpt ends here. Continue reading the full article.


