Regression tests written for morphology

This commit is contained in:
Damian Eads
2009-11-18 22:59:34 -08:00
parent 8a590bdd6a
commit f7f294ccf1
17 changed files with 97 additions and 2 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,52 @@
import os.path
import numpy as np
from numpy.testing import *
from scikits.image import data_dir
from scikits.image.io import imread
from scikits.image import data_dir
from scikits.image.morphology import *
lena = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy'))
class TestMorphology():
def morph_worker(self, img, fn, morph_func, strel_func):
matlab_results = np.load(os.path.join(data_dir, fn))
k = 0
for expected_result in matlab_results:
mask = strel_func(k)
actual_result = morph_func(lena, mask)
assert_equal(expected_result, actual_result)
k = k + 1
def test_erode_diamond(self):
self.morph_worker(lena, "diamond-erode-matlab-output.npy", greyscale_erode, diamond)
def test_dilate_diamond(self):
self.morph_worker(lena, "diamond-dilate-matlab-output.npy", greyscale_dilate, diamond)
def test_open_diamond(self):
self.morph_worker(lena, "diamond-open-matlab-output.npy", greyscale_open, diamond)
def test_close_diamond(self):
self.morph_worker(lena, "diamond-close-matlab-output.npy", greyscale_close, diamond)
def test_tophat_diamond(self):
self.morph_worker(lena, "diamond-tophat-matlab-output.npy", greyscale_white_top_hat, diamond)
def test_bothat_diamond(self):
self.morph_worker(lena, "diamond-bothat-matlab-output.npy", greyscale_black_top_hat, diamond)
def test_erode_disk(self):
self.morph_worker(lena, "disk-erode-matlab-output.npy", greyscale_erode, disk)
def test_dilate_disk(self):
self.morph_worker(lena, "disk-dilate-matlab-output.npy", greyscale_dilate, disk)
def test_open_disk(self):
self.morph_worker(lena, "disk-open-matlab-output.npy", greyscale_open, disk)
def test_close_disk(self):
self.morph_worker(lena, "disk-close-matlab-output.npy", greyscale_close, disk)
@@ -0,0 +1,43 @@
# Author: Damian Eads
import os.path
import numpy as np
from numpy.testing import *
from scikits.image import data_dir
from scikits.image.io import *
from scikits.image import data_dir
from scikits.image.morphology import *
class TestSElem():
def test_square_selem(self):
for k in xrange(0, 5):
actual_mask = selem.square(k)
expected_mask = np.ones((k, k), dtype='uint8')
assert_equal(expected_mask, actual_mask)
def test_rectangle_selem(self):
for i in xrange(0, 5):
for j in xrange(0, 5):
actual_mask = selem.rectangle(i, j)
expected_mask = np.ones((i, j), dtype='uint8')
assert_equal(expected_mask, actual_mask)
def strel_worker(self, fn, func):
matlab_masks = np.load(os.path.join(data_dir, fn))
k = 0
for expected_mask in matlab_masks:
actual_mask = func(k)
if (expected_mask.shape == (1,)):
expected_mask = expected_mask[:,np.newaxis]
assert_equal(expected_mask, actual_mask)
k = k + 1
def test_selem_disk(self):
self.strel_worker("disk-matlab-output.npy", selem.disk)
def test_selem_diamond(self):
self.strel_worker("diamond-matlab-output.npy", selem.diamond)
+2 -2
View File
@@ -1,2 +1,2 @@
# THIS FILE IS GENERATED FROM THE SCIKITS.IMAGE SETUP.PY
version='0.2dev'
version='unbuilt-dev'