mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 08:52:29 +08:00
Always use uint8 for binary view.
This commit is contained in:
@@ -33,12 +33,11 @@ def binary_erosion(image, selem, out=None):
|
||||
selem_sum = np.sum(selem)
|
||||
|
||||
if selem_sum <= 255:
|
||||
binary = (image > 0).view(np.uint8)
|
||||
conv = np.empty_like(image, dtype=np.uint8)
|
||||
else:
|
||||
binary = (image > 0).astype(np.intp)
|
||||
conv = np.empty_like(image, dtype=np.intp)
|
||||
|
||||
binary = (image > 0).view(np.uint8)
|
||||
ndimage.convolve(binary, selem, mode='constant', cval=1, output=conv)
|
||||
|
||||
if out is None:
|
||||
@@ -74,13 +73,13 @@ def binary_dilation(image, selem, out=None):
|
||||
|
||||
"""
|
||||
selem = (selem != 0)
|
||||
|
||||
if np.sum(selem) <= 255:
|
||||
binary = (image > 0).view(np.uint8)
|
||||
conv = np.empty_like(image, dtype=np.uint8)
|
||||
else:
|
||||
binary = (image > 0).astype(np.intp)
|
||||
conv = np.empty_like(image, dtype=np.intp)
|
||||
|
||||
binary = (image > 0).view(np.uint8)
|
||||
ndimage.convolve(binary, selem, mode='constant', cval=0, output=conv)
|
||||
|
||||
if out is None:
|
||||
|
||||
Reference in New Issue
Block a user