From 43c8858338fb1c1f8664b8ef1bc562ad74493dc1 Mon Sep 17 00:00:00 2001 From: Umesh Date: Sun, 21 Apr 2013 17:18:48 -0700 Subject: [PATCH 1/7] Updated Implementation of Roberts Algorithm --- doc/examples/plot_edge_filter.py | 23 +++++++++ skimage/filter/__init__.py | 2 +- skimage/filter/edges.py | 88 ++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 doc/examples/plot_edge_filter.py diff --git a/doc/examples/plot_edge_filter.py b/doc/examples/plot_edge_filter.py new file mode 100644 index 00000000..bbc79ff8 --- /dev/null +++ b/doc/examples/plot_edge_filter.py @@ -0,0 +1,23 @@ +import matplotlib +import matplotlib.pyplot as plt + +from skimage.data import camera +from skimage.filter import roberts,sobel + +image = camera() +edge_roberts = roberts(image) +edge_sobel = sobel(image) + +plt.figure(figsize=(8, 2.5)) +plt.subplot(1, 2, 1) +plt.imshow(edge_roberts, cmap=plt.cm.gray) +plt.title('Roberts Edge Detection') +plt.axis('off') + +plt.subplot(1, 2, 2) +plt.imshow(edge_sobel, cmap=plt.cm.gray) +plt.title('Sobel Edge Detection') +plt.axis('off') + + +plt.show() diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py index 15eec3da..e98583ff 100644 --- a/skimage/filter/__init__.py +++ b/skimage/filter/__init__.py @@ -2,7 +2,7 @@ from .lpi_filter import * from .ctmf import median_filter from ._canny import canny from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt, - hprewitt, vprewitt) + hprewitt, vprewitt, roberts , pdroberts, ndroberts) from ._denoise import denoise_tv_chambolle, tv_denoise from ._denoise_cy import denoise_bilateral, denoise_tv_bregman from ._rank_order import rank_order diff --git a/skimage/filter/edges.py b/skimage/filter/edges.py index fcd9f548..ef0a37a5 100644 --- a/skimage/filter/edges.py +++ b/skimage/filter/edges.py @@ -338,3 +338,91 @@ def vprewitt(image, mask=None): [1, 0, -1], [1, 0, -1]]).astype(float) / 3.0)) return _mask_filter_result(result, mask) + + +def roberts(image, mask=None): + """Find the edge magnitude using Roberts' Cross Operator. + + Parameters + ---------- + image : 2-D array + Image to process. + mask : 2-D array, optional + An optional mask to limit the application to a certain area. + Note that pixels surrounding masked regions are also masked to + prevent masked regions from affecting the result. + + Returns + ------- + output : ndarray + The Roberts' Cross edge map. + """ + return np.sqrt(pdroberts(image, mask)**2 + ndroberts(image, mask)**2) + + +def pdroberts(image, mask=None): + """Find the cross edges of an image using the Roberts' Cross operator. + The kernel is applied to the input image, to produce separate measurements + of the gradient component one orientation. + Parameters + ---------- + image : 2-D array + Image to process. + mask : 2-D array, optional + An optional mask to limit the application to a certain area. + Note that pixels surrounding masked regions are also masked to + prevent masked regions from affecting the result. + + Returns + ------- + output : ndarray + The Robert edge map. + + Notes + ----- + We use the following kernel and return the absolute value of the + result at each point:: + + 1 0 + 0 -1 + + """ + image = img_as_float(image) + result = np.abs(convolve(image, + np.array([[ 1, 0], + [ 0, -1]]).astype(float) / 1.0 )) + return _mask_filter_result(result, mask) + + +def ndroberts(image, mask=None): + """Find the cross edges of an image using the Roberts' Cross operator. + The kernel is applied to the input image, to produce separate measurements + of the gradient component one orientation. + Parameters + ---------- + image : 2-D array + Image to process. + mask : 2-D array, optional + An optional mask to limit the application to a certain area. + Note that pixels surrounding masked regions are also masked to + prevent masked regions from affecting the result. + + Returns + ------- + output : ndarray + The Robert edge map. + + Notes + ----- + We use the following kernel and return the absolute value of the + result at each point:: + + 0 1 + -1 0 + + """ + image = img_as_float(image) + result = np.abs(convolve(image, + np.array([[0, 1], + [-1, 0]]).astype(float) / 1.0)) + return _mask_filter_result(result, mask) From e6dedc68e84bfa49af790738aafa60bef59c6532 Mon Sep 17 00:00:00 2001 From: Umesh Date: Mon, 22 Apr 2013 00:20:44 -0700 Subject: [PATCH 2/7] Upadated Version with test added(/filter/tests/test_edge.py --- skimage/filter/edges.py | 10 +++--- skimage/filter/tests/test_edges.py | 49 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/skimage/filter/edges.py b/skimage/filter/edges.py index ef0a37a5..73215d71 100644 --- a/skimage/filter/edges.py +++ b/skimage/filter/edges.py @@ -362,8 +362,10 @@ def roberts(image, mask=None): def pdroberts(image, mask=None): """Find the cross edges of an image using the Roberts' Cross operator. + The kernel is applied to the input image, to produce separate measurements of the gradient component one orientation. + Parameters ---------- image : 2-D array @@ -376,7 +378,7 @@ def pdroberts(image, mask=None): Returns ------- output : ndarray - The Robert edge map. + The Robert's edge map. Notes ----- @@ -390,7 +392,7 @@ def pdroberts(image, mask=None): image = img_as_float(image) result = np.abs(convolve(image, np.array([[ 1, 0], - [ 0, -1]]).astype(float) / 1.0 )) + [ 0, -1]]).astype(float))) return _mask_filter_result(result, mask) @@ -410,7 +412,7 @@ def ndroberts(image, mask=None): Returns ------- output : ndarray - The Robert edge map. + The Robert's edge map. Notes ----- @@ -424,5 +426,5 @@ def ndroberts(image, mask=None): image = img_as_float(image) result = np.abs(convolve(image, np.array([[0, 1], - [-1, 0]]).astype(float) / 1.0)) + [-1, 0]]).astype(float))) return _mask_filter_result(result, mask) diff --git a/skimage/filter/tests/test_edges.py b/skimage/filter/tests/test_edges.py index 628de16d..fec01109 100644 --- a/skimage/filter/tests/test_edges.py +++ b/skimage/filter/tests/test_edges.py @@ -4,6 +4,55 @@ from numpy.testing import assert_array_almost_equal as assert_close import skimage.filter as F +def test_roberts_zeros(): + """Roberts' on an array of all zeros""" + result = F.roberts(np.zeros((10, 10)), np.ones((10, 10), bool)) + assert (np.all(result == 0)) + + +def test_roberts_diagonal1(): + """Roberts' on an edge should be a diagonal""" + i = (10, 10) + n = (10, 10) + i = np.ones(i) + i = np.triu(i) + image = (i > 0).astype(float) + n = np.zeros(n) + for k in range(2, 10): + for t in range(0, k-1): + n[k][t] = 1 + n[t][k] = 1 + j = np.identity(10) + result = F.roberts(image) + j[9][9] = j[0][0] = 0 + assert (np.all(result[j == 1] == 1) and np.all(result[n == 1] == 0)) + + +def test_roberts_diagonal2(): + """Roberts' on an edge should be a diagonal""" + i = (10, 10) + j = (10, 10) + n = (10, 10) + i = np.ones(i) + for k in range(0, 10): + for t in range(10-k, 10): + i[k][t] = 0 + n = np.zeros(n) + for k in range(0, 10): + for t in range(0, 9-k): + n[k][t] = 0 + n[t][k] = 0 + + image = (i > 0).astype(float) + + j = np.ones(j) + for k in range(0, 10): + j[k][9-k] = 5 + result = F.roberts(image) + j[0][9] = j[9][0] = 0 + assert (np.all(result[j == 5] == 1) and np.all(result[n == 1] == 0)) + + def test_sobel_zeros(): """Sobel on an array of all zeros""" result = F.sobel(np.zeros((10, 10)), np.ones((10, 10), bool)) From 27026cea8735cf352d0d5a3c5a68a253156369c4 Mon Sep 17 00:00:00 2001 From: Umesh Date: Mon, 22 Apr 2013 07:51:32 -0700 Subject: [PATCH 3/7] updated tests for Roberts Edge Detector --- skimage/filter/tests/test_edges.py | 34 +++++++++--------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/skimage/filter/tests/test_edges.py b/skimage/filter/tests/test_edges.py index fec01109..e84dba41 100644 --- a/skimage/filter/tests/test_edges.py +++ b/skimage/filter/tests/test_edges.py @@ -12,16 +12,11 @@ def test_roberts_zeros(): def test_roberts_diagonal1(): """Roberts' on an edge should be a diagonal""" - i = (10, 10) n = (10, 10) - i = np.ones(i) - i = np.triu(i) + i = np.tri(10,10,0) image = (i > 0).astype(float) - n = np.zeros(n) - for k in range(2, 10): - for t in range(0, k-1): - n[k][t] = 1 - n[t][k] = 1 + n = np.tri(10,10,-2) + n = n+n.transpose() j = np.identity(10) result = F.roberts(image) j[9][9] = j[0][0] = 0 @@ -30,27 +25,18 @@ def test_roberts_diagonal1(): def test_roberts_diagonal2(): """Roberts' on an edge should be a diagonal""" - i = (10, 10) - j = (10, 10) - n = (10, 10) - i = np.ones(i) - for k in range(0, 10): - for t in range(10-k, 10): - i[k][t] = 0 - n = np.zeros(n) - for k in range(0, 10): - for t in range(0, 9-k): - n[k][t] = 0 - n[t][k] = 0 + i = np.tri(10,10,0,dtype=int) + i = np.rot90(i.transpose()) + n = np.tri(10,10,-2,dtype=int) + n = np.rot90(n.transpose()) + np.rot90(n) image = (i > 0).astype(float) - j = np.ones(j) - for k in range(0, 10): - j[k][9-k] = 5 + j = np.identity(10) + j = np.rot90(j) result = F.roberts(image) j[0][9] = j[9][0] = 0 - assert (np.all(result[j == 5] == 1) and np.all(result[n == 1] == 0)) + assert (np.all(result[j == 1] == 1) and np.all(result[n == 1] == 0)) def test_sobel_zeros(): From f417a45a971d13ef4f5ae5ad75fd090bdc1a4ea0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Apr 2013 15:29:25 -0700 Subject: [PATCH 4/7] Updated function names[Robert's Edge Detection] --- skimage/filter/__init__.py | 2 +- skimage/filter/edges.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py index e98583ff..bd9c94cc 100644 --- a/skimage/filter/__init__.py +++ b/skimage/filter/__init__.py @@ -2,7 +2,7 @@ from .lpi_filter import * from .ctmf import median_filter from ._canny import canny from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt, - hprewitt, vprewitt, roberts , pdroberts, ndroberts) + hprewitt, vprewitt, roberts , roberts_positive_diagonal, roberts_negative_diagonal) from ._denoise import denoise_tv_chambolle, tv_denoise from ._denoise_cy import denoise_bilateral, denoise_tv_bregman from ._rank_order import rank_order diff --git a/skimage/filter/edges.py b/skimage/filter/edges.py index 73215d71..0e1fcda0 100644 --- a/skimage/filter/edges.py +++ b/skimage/filter/edges.py @@ -357,10 +357,10 @@ def roberts(image, mask=None): output : ndarray The Roberts' Cross edge map. """ - return np.sqrt(pdroberts(image, mask)**2 + ndroberts(image, mask)**2) + return np.sqrt(roberts_positive_diagonal(image, mask)**2 + roberts_negative_diagonal(image, mask)**2) -def pdroberts(image, mask=None): +def roberts_positive_diagonal(image, mask=None): """Find the cross edges of an image using the Roberts' Cross operator. The kernel is applied to the input image, to produce separate measurements @@ -396,7 +396,7 @@ def pdroberts(image, mask=None): return _mask_filter_result(result, mask) -def ndroberts(image, mask=None): +def roberts_negative_diagonal(image, mask=None): """Find the cross edges of an image using the Roberts' Cross operator. The kernel is applied to the input image, to produce separate measurements of the gradient component one orientation. From 9c6cd7dbd9499794ac66c917d3c46d13dfc2a775 Mon Sep 17 00:00:00 2001 From: umesh Date: Tue, 23 Apr 2013 01:16:29 -0700 Subject: [PATCH 5/7] Final Roberts Edge Detector --- skimage/filter/__init__.py | 3 ++- skimage/filter/edges.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py index bd9c94cc..5479af5d 100644 --- a/skimage/filter/__init__.py +++ b/skimage/filter/__init__.py @@ -2,7 +2,8 @@ from .lpi_filter import * from .ctmf import median_filter from ._canny import canny from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt, - hprewitt, vprewitt, roberts , roberts_positive_diagonal, roberts_negative_diagonal) + hprewitt, vprewitt, roberts , roberts_positive_diagonal, + roberts_negative_diagonal) from ._denoise import denoise_tv_chambolle, tv_denoise from ._denoise_cy import denoise_bilateral, denoise_tv_bregman from ._rank_order import rank_order diff --git a/skimage/filter/edges.py b/skimage/filter/edges.py index 0e1fcda0..05404615 100644 --- a/skimage/filter/edges.py +++ b/skimage/filter/edges.py @@ -357,7 +357,8 @@ def roberts(image, mask=None): output : ndarray The Roberts' Cross edge map. """ - return np.sqrt(roberts_positive_diagonal(image, mask)**2 + roberts_negative_diagonal(image, mask)**2) + return np.sqrt(roberts_positive_diagonal(image, mask)**2 +\ + roberts_negative_diagonal(image, mask)**2) def roberts_positive_diagonal(image, mask=None): From 18839cdf084e2d2bb4afc8e741231d74047a059c Mon Sep 17 00:00:00 2001 From: umesh Date: Tue, 23 Apr 2013 08:43:05 -0700 Subject: [PATCH 6/7] Updated Test Case --- skimage/filter/tests/test_edges.py | 40 +++++++++++++----------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/skimage/filter/tests/test_edges.py b/skimage/filter/tests/test_edges.py index e84dba41..e550099a 100644 --- a/skimage/filter/tests/test_edges.py +++ b/skimage/filter/tests/test_edges.py @@ -2,7 +2,7 @@ import numpy as np from numpy.testing import assert_array_almost_equal as assert_close import skimage.filter as F - +from skimage.filter.edges import _mask_filter_result def test_roberts_zeros(): """Roberts' on an array of all zeros""" @@ -11,32 +11,26 @@ def test_roberts_zeros(): def test_roberts_diagonal1(): - """Roberts' on an edge should be a diagonal""" - n = (10, 10) - i = np.tri(10,10,0) - image = (i > 0).astype(float) - n = np.tri(10,10,-2) - n = n+n.transpose() - j = np.identity(10) - result = F.roberts(image) - j[9][9] = j[0][0] = 0 - assert (np.all(result[j == 1] == 1) and np.all(result[n == 1] == 0)) + """Roberts' on an edge should be a one diagonal""" + image = np.tri(10, 10, 0) + expected = ~(np.tri(10, 10, -1).astype(bool) | \ + np.tri(10, 10, -2).astype(bool).transpose()) + expected = _mask_filter_result(expected,None) + result = F.roberts(image).astype(bool) + assert_close(result,expected) def test_roberts_diagonal2(): - """Roberts' on an edge should be a diagonal""" - i = np.tri(10,10,0,dtype=int) - i = np.rot90(i.transpose()) - n = np.tri(10,10,-2,dtype=int) - n = np.rot90(n.transpose()) + np.rot90(n) + """Roberts' on an edge should be a other diagonal""" + diagonal = np.tri(10, 10, 0,dtype=int) + rev_diagonal = np.rot90(diagonal.transpose(),1) - image = (i > 0).astype(float) - - j = np.identity(10) - j = np.rot90(j) - result = F.roberts(image) - j[0][9] = j[9][0] = 0 - assert (np.all(result[j == 1] == 1) and np.all(result[n == 1] == 0)) + image = (rev_diagonal > 0).astype(float) + expected = ~np.rot90((np.tri(10, 10, -1).astype(bool) | \ + np.tri(10, 10, -2).astype(bool).transpose()),1) + expected = _mask_filter_result(expected,None) + result = F.roberts(image).astype(bool) + assert_close(result,expected) def test_sobel_zeros(): From 5c3c75cd098c61b7a4afab9d6993ec341d304c84 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 25 Apr 2013 22:47:22 -0500 Subject: [PATCH 7/7] Minor cleanups * PEP8 clean ups (space after commas, docstring spacing, prefer parentheses over line continuation) * Simplify creation of test images. * Use `plt.subplots` instead of state machine * Minor wording modifications --- doc/examples/plot_edge_filter.py | 19 +++--- skimage/filter/edges.py | 12 ++-- skimage/filter/tests/test_edges.py | 98 +++++++++++++++--------------- 3 files changed, 63 insertions(+), 66 deletions(-) diff --git a/doc/examples/plot_edge_filter.py b/doc/examples/plot_edge_filter.py index bbc79ff8..afadddf7 100644 --- a/doc/examples/plot_edge_filter.py +++ b/doc/examples/plot_edge_filter.py @@ -1,23 +1,20 @@ -import matplotlib import matplotlib.pyplot as plt from skimage.data import camera -from skimage.filter import roberts,sobel +from skimage.filter import roberts, sobel image = camera() edge_roberts = roberts(image) edge_sobel = sobel(image) -plt.figure(figsize=(8, 2.5)) -plt.subplot(1, 2, 1) -plt.imshow(edge_roberts, cmap=plt.cm.gray) -plt.title('Roberts Edge Detection') -plt.axis('off') +fig, (ax0, ax1) = plt.subplots(ncols=2) -plt.subplot(1, 2, 2) -plt.imshow(edge_sobel, cmap=plt.cm.gray) -plt.title('Sobel Edge Detection') -plt.axis('off') +ax0.imshow(edge_roberts, cmap=plt.cm.gray) +ax0.set_title('Roberts Edge Detection') +ax0.axis('off') +ax1.imshow(edge_sobel, cmap=plt.cm.gray) +ax1.set_title('Sobel Edge Detection') +ax1.axis('off') plt.show() diff --git a/skimage/filter/edges.py b/skimage/filter/edges.py index 05404615..d06b2efa 100644 --- a/skimage/filter/edges.py +++ b/skimage/filter/edges.py @@ -341,7 +341,7 @@ def vprewitt(image, mask=None): def roberts(image, mask=None): - """Find the edge magnitude using Roberts' Cross Operator. + """Find the edge magnitude using Roberts' cross operator. Parameters ---------- @@ -357,14 +357,14 @@ def roberts(image, mask=None): output : ndarray The Roberts' Cross edge map. """ - return np.sqrt(roberts_positive_diagonal(image, mask)**2 +\ + return np.sqrt(roberts_positive_diagonal(image, mask)**2 + roberts_negative_diagonal(image, mask)**2) def roberts_positive_diagonal(image, mask=None): - """Find the cross edges of an image using the Roberts' Cross operator. + """Find the cross edges of an image using Roberts' cross operator. - The kernel is applied to the input image, to produce separate measurements + The kernel is applied to the input image to produce separate measurements of the gradient component one orientation. Parameters @@ -399,8 +399,10 @@ def roberts_positive_diagonal(image, mask=None): def roberts_negative_diagonal(image, mask=None): """Find the cross edges of an image using the Roberts' Cross operator. - The kernel is applied to the input image, to produce separate measurements + + The kernel is applied to the input image to produce separate measurements of the gradient component one orientation. + Parameters ---------- image : 2-D array diff --git a/skimage/filter/tests/test_edges.py b/skimage/filter/tests/test_edges.py index e550099a..523d6dd8 100644 --- a/skimage/filter/tests/test_edges.py +++ b/skimage/filter/tests/test_edges.py @@ -4,43 +4,41 @@ from numpy.testing import assert_array_almost_equal as assert_close import skimage.filter as F from skimage.filter.edges import _mask_filter_result + def test_roberts_zeros(): - """Roberts' on an array of all zeros""" + """Roberts' filter on an array of all zeros.""" result = F.roberts(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_roberts_diagonal1(): - """Roberts' on an edge should be a one diagonal""" + """Roberts' filter on a diagonal edge should be a diagonal line.""" image = np.tri(10, 10, 0) - expected = ~(np.tri(10, 10, -1).astype(bool) | \ + expected = ~(np.tri(10, 10, -1).astype(bool) | np.tri(10, 10, -2).astype(bool).transpose()) - expected = _mask_filter_result(expected,None) + expected = _mask_filter_result(expected, None) result = F.roberts(image).astype(bool) - assert_close(result,expected) + assert_close(result, expected) def test_roberts_diagonal2(): - """Roberts' on an edge should be a other diagonal""" - diagonal = np.tri(10, 10, 0,dtype=int) - rev_diagonal = np.rot90(diagonal.transpose(),1) - - image = (rev_diagonal > 0).astype(float) - expected = ~np.rot90((np.tri(10, 10, -1).astype(bool) | \ - np.tri(10, 10, -2).astype(bool).transpose()),1) - expected = _mask_filter_result(expected,None) + """Roberts' filter on a diagonal edge should be a diagonal line.""" + image = np.rot90(np.tri(10, 10, 0), 3) + expected = ~np.rot90(np.tri(10, 10, -1).astype(bool) | + np.tri(10, 10, -2).astype(bool).transpose()) + expected = _mask_filter_result(expected, None) result = F.roberts(image).astype(bool) - assert_close(result,expected) + assert_close(result, expected) def test_sobel_zeros(): - """Sobel on an array of all zeros""" + """Sobel on an array of all zeros.""" result = F.sobel(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_sobel_mask(): - """Sobel on a masked array should be zero""" + """Sobel on a masked array should be zero.""" np.random.seed(0) result = F.sobel(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -48,7 +46,7 @@ def test_sobel_mask(): def test_sobel_horizontal(): - """Sobel on an edge should be a horizontal line""" + """Sobel on a horizontal edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.sobel(image) @@ -59,7 +57,7 @@ def test_sobel_horizontal(): def test_sobel_vertical(): - """Sobel on a vertical edge should be a vertical line""" + """Sobel on a vertical edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.sobel(image) @@ -69,13 +67,13 @@ def test_sobel_vertical(): def test_hsobel_zeros(): - """Horizontal sobel on an array of all zeros""" + """Horizontal sobel on an array of all zeros.""" result = F.hsobel(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_hsobel_mask(): - """Horizontal Sobel on a masked array should be zero""" + """Horizontal Sobel on a masked array should be zero.""" np.random.seed(0) result = F.hsobel(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -83,7 +81,7 @@ def test_hsobel_mask(): def test_hsobel_horizontal(): - """Horizontal Sobel on an edge should be a horizontal line""" + """Horizontal Sobel on an edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.hsobel(image) @@ -94,7 +92,7 @@ def test_hsobel_horizontal(): def test_hsobel_vertical(): - """Horizontal Sobel on a vertical edge should be zero""" + """Horizontal Sobel on a vertical edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.hsobel(image) @@ -102,13 +100,13 @@ def test_hsobel_vertical(): def test_vsobel_zeros(): - """Vertical sobel on an array of all zeros""" + """Vertical sobel on an array of all zeros.""" result = F.vsobel(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_vsobel_mask(): - """Vertical Sobel on a masked array should be zero""" + """Vertical Sobel on a masked array should be zero.""" np.random.seed(0) result = F.vsobel(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -116,7 +114,7 @@ def test_vsobel_mask(): def test_vsobel_vertical(): - """Vertical Sobel on an edge should be a vertical line""" + """Vertical Sobel on an edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vsobel(image) @@ -127,7 +125,7 @@ def test_vsobel_vertical(): def test_vsobel_horizontal(): - """vertical Sobel on a horizontal edge should be zero""" + """vertical Sobel on a horizontal edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vsobel(image) @@ -136,13 +134,13 @@ def test_vsobel_horizontal(): def test_scharr_zeros(): - """Scharr on an array of all zeros""" + """Scharr on an array of all zeros.""" result = F.scharr(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_scharr_mask(): - """Scharr on a masked array should be zero""" + """Scharr on a masked array should be zero.""" np.random.seed(0) result = F.scharr(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -150,7 +148,7 @@ def test_scharr_mask(): def test_scharr_horizontal(): - """Scharr on an edge should be a horizontal line""" + """Scharr on an edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.scharr(image) @@ -161,7 +159,7 @@ def test_scharr_horizontal(): def test_scharr_vertical(): - """Scharr on a vertical edge should be a vertical line""" + """Scharr on a vertical edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.scharr(image) @@ -171,13 +169,13 @@ def test_scharr_vertical(): def test_hscharr_zeros(): - """Horizontal Scharr on an array of all zeros""" + """Horizontal Scharr on an array of all zeros.""" result = F.hscharr(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_hscharr_mask(): - """Horizontal Scharr on a masked array should be zero""" + """Horizontal Scharr on a masked array should be zero.""" np.random.seed(0) result = F.hscharr(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -185,7 +183,7 @@ def test_hscharr_mask(): def test_hscharr_horizontal(): - """Horizontal Scharr on an edge should be a horizontal line""" + """Horizontal Scharr on an edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.hscharr(image) @@ -196,7 +194,7 @@ def test_hscharr_horizontal(): def test_hscharr_vertical(): - """Horizontal Scharr on a vertical edge should be zero""" + """Horizontal Scharr on a vertical edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.hscharr(image) @@ -204,13 +202,13 @@ def test_hscharr_vertical(): def test_vscharr_zeros(): - """Vertical Scharr on an array of all zeros""" + """Vertical Scharr on an array of all zeros.""" result = F.vscharr(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_vscharr_mask(): - """Vertical Scharr on a masked array should be zero""" + """Vertical Scharr on a masked array should be zero.""" np.random.seed(0) result = F.vscharr(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -218,7 +216,7 @@ def test_vscharr_mask(): def test_vscharr_vertical(): - """Vertical Scharr on an edge should be a vertical line""" + """Vertical Scharr on an edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vscharr(image) @@ -229,7 +227,7 @@ def test_vscharr_vertical(): def test_vscharr_horizontal(): - """vertical Scharr on a horizontal edge should be zero""" + """vertical Scharr on a horizontal edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vscharr(image) @@ -238,13 +236,13 @@ def test_vscharr_horizontal(): def test_prewitt_zeros(): - """Prewitt on an array of all zeros""" + """Prewitt on an array of all zeros.""" result = F.prewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_prewitt_mask(): - """Prewitt on a masked array should be zero""" + """Prewitt on a masked array should be zero.""" np.random.seed(0) result = F.prewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -253,7 +251,7 @@ def test_prewitt_mask(): def test_prewitt_horizontal(): - """Prewitt on an edge should be a horizontal line""" + """Prewitt on an edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.prewitt(image) @@ -265,7 +263,7 @@ def test_prewitt_horizontal(): def test_prewitt_vertical(): - """Prewitt on a vertical edge should be a vertical line""" + """Prewitt on a vertical edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.prewitt(image) @@ -276,13 +274,13 @@ def test_prewitt_vertical(): def test_hprewitt_zeros(): - """Horizontal prewitt on an array of all zeros""" + """Horizontal prewitt on an array of all zeros.""" result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_hprewitt_mask(): - """Horizontal prewitt on a masked array should be zero""" + """Horizontal prewitt on a masked array should be zero.""" np.random.seed(0) result = F.hprewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -291,7 +289,7 @@ def test_hprewitt_mask(): def test_hprewitt_horizontal(): - """Horizontal prewitt on an edge should be a horizontal line""" + """Horizontal prewitt on an edge should be a horizontal line.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.hprewitt(image) @@ -303,7 +301,7 @@ def test_hprewitt_horizontal(): def test_hprewitt_vertical(): - """Horizontal prewitt on a vertical edge should be zero""" + """Horizontal prewitt on a vertical edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.hprewitt(image) @@ -312,13 +310,13 @@ def test_hprewitt_vertical(): def test_vprewitt_zeros(): - """Vertical prewitt on an array of all zeros""" + """Vertical prewitt on an array of all zeros.""" result = F.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0)) def test_vprewitt_mask(): - """Vertical prewitt on a masked array should be zero""" + """Vertical prewitt on a masked array should be zero.""" np.random.seed(0) result = F.vprewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) @@ -326,7 +324,7 @@ def test_vprewitt_mask(): def test_vprewitt_vertical(): - """Vertical prewitt on an edge should be a vertical line""" + """Vertical prewitt on an edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vprewitt(image) @@ -338,7 +336,7 @@ def test_vprewitt_vertical(): def test_vprewitt_horizontal(): - """Vertical prewitt on a horizontal edge should be zero""" + """Vertical prewitt on a horizontal edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vprewitt(image)