Esempio n. 1
0
def test_grey_erode():
    from mahotas.tests.pymorph_copy import erode as slow_erode
    from mahotas.tests.pymorph_copy import dilate as slow_dilate
    np.random.seed(334)
    for i in range(8):
        f = np.random.random_sample((128,128))
        f *= 255
        f = f.astype(np.uint8)
        B = (np.random.random_sample((3,3))*255).astype(np.uint8)
        B //= 4
        fast = mahotas.erode(f,B)
        slow = slow_erode(f,B)
        # mahotas & pymorph use different border conventions.
        assert np.all(fast[1:-1,1:-1] == slow[1:-1,1:-1])

        fast = mahotas.dilate(f,B)
        slow = slow_dilate(f,B)
        # mahotas & pymorph use different border conventions.
        assert np.all(fast[1:-1,1:-1] == slow[1:-1,1:-1])
Esempio n. 2
0
def test_grey_erode():
    from mahotas.tests.pymorph_copy import erode as slow_erode
    from mahotas.tests.pymorph_copy import dilate as slow_dilate
    np.random.seed(334)
    for i in range(8):
        f = np.random.random_sample((128, 128))
        f *= 255
        f = f.astype(np.uint8)
        B = (np.random.random_sample((3, 3)) * 255).astype(np.uint8)
        B //= 4
        fast = mahotas.erode(f, B)
        slow = slow_erode(f, B)
        # mahotas & pymorph use different border conventions.
        assert np.all(fast[1:-1, 1:-1] == slow[1:-1, 1:-1])

        fast = mahotas.dilate(f, B)
        slow = slow_dilate(f, B)
        # mahotas & pymorph use different border conventions.
        assert np.all(fast[1:-1, 1:-1] == slow[1:-1, 1:-1])