machinevisiontoolbox.Image.dilate
- Image.dilate(se, n=1, border='replicate', bordervalue=0, **kwargs)
Morphological dilation
- Parameters:
se (ndarray(N,M)) – structuring element
n (int, optional) – number of times to apply the dilation, defaults to 1
border (str, optional) – option for boundary handling, see
convolve
, defaults to ‘replicate’bordervalue (scalar, optional) – padding value, defaults to 0
kwargs – addition options passed to
opencv.dilate
- Returns:
dilated image
- Return type:
Image
Returns the image after morphological dilation with the structuring element
se
appliedn
times.Example:
>>> from machinevisiontoolbox import Image >>> import numpy as np >>> pixels = np.zeros((7,7)); pixels[3,3] = 1 >>> img = Image(pixels) >>> img.print() 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 >>> img.dilate(np.ones((3,3))).print() 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 255 255 255 0 0 0 0 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- Note:
It is cheaper to apply a smaller structuring element multiple times than one large one, the effective structuing element is the Minkowski sum of the structuring element with itself N times.
The structuring element typically has odd side lengths.
For a greyscale image this is the minimum value over the structuring element.
- References:
Robotics, Vision & Control for Python, Section 11.6, P. Corke, Springer 2023.
- Seealso: