-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test and then discovered kernel wasn't properly constructed
- Loading branch information
Lee Kamentsky
committed
Feb 29, 2016
1 parent
c2aa414
commit 47932f2
Showing
3 changed files
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
import centrosome.kirsch | ||
import skimage.io | ||
import skimage.data | ||
import scipy.misc | ||
import numpy | ||
import numpy as np | ||
import unittest | ||
|
||
|
||
def test_kirsch(): | ||
assert numpy.array_equal(centrosome.kirsch.kirsch(skimage.data.camera()), scipy.misc.imread("tests/resources/kirsch.tiff")) | ||
class TestKirsch(unittest.TestCase): | ||
def test_01_01_kirsch(self): | ||
# | ||
# Test a maximum at all possible orientations | ||
# | ||
r = np.random.RandomState([ord(_) for _ in "kirsch"]) | ||
for coords in (((0, -1), (-1, -1), (-1, 0)), | ||
((-1, -1), (-1, 0), (-1, 1)), | ||
((-1, 0), (-1, 1), (0, 1)), | ||
((-1, 1), ( 0, 1), (1, 1)), | ||
(( 0, 1), ( 1, 1), (1, 0)), | ||
(( 1, 1), ( 1, 0), (1, -1)), | ||
(( 1, 0), ( 1, -1), (0, -1)), | ||
(( 1, -1), ( 0, -1), (-1, -1))): | ||
img = r.uniform(size=(3, 3)) * .1 | ||
expected = -3 * img | ||
for ioff, joff in coords: | ||
img[ioff + 1, joff + 1] += .5 | ||
expected[ioff + 1, joff+1] = img[ioff + 1, joff+1] * 5 | ||
expected[1, 1] = 0 | ||
result = centrosome.kirsch.kirsch(img) | ||
self.assertEqual(result[1, 1], np.sum(expected)) |