20.6 Grey-scale morphology

Grey-scale morphology operations are the equivalents of binary morphology operations that operate on arrays with arbitrary values. Below we describe the grey-scale equivalents of erosion, dilation, opening and closing. These operations are implemented in a similar fashion as the filters described in section 20.2, and we refer to this section for the description of filter kernels and footprints, and the handling of array borders. The grey-scale morphology operations optionally take a structure parameter that gives the values of the structuring element. If this parameter is not given the structuring element is assumed to be flat with a value equal to zero. The shape of the structure can optionally be defined by the footprint parameter. If this parameter is not given, the structure is assumed to be rectangular, with sizes equal to the dimensions of the structure array, or by the size parameter if structure is not given. The size parameter is only used if both structure and footprint are not given, in which case the structuring element is assumed to be rectangular and flat with the dimensions given by size. The size parameter, if provided, must be a sequence of sizes or a single number in which case the size of the filter is assumed to be equal along each axis. The footprint parameter, if provided, must be an array that defines the shape of the kernel by its non-zero elements.

Similar to binary erosion and dilation there are operations for grey-scale erosion and dilation:

grey_erosion( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The grey_erosion function calculates a multi-dimensional grey- scale erosion.

grey_dilation( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The grey_dilation function calculates a multi-dimensional grey- scale dilation.

Grey-scale opening and closing operations can be defined similar to their binary counterparts:

grey_opening( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The grey_opening function implements grey-scale opening of arrays of arbitrary rank. Grey-scale opening is equivalent to a grey-scale erosion followed by a grey-scale dilation.

grey_closing( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The grey_closing function implements grey-scale closing of arrays of arbitrary rank. Grey-scale opening is equivalent to a grey-scale dilation followed by a grey-scale erosion.

morphological_gradient( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The morphological_gradient function implements a grey-scale morphological gradient of arrays of arbitrary rank. The grey-scale morphological gradient is equal to the difference of a grey-scale dilation and a grey-scale erosion.

morphological_laplace( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The morphological_laplace function implements a grey-scale morphological laplace of arrays of arbitrary rank. The grey-scale morphological laplace is equal to the sum of a grey-scale dilation and a grey-scale erosion minus twice the input.

white_tophat( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The white_tophat function implements a white top-hat filter of arrays of arbitrary rank. The white top-hat is equal to the difference of the input and a grey-scale opening.

black_tophat( input, size=None, footprint=None, structure=None, output=None, mode='nearest', cval=0.0, origin=0)
The black_tophat function implements a black top-hat filter of arrays of arbitrary rank. The black top-hat is equal to the difference of the a grey-scale closing and the input.

Send comments to the NumArray community.