mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-03 13:11:25 +08:00
improved test coverage
This commit is contained in:
@@ -2,11 +2,13 @@ import numpy as np
|
||||
from skimage.draw import circle
|
||||
from skimage.feature import blob_dog, blob_log, blob_doh
|
||||
import math
|
||||
from numpy.testing import assert_raises
|
||||
|
||||
|
||||
def test_blob_dog():
|
||||
r2 = math.sqrt(2)
|
||||
img = np.ones((512, 512))
|
||||
img3 = np.ones((5, 5, 5))
|
||||
|
||||
xs, ys = circle(400, 130, 5)
|
||||
img[xs, ys] = 255
|
||||
@@ -37,10 +39,13 @@ def test_blob_dog():
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(radius(b) - 45) <= thresh
|
||||
|
||||
assert_raises(ValueError, blob_dog, img3)
|
||||
|
||||
|
||||
def test_blob_log():
|
||||
r2 = math.sqrt(2)
|
||||
img = np.ones((512, 512))
|
||||
img3 = np.ones((5, 5, 5))
|
||||
|
||||
xs, ys = circle(400, 130, 5)
|
||||
img[xs, ys] = 255
|
||||
@@ -80,9 +85,40 @@ def test_blob_log():
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(radius(b) - 30) <= thresh
|
||||
|
||||
# Testing log scale
|
||||
blobs = blob_log(
|
||||
img,
|
||||
min_sigma=5,
|
||||
max_sigma=20,
|
||||
threshold=1,
|
||||
log_scale=True)
|
||||
|
||||
b = s[0]
|
||||
assert abs(b[0] - 400) <= thresh
|
||||
assert abs(b[1] - 130) <= thresh
|
||||
assert abs(radius(b) - 5) <= thresh
|
||||
|
||||
b = s[1]
|
||||
assert abs(b[0] - 160) <= thresh
|
||||
assert abs(b[1] - 50) <= thresh
|
||||
assert abs(radius(b) - 15) <= thresh
|
||||
|
||||
b = s[2]
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 300) <= thresh
|
||||
assert abs(radius(b) - 25) <= thresh
|
||||
|
||||
b = s[3]
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(radius(b) - 30) <= thresh
|
||||
|
||||
assert_raises(ValueError, blob_log, img3)
|
||||
|
||||
|
||||
def test_blob_doh():
|
||||
img = np.ones((512, 512), dtype=np.uint8)
|
||||
img3 = np.ones((5, 5, 5))
|
||||
|
||||
xs, ys = circle(400, 130, 20)
|
||||
img[xs, ys] = 255
|
||||
@@ -126,3 +162,53 @@ def test_blob_doh():
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(radius(b) - 50) <= thresh
|
||||
|
||||
# Testing log scale
|
||||
blobs = blob_doh(
|
||||
img,
|
||||
min_sigma=1,
|
||||
max_sigma=60,
|
||||
num_sigma=10,
|
||||
log_scale=True,
|
||||
threshold=.05)
|
||||
|
||||
b = s[0]
|
||||
assert abs(b[0] - 400) <= thresh
|
||||
assert abs(b[1] - 130) <= thresh
|
||||
assert abs(radius(b) - 20) <= thresh
|
||||
|
||||
b = s[1]
|
||||
assert abs(b[0] - 460) <= thresh
|
||||
assert abs(b[1] - 50) <= thresh
|
||||
assert abs(radius(b) - 30) <= thresh
|
||||
|
||||
b = s[2]
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 300) <= thresh
|
||||
assert abs(radius(b) - 40) <= thresh
|
||||
|
||||
b = s[3]
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(radius(b) - 50) <= thresh
|
||||
|
||||
assert_raises(ValueError, blob_doh, img3)
|
||||
|
||||
|
||||
def test_blob_overlap():
|
||||
img = np.ones((512, 512), dtype=np.uint8)
|
||||
|
||||
xs, ys = circle(100, 100, 20)
|
||||
img[xs, ys] = 255
|
||||
|
||||
xs, ys = circle(120, 100, 30)
|
||||
img[xs, ys] = 255
|
||||
|
||||
blobs = blob_doh(
|
||||
img,
|
||||
min_sigma=1,
|
||||
max_sigma=60,
|
||||
num_sigma=10,
|
||||
threshold=.05)
|
||||
|
||||
assert len(blobs) == 1
|
||||
|
||||
Reference in New Issue
Block a user