mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-14 12:50:39 +08:00
Add default structuring element to morphology
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import warnings
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from .selem import _default_selem
|
||||
|
||||
|
||||
def binary_erosion(image, selem, out=None):
|
||||
def binary_erosion(image, selem=None, out=None):
|
||||
"""Return fast binary morphological erosion of an image.
|
||||
|
||||
This function returns the same result as greyscale erosion but performs
|
||||
@@ -29,6 +30,11 @@ def binary_erosion(image, selem, out=None):
|
||||
The result of the morphological erosion with values in ``[0, 1]``.
|
||||
|
||||
"""
|
||||
|
||||
# Default structure element
|
||||
if selem is None:
|
||||
selem = _default_selem(image.ndim)
|
||||
|
||||
selem = (selem != 0)
|
||||
selem_sum = np.sum(selem)
|
||||
|
||||
@@ -45,7 +51,7 @@ def binary_erosion(image, selem, out=None):
|
||||
return np.equal(conv, selem_sum, out=out)
|
||||
|
||||
|
||||
def binary_dilation(image, selem, out=None):
|
||||
def binary_dilation(image, selem=None, out=None):
|
||||
"""Return fast binary morphological dilation of an image.
|
||||
|
||||
This function returns the same result as greyscale dilation but performs
|
||||
@@ -72,6 +78,11 @@ def binary_dilation(image, selem, out=None):
|
||||
The result of the morphological dilation with values in ``[0, 1]``.
|
||||
|
||||
"""
|
||||
|
||||
# Default structure element
|
||||
if selem is None:
|
||||
selem = _default_selem(image.ndim)
|
||||
|
||||
selem = (selem != 0)
|
||||
|
||||
if np.sum(selem) <= 255:
|
||||
@@ -87,7 +98,7 @@ def binary_dilation(image, selem, out=None):
|
||||
return np.not_equal(conv, 0, out=out)
|
||||
|
||||
|
||||
def binary_opening(image, selem, out=None):
|
||||
def binary_opening(image, selem=None, out=None):
|
||||
"""Return fast binary morphological opening of an image.
|
||||
|
||||
This function returns the same result as greyscale opening but performs
|
||||
@@ -119,7 +130,7 @@ def binary_opening(image, selem, out=None):
|
||||
return out
|
||||
|
||||
|
||||
def binary_closing(image, selem, out=None):
|
||||
def binary_closing(image, selem=None, out=None):
|
||||
"""Return fast binary morphological closing of an image.
|
||||
|
||||
This function returns the same result as greyscale closing but performs
|
||||
|
||||
Reference in New Issue
Block a user