filter_isolated_spots
- ketos.audio.utils.filter.filter_isolated_spots(img, struct=array([[1, 1, 1], [1, 1, 1], [1, 1, 1]]))[source]
Remove isolated spots from the image.
- Args:
- imgnumpy array
An array like object representing an image.
- structnumpy array
A structuring pattern that defines feature connections. Must be symmetric.
- Returns:
- filtered_arraynumpy array
An array containing the input image without the isolated spots.
- Example:
>>> from ketos.audio.utils.filter import filter_isolated_spots >>> img = np.array([[0,0,1,1,0,0], ... [0,0,0,1,0,0], ... [0,1,0,0,0,0], ... [0,0,0,0,0,0], ... [0,0,0,1,0,0]]) >>> # remove pixels without neighbors >>> img_fil = filter_isolated_spots(img) >>> print(img_fil) [[0 0 1 1 0 0] [0 0 0 1 0 0] [0 0 0 0 0 0] [0 0 0 0 0 0] [0 0 0 0 0 0]]