mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 16:16:07 +08:00
Move test functions to test class
This commit is contained in:
@@ -63,46 +63,47 @@ class TestMorphology():
|
||||
greyscale_close, disk)
|
||||
|
||||
|
||||
BLACK_PIXEL = 255 * np.ones((4, 4), dtype=np.uint8)
|
||||
BLACK_PIXEL[1, 1] = 0
|
||||
WHITE_PIXEL = 255 - BLACK_PIXEL
|
||||
SELEM = square(2)
|
||||
class TestEccentricStructuringElements():
|
||||
|
||||
def test_dilate_erode_symmetry():
|
||||
c = greyscale_erode(BLACK_PIXEL, SELEM)
|
||||
d = greyscale_dilate(WHITE_PIXEL, SELEM)
|
||||
assert np.all(c == (255 - d))
|
||||
|
||||
|
||||
def test_open_dark_pixel():
|
||||
assert np.all(greyscale_open(BLACK_PIXEL, SELEM) == BLACK_PIXEL)
|
||||
|
||||
def test_close_white_pixel():
|
||||
assert np.all(greyscale_close(WHITE_PIXEL, SELEM) == WHITE_PIXEL)
|
||||
|
||||
|
||||
def test_open_white_pixel():
|
||||
assert np.all(greyscale_open(WHITE_PIXEL, SELEM) == 0)
|
||||
|
||||
def test_close_dark_pixel():
|
||||
assert np.all(greyscale_close(BLACK_PIXEL, SELEM) == 255)
|
||||
|
||||
|
||||
def test_white_tophat_white_pixel():
|
||||
tophat = greyscale_white_top_hat(WHITE_PIXEL, SELEM)
|
||||
assert np.all(tophat == WHITE_PIXEL)
|
||||
|
||||
def test_black_tophat_black_pixel():
|
||||
tophat = greyscale_black_top_hat(BLACK_PIXEL, SELEM)
|
||||
assert np.all(tophat == (255 - BLACK_PIXEL))
|
||||
|
||||
|
||||
def test_white_tophat_black_pixel():
|
||||
tophat = greyscale_white_top_hat(BLACK_PIXEL, SELEM)
|
||||
assert np.all(tophat == 0)
|
||||
|
||||
def test_black_tophat_white_pixel():
|
||||
tophat = greyscale_black_top_hat(WHITE_PIXEL, SELEM)
|
||||
assert np.all(tophat == 0)
|
||||
def setUp(self):
|
||||
self.black_pixel = 255 * np.ones((4, 4), dtype=np.uint8)
|
||||
self.black_pixel[1, 1] = 0
|
||||
self.white_pixel = 255 - self.black_pixel
|
||||
self.selem = square(2)
|
||||
|
||||
def test_dilate_erode_symmetry(self):
|
||||
c = greyscale_erode(self.black_pixel, self.selem)
|
||||
d = greyscale_dilate(self.white_pixel, self.selem)
|
||||
assert np.all(c == (255 - d))
|
||||
|
||||
def test_open_dark_pixel(self):
|
||||
grey_open = greyscale_open(self.black_pixel, self.selem)
|
||||
assert np.all(grey_open == self.black_pixel)
|
||||
|
||||
def test_close_white_pixel(self):
|
||||
grey_close = greyscale_close(self.white_pixel, self.selem)
|
||||
assert np.all(grey_close == self.white_pixel)
|
||||
|
||||
def test_open_white_pixel(self):
|
||||
assert np.all(greyscale_open(self.white_pixel, self.selem) == 0)
|
||||
|
||||
def test_close_dark_pixel(self):
|
||||
assert np.all(greyscale_close(self.black_pixel, self.selem) == 255)
|
||||
|
||||
def test_white_tophat_white_pixel(self):
|
||||
tophat = greyscale_white_top_hat(self.white_pixel, self.selem)
|
||||
assert np.all(tophat == self.white_pixel)
|
||||
|
||||
def test_black_tophat_black_pixel(self):
|
||||
tophat = greyscale_black_top_hat(self.black_pixel, self.selem)
|
||||
assert np.all(tophat == (255 - self.black_pixel))
|
||||
|
||||
def test_white_tophat_black_pixel(self):
|
||||
tophat = greyscale_white_top_hat(self.black_pixel, self.selem)
|
||||
assert np.all(tophat == 0)
|
||||
|
||||
def test_black_tophat_white_pixel(self):
|
||||
tophat = greyscale_black_top_hat(self.white_pixel, self.selem)
|
||||
assert np.all(tophat == 0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user