mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-09 12:30:07 +08:00
66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
from __future__ import division, print_function, absolute_import
|
|
|
|
import os
|
|
|
|
import numpy as np
|
|
from numpy.testing import assert_equal, run_module_suite
|
|
|
|
import skimage
|
|
from skimage import io
|
|
|
|
from skimage.morphology import compute_thin_image
|
|
|
|
|
|
# nose test generators:
|
|
# 2D images
|
|
def test_simple_2d_images():
|
|
for fname in ("strip", "loop", "cross", "two-hole"):
|
|
yield check_skel, fname
|
|
|
|
|
|
# trivial 3D images
|
|
def test_simple_3d():
|
|
for fname in ['3/stack', '4/stack']:
|
|
yield check_skel_3d, fname
|
|
|
|
|
|
# 'slow' test: Bat Cochlea from FIJI collections.
|
|
def test_large():
|
|
for fname in ['bat/bat-cochlea-volume']:
|
|
yield check_skel_3d, fname
|
|
|
|
|
|
def get_data_path():
|
|
# XXX this is a bad temp hack
|
|
return os.path.join(os.path.split(skimage.__file__)[0],
|
|
'morphology',
|
|
'tests',
|
|
'data')
|
|
|
|
|
|
def check_skel(fname):
|
|
# compute the thin image and compare the result to that of ImageJ
|
|
img = np.loadtxt(os.path.join(get_data_path(), fname + '.txt'),
|
|
dtype=np.uint8)
|
|
|
|
# compute
|
|
img1_2d = compute_thin_image(img)
|
|
|
|
# and compare to FIJI
|
|
img_f = np.loadtxt(os.path.join(get_data_path(), fname + '_fiji.txt'),
|
|
dtype=np.uint8)
|
|
|
|
assert_equal(img1_2d, img_f)
|
|
|
|
|
|
def check_skel_3d(fname):
|
|
img = io.imread(os.path.join(get_data_path(), fname + '.tif'))
|
|
img_f = io.imread(os.path.join(get_data_path(), fname + '_fiji.tif'))
|
|
|
|
img_s = compute_thin_image(img)
|
|
assert_equal(img_s, img_f)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_module_suite()
|