tests and minor corrections

This commit is contained in:
Vighnesh Birodkar
2014-04-09 10:27:53 +05:30
parent a4029c0e71
commit 2e441b2e5b
2 changed files with 33 additions and 29 deletions
+19 -20
View File
@@ -351,27 +351,25 @@ def blob_doh(image, min_sigma=1, max_sigma=30, num_sigma=10, threshold=500,
Examples Examples
-------- --------
>>> from skimage import data, feature, exposure >>> from skimage import data, feature
>>> img = data.coins() >>> img = data.coins()
>>> img = exposure.equalize_hist(img) # improves detection >>> feature.blob_doh(img,threshold = 700)
>>> feature.blob_log(img, threshold = .3) array([[121, 271, 30],
array([[113, 323, 1], [123, 44, 23],
[121, 272, 17], [123, 205, 20],
[124, 336, 11], [124, 336, 20],
[126, 46, 11], [126, 101, 20],
[126, 208, 11], [126, 153, 20],
[127, 102, 11], [156, 302, 30],
[128, 154, 11], [185, 348, 30],
[185, 344, 17], [192, 212, 23],
[194, 213, 17], [193, 275, 23],
[194, 276, 17], [195, 100, 23],
[197, 44, 11], [197, 153, 20],
[198, 103, 11], [260, 173, 30],
[198, 155, 11], [262, 243, 23],
[260, 174, 17], [265, 113, 23],
[263, 244, 17], [270, 363, 30]])
[263, 302, 17],
[266, 115, 11]])
Notes Notes
----- -----
@@ -381,6 +379,7 @@ def blob_doh(image, min_sigma=1, max_sigma=30, num_sigma=10, threshold=500,
methods line :py:meth:`blob_dog` and :py:meth:`blob_log` the computation methods line :py:meth:`blob_dog` and :py:meth:`blob_log` the computation
of Gaussians for larger `sigma` takes more time. of Gaussians for larger `sigma` takes more time.
""" """
if image.ndim != 2: if image.ndim != 2:
raise ValueError("'image' must be a grayscale ") raise ValueError("'image' must be a grayscale ")
+13 -8
View File
@@ -18,7 +18,7 @@ def test_blob_dog():
img[xs, ys] = 255 img[xs, ys] = 255
blobs = blob_dog(img, min_sigma=5, max_sigma=50) blobs = blob_dog(img, min_sigma=5, max_sigma=50)
radius = lambda x: r2*x[2] radius = lambda x: r2 * x[2]
s = sorted(blobs, key=radius) s = sorted(blobs, key=radius)
thresh = 5 thresh = 5
@@ -56,7 +56,7 @@ def test_blob_log():
blobs = blob_log(img, min_sigma=5, max_sigma=20, threshold=1) blobs = blob_log(img, min_sigma=5, max_sigma=20, threshold=1)
radius = lambda x: r2*x[2] radius = lambda x: r2 * x[2]
s = sorted(blobs, key=radius) s = sorted(blobs, key=radius)
thresh = 3 thresh = 3
@@ -80,14 +80,14 @@ def test_blob_log():
assert abs(b[1] - 350) <= thresh assert abs(b[1] - 350) <= thresh
assert abs(radius(b) - 30) <= thresh assert abs(radius(b) - 30) <= thresh
def test_blob_doh(): def test_blob_doh():
r2 = math.sqrt(2) img = np.ones((512, 512), dtype=np.uint8)
img = np.ones((512, 512), dtype = np.uint8)
xs, ys = circle(400, 130, 20) xs, ys = circle(400, 130, 20)
img[xs, ys] = 255 img[xs, ys] = 255
xs, ys = circle(160, 50, 30) xs, ys = circle(460, 50, 30)
img[xs, ys] = 255 img[xs, ys] = 255
xs, ys = circle(100, 300, 40) xs, ys = circle(100, 300, 40)
@@ -96,9 +96,14 @@ def test_blob_doh():
xs, ys = circle(200, 350, 50) xs, ys = circle(200, 350, 50)
img[xs, ys] = 255 img[xs, ys] = 255
blobs = blob_doh(img, min_sigma=1, max_sigma=60, num_sigma=10) blobs = blob_doh(
img,
min_sigma=1,
max_sigma=60,
num_sigma=10,
threshold=1000)
radius = lambda x: r2*x[2] radius = lambda x: x[2]
s = sorted(blobs, key=radius) s = sorted(blobs, key=radius)
thresh = 3 thresh = 3
@@ -108,7 +113,7 @@ def test_blob_doh():
assert abs(radius(b) - 20) <= thresh assert abs(radius(b) - 20) <= thresh
b = s[1] b = s[1]
assert abs(b[0] - 160) <= thresh assert abs(b[0] - 460) <= thresh
assert abs(b[1] - 50) <= thresh assert abs(b[1] - 50) <= thresh
assert abs(radius(b) - 30) <= thresh assert abs(radius(b) - 30) <= thresh