Remove unnecessary whitespace

This commit is contained in:
Nelson Brown
2014-07-11 14:51:57 -07:00
parent 54aff88bd0
commit 1ef556b710
5 changed files with 15 additions and 22 deletions
+4 -4
View File
@@ -31,11 +31,11 @@ def binary_erosion(image, selem=None, 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)
@@ -80,11 +80,11 @@ def binary_dilation(image, selem=None, 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:
+8 -8
View File
@@ -59,7 +59,7 @@ def erosion(image, selem=None, out=None, shift_x=False, shift_y=False):
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
if image is out:
raise NotImplementedError("In-place erosion not supported!")
image = img_as_ubyte(image)
@@ -117,7 +117,7 @@ def dilation(image, selem=None, out=None, shift_x=False, shift_y=False):
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
if image is out:
raise NotImplementedError("In-place dilation not supported!")
image = img_as_ubyte(image)
@@ -168,11 +168,11 @@ def opening(image, selem=None, out=None):
[0, 0, 0, 0, 0]], dtype=uint8)
"""
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
h, w = selem.shape
shift_x = True if (w % 2) == 0 else False
shift_y = True if (h % 2) == 0 else False
@@ -228,7 +228,7 @@ def closing(image, selem=None, out=None):
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
h, w = selem.shape
shift_x = True if (w % 2) == 0 else False
shift_y = True if (h % 2) == 0 else False
@@ -279,11 +279,11 @@ def white_tophat(image, selem=None, out=None):
[0, 0, 0, 0, 0]], dtype=uint8)
"""
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
if image is out:
raise NotImplementedError("Cannot perform white top hat in place.")
@@ -338,7 +338,7 @@ def black_tophat(image, selem=None, out=None):
# Default structure element
if selem is None:
selem = _default_selem(image.ndim)
if image is out:
raise NotImplementedError("Cannot perform white top hat in place.")
+1 -1
View File
@@ -292,7 +292,7 @@ def star(a, dtype=np.uint8):
selem[selem > 0] = 1
return selem.astype(dtype)
def _default_selem(ndim):
"""
Generates a cross-shaped structuring element (connectivity=1). This is the
+1 -4
View File
@@ -65,10 +65,8 @@ def test_out_argument():
testing.assert_array_equal(out, func(img, strel))
def test_default_selem():
functions = [binary.binary_erosion, binary.binary_dilation,
binary.binary_opening, binary.binary_closing]
strel = selem.diamond(radius=1)
image = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -83,11 +81,10 @@ def test_default_selem():
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], np.uint8)
for function in functions:
im_expected = function(image, strel)
im_test = function(image)
yield testing.assert_array_equal, im_expected, im_test
if __name__ == '__main__':
testing.run_module_suite()
+1 -5
View File
@@ -120,11 +120,9 @@ class TestEccentricStructuringElements():
assert np.all(tophat == 0)
def test_default_selem():
functions = [grey.erosion, grey.dilation,
grey.opening, grey.closing,
grey.white_tophat, grey.black_tophat]
strel = selem.diamond(radius=1)
image = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -139,13 +137,11 @@ def test_default_selem():
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], np.uint8)
for function in functions:
im_expected = function(image, strel)
im_test = function(image)
yield testing.assert_array_equal, im_expected, im_test
class TestDTypes():
def setUp(self):