Always use uint8 for binary view.

This commit is contained in:
Stefan van der Walt
2013-10-14 16:41:08 +02:00
parent f83c7a95e3
commit d182286e53
+3 -4
View File
@@ -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: