skimage2.morphology.footprint_rectangle#

skimage2.morphology.footprint_rectangle(shape, *, dtype=<class 'numpy.uint8'>)[source]#

Generate a (hyper-)rectangular footprint.

This is a convenience wrapper around numpy.ones(). Depending on the requested shape, it generates a square, rectangle, cube, cuboid, or even higher-dimensional version of these shapes.

Parameters:
shapetuple[int, …]

The length of the footprint in each dimension. The length of the sequence determines the number of dimensions of the footprint.

dtypedtype-like, optional

The data type of the footprint.

Returns:
footprintarray

A footprint consisting only of ones, i.e. every pixel belongs to the neighborhood.

See also

numpy.ones

Upstream version of this function.

footprint_rectangle_decomposed

Alternate version that creates a decomposed footprint.

Examples

>>> import _skimage2 as ski2
>>> ski2.morphology.footprint_rectangle((3, 5))
array([[1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1]], dtype=uint8)

Generate a 5-dimensional hypercube with 3 samples in each dimension

>>> ski2.morphology.footprint_rectangle((3,) * 5).shape
(3, 3, 3, 3, 3)