This is documentation for an old release of SciPy (version 0.7.). Read this page in the documentation of the latest stable release (version 1.15.1).

scipy.ndimage.morphology.generate_binary_structure

scipy.ndimage.morphology.generate_binary_structure(rank, connectivity)

Generate a binary structure for binary morphological operations.

The inputs are the rank of the array to which the structure will be applied and the square of the connectivity of the structure.