mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-13 17:45:20 +08:00
Binary file not shown.
|
Before Width: | Height: | Size: 887 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
@@ -44,19 +44,19 @@ def test_blob_dog():
|
||||
|
||||
def test_blob_log():
|
||||
r2 = math.sqrt(2)
|
||||
img = np.ones((512, 512))
|
||||
img = np.ones((256, 256))
|
||||
img3 = np.ones((5, 5, 5))
|
||||
|
||||
xs, ys = circle(400, 130, 5)
|
||||
xs, ys = circle(200, 65, 5)
|
||||
img[xs, ys] = 255
|
||||
|
||||
xs, ys = circle(160, 50, 15)
|
||||
xs, ys = circle(80, 25, 15)
|
||||
img[xs, ys] = 255
|
||||
|
||||
xs, ys = circle(100, 300, 25)
|
||||
xs, ys = circle(50, 150, 25)
|
||||
img[xs, ys] = 255
|
||||
|
||||
xs, ys = circle(200, 350, 30)
|
||||
xs, ys = circle(100, 175, 30)
|
||||
img[xs, ys] = 255
|
||||
|
||||
blobs = blob_log(img, min_sigma=5, max_sigma=20, threshold=1)
|
||||
@@ -66,23 +66,23 @@ def test_blob_log():
|
||||
thresh = 3
|
||||
|
||||
b = s[0]
|
||||
assert abs(b[0] - 400) <= thresh
|
||||
assert abs(b[1] - 130) <= thresh
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 65) <= thresh
|
||||
assert abs(radius(b) - 5) <= thresh
|
||||
|
||||
b = s[1]
|
||||
assert abs(b[0] - 160) <= thresh
|
||||
assert abs(b[1] - 50) <= thresh
|
||||
assert abs(b[0] - 80) <= thresh
|
||||
assert abs(b[1] - 25) <= thresh
|
||||
assert abs(radius(b) - 15) <= thresh
|
||||
|
||||
b = s[2]
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 300) <= thresh
|
||||
assert abs(b[0] - 50) <= thresh
|
||||
assert abs(b[1] - 150) <= thresh
|
||||
assert abs(radius(b) - 25) <= thresh
|
||||
|
||||
b = s[3]
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 175) <= thresh
|
||||
assert abs(radius(b) - 30) <= thresh
|
||||
|
||||
# Testing log scale
|
||||
@@ -94,23 +94,23 @@ def test_blob_log():
|
||||
log_scale=True)
|
||||
|
||||
b = s[0]
|
||||
assert abs(b[0] - 400) <= thresh
|
||||
assert abs(b[1] - 130) <= thresh
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 65) <= thresh
|
||||
assert abs(radius(b) - 5) <= thresh
|
||||
|
||||
b = s[1]
|
||||
assert abs(b[0] - 160) <= thresh
|
||||
assert abs(b[1] - 50) <= thresh
|
||||
assert abs(b[0] - 80) <= thresh
|
||||
assert abs(b[1] - 25) <= thresh
|
||||
assert abs(radius(b) - 15) <= thresh
|
||||
|
||||
b = s[2]
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 300) <= thresh
|
||||
assert abs(b[0] - 50) <= thresh
|
||||
assert abs(b[1] - 150) <= thresh
|
||||
assert abs(radius(b) - 25) <= thresh
|
||||
|
||||
b = s[3]
|
||||
assert abs(b[0] - 200) <= thresh
|
||||
assert abs(b[1] - 350) <= thresh
|
||||
assert abs(b[0] - 100) <= thresh
|
||||
assert abs(b[1] - 175) <= thresh
|
||||
assert abs(radius(b) - 30) <= thresh
|
||||
|
||||
assert_raises(ValueError, blob_log, img3)
|
||||
|
||||
@@ -3,6 +3,7 @@ from numpy.testing import assert_array_equal, assert_raises
|
||||
from skimage.data import moon
|
||||
from skimage.feature import CENSURE
|
||||
from skimage._shared.testing import test_parallel
|
||||
from skimage.transform import rescale
|
||||
|
||||
|
||||
img = moon()
|
||||
@@ -60,14 +61,14 @@ def test_keypoints_censure_moon_image_octagon():
|
||||
the expected values for Octagon filter."""
|
||||
|
||||
detector = CENSURE(mode='octagon')
|
||||
detector.detect(img)
|
||||
expected_keypoints = np.array([[ 21, 496],
|
||||
[ 35, 46],
|
||||
[287, 250],
|
||||
[356, 239],
|
||||
[463, 116]])
|
||||
detector.detect(rescale(img, 0.25)) # quarter scale image for speed
|
||||
expected_keypoints = np.array([[ 23, 27],
|
||||
[ 29, 89],
|
||||
[ 31, 87],
|
||||
[106, 59],
|
||||
[111, 67]])
|
||||
|
||||
expected_scales = np.array([3, 4, 2, 2, 2])
|
||||
expected_scales = np.array([3, 2, 5, 2, 4])
|
||||
|
||||
assert_array_equal(expected_keypoints, detector.keypoints)
|
||||
assert_array_equal(expected_scales, detector.scales)
|
||||
@@ -77,19 +78,16 @@ def test_keypoints_censure_moon_image_star():
|
||||
"""Verify the actual Censure keypoints and their corresponding scale with
|
||||
the expected values for STAR filter."""
|
||||
detector = CENSURE(mode='star')
|
||||
detector.detect(img)
|
||||
expected_keypoints = np.array([[ 21, 497],
|
||||
[ 36, 46],
|
||||
[117, 356],
|
||||
[185, 177],
|
||||
[260, 227],
|
||||
[287, 250],
|
||||
[357, 239],
|
||||
[451, 281],
|
||||
[463, 116],
|
||||
[467, 260]])
|
||||
detector.detect(rescale(img, 0.25)) # quarter scale image for speed
|
||||
expected_keypoints = np.array([[ 23, 27],
|
||||
[ 29, 89],
|
||||
[ 30, 86],
|
||||
[107, 59],
|
||||
[109, 64],
|
||||
[111, 67],
|
||||
[113, 70]])
|
||||
|
||||
expected_scales = np.array([3, 3, 6, 2, 3, 2, 3, 5, 2, 2])
|
||||
expected_scales = np.array([3, 2, 4, 2, 5, 3, 2])
|
||||
|
||||
assert_array_equal(expected_keypoints, detector.keypoints)
|
||||
assert_array_equal(expected_scales, detector.scales)
|
||||
|
||||
@@ -282,7 +282,7 @@ def test_compare_8bit_unsigned_vs_signed():
|
||||
# of dynamic) should be identical
|
||||
|
||||
# Create signed int8 image that and convert it to uint8
|
||||
image = img_as_ubyte(data.camera())
|
||||
image = img_as_ubyte(data.camera())[::2, ::2]
|
||||
image[image > 127] = 0
|
||||
image_s = image.astype(np.int8)
|
||||
with expected_warnings(['sign loss', 'precision loss']):
|
||||
@@ -306,7 +306,7 @@ def test_compare_8bit_vs_16bit():
|
||||
# filters applied on 8-bit image ore 16-bit image (having only real 8-bit
|
||||
# of dynamic) should be identical
|
||||
|
||||
image8 = util.img_as_ubyte(data.camera())
|
||||
image8 = util.img_as_ubyte(data.camera())[::2, ::2]
|
||||
image16 = image8.astype(np.uint16)
|
||||
assert_equal(image8, image16)
|
||||
|
||||
@@ -486,8 +486,8 @@ def test_entropy():
|
||||
|
||||
# 12 bit per pixel
|
||||
selem = np.ones((64, 64), dtype=np.uint8)
|
||||
data = np.tile(
|
||||
np.reshape(np.arange(4096), (64, 64)), (2, 2)).astype(np.uint16)
|
||||
data = np.zeros((65, 65), dtype=np.uint16)
|
||||
data[:64, :64] = np.reshape(np.arange(4096), (64, 64))
|
||||
with expected_warnings(['Bitdepth of 11']):
|
||||
assert(np.max(rank.entropy(data, selem)) == 12)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestMultiImage():
|
||||
# convert im1.tif im2.tif -adjoin multipage.tif
|
||||
use_plugin('pil')
|
||||
paths = [os.path.join(data_dir, 'multipage_rgb.tif'),
|
||||
os.path.join(data_dir, 'no_time_for_that.gif')]
|
||||
os.path.join(data_dir, 'no_time_for_that_tiny.gif')]
|
||||
self.imgs = [MultiImage(paths[0]),
|
||||
MultiImage(paths[0], conserve_memory=False),
|
||||
MultiImage(paths[1]),
|
||||
|
||||
@@ -191,11 +191,11 @@ def test_all_mono():
|
||||
|
||||
|
||||
def test_multi_page_gif():
|
||||
img = imread(os.path.join(data_dir, 'no_time_for_that.gif'))
|
||||
assert img.shape == (24, 280, 500, 3), img.shape
|
||||
img2 = imread(os.path.join(data_dir, 'no_time_for_that.gif'),
|
||||
img = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'))
|
||||
assert img.shape == (24, 25, 14, 3), img.shape
|
||||
img2 = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'),
|
||||
img_num=5)
|
||||
assert img2.shape == (280, 500, 3)
|
||||
assert img2.shape == (25, 14, 3)
|
||||
assert_allclose(img[5], img2)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user