bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / morphology / footprints / rectangle
function
skimage.morphology.footprints:rectangle
source: /dev/scikit-image/src/skimage/morphology/footprints.py :256
Signature
def rectangle ( nrows , ncols , dtype = <class 'numpy.uint8'> , * , decomposition = None ) Summary
Generates a flat, rectangular-shaped footprint.
Extended Summary
Every pixel in the rectangle generated for a given width and given height belongs to the neighborhood.
Parameters
nrows: intThe number of rows of the rectangle.
ncols: intThe number of columns of the rectangle.
Returns
footprint: ndarray or tupleA footprint consisting only of ones, i.e. every pixel belongs to the neighborhood. When
decompositionis None, this is just a numpy.ndarray. Otherwise, this will be a tuple whose length is equal to the number of unique structuring elements to apply (see Notes for more detail)
Other Parameters
dtype: dtype-like, optionalThe data type of the footprint.
decomposition: {None, 'separable', 'sequence'}, optionalIf None, a single array is returned. For 'sequence', a tuple of smaller footprints is returned. Applying this series of smaller footprints will given an identical result to a single, larger footprint, but often with better computational performance. See Notes for more details. With 'separable', this function uses separable 1D footprints for each axis. Whether 'sequence' or 'separable' is computationally faster may be architecture-dependent.
Notes
When decomposition is not None, each element of the footprint tuple is a 2-tuple of the form (ndarray, num_iter) that specifies a footprint array and the number of iterations it is to be applied.
For binary morphology, using decomposition='sequence' was observed to give better performance, with the magnitude of the performance increase rapidly increasing with footprint size. For grayscale morphology with rectangular footprints, it is recommended to use decomposition=None since the internal SciPy functions that are called already have a fast implementation based on separable 1D sliding windows.
The sequence decomposition mode only supports odd valued nrows and ncols. If either nrows or ncols is even, the sequence used will be identical to decomposition='separable'.
The use of
widthandheighthas been deprecated in version 0.18.0. Usenrowsandncolsinstead.
Aliases
-
skimage.morphology.rectangle