machinevisiontoolbox.Image.open
- Image.open(se, n=1, border='replicate', bordervalue=0, **kwargs)
Morphological opening
- Parameters:
se (ndarray(N,M)) – structuring element
n (int, optional) – number of times to apply the erosion then dilation, defauts 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.morphologyEx
- Returns:
dilated image
- Return type:
Image
Returns the image after morphological opening with the structuring element
se
applied asn
erosions followed byn
dilations.Example:
>>> from machinevisiontoolbox import Image >>> import numpy as np >>> img = Image.Read("eg-morph1.png") >>> img.print('{:1d}') 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000010000000000000000000000001100000000 00000000000000010000000000000000000000001100000000 00000000001111111111000000000000000000001100000000 00000000001111111111000000000000000000001100000000 00000000001111111111000001111100000000001100000000 00000000001111111111000001111100000000001100000000 00000000001111111111111111111100000000001100000000 00000000111111111111000001111100000000001100000000 00000000001111111111000001111100000000001100000000 00000000001111111111000000000000000000001100000000 00000000001111111111000000000000000000001100000000 00000000001111111111000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000001100000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000111111111111111111110000000000000000000000000 00000111111111111111111110000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 >>> img.open(np.ones((5,5))).print('{:1d}') 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000001111111111000000000000000000000000000000 00000000001111111111000000000000000000000000000000 00000000001111111111000001111100000000000000000000 00000000001111111111000001111100000000000000000000 00000000001111111111000001111100000000000000000000 00000000001111111111000001111100000000000000000000 00000000001111111111000001111100000000000000000000 00000000001111111111000000000000000000000000000000 00000000001111111111000000000000000000000000000000 00000000001111111111000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000
- Note:
For binary image an opening operation can be used to eliminate small white noise regions.
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.
- References:
Robotics, Vision & Control for Python, Section 11.6, P. Corke, Springer 2023.
- Seealso:
close :meth:`morph
opencv.morphologyEx