Пример #1
0
def test_uint16():
    im16, eroded16, dilated16, opened16, closed16 = map(
        img_as_uint, [im, eroded, dilated, opened, closed])
    cp.testing.assert_allclose(grey.erosion(im16), eroded16)
    cp.testing.assert_allclose(grey.dilation(im16), dilated16)
    cp.testing.assert_allclose(grey.opening(im16), opened16)
    cp.testing.assert_allclose(grey.closing(im16), closed16)
Пример #2
0
def test_2d_ndimage_equivalence():
    image = cp.zeros((9, 9), cp.uint8)
    image[2:-2, 2:-2] = 128
    image[3:-3, 3:-3] = 196
    image[4, 4] = 255

    opened = grey.opening(image)
    closed = grey.closing(image)

    selem = ndi.generate_binary_structure(2, 1)
    ndimage_opened = ndi.grey_opening(image, footprint=selem)
    ndimage_closed = ndi.grey_closing(image, footprint=selem)

    cp.testing.assert_array_equal(opened, ndimage_opened)
    cp.testing.assert_array_equal(closed, ndimage_closed)
Пример #3
0
 def test_close_white_pixel(self):
     for s in self.selems:
         grey_close = grey.closing(self.white_pixel, s)
         assert cp.all(grey_close == self.white_pixel)
Пример #4
0
def test_float():
    cp.testing.assert_allclose(grey.erosion(im), eroded)
    cp.testing.assert_allclose(grey.dilation(im), dilated)
    cp.testing.assert_allclose(grey.opening(im), opened)
    cp.testing.assert_allclose(grey.closing(im), closed)
Пример #5
0
 def test_close_black_pixel(self):
     for s in self.selems:
         assert cp.all(grey.closing(self.black_pixel, s) == 255)
Пример #6
0
def test_binary_closing():
    strel = selem.square(3)
    binary_res = binary.binary_closing(bw_img, strel)
    grey_res = img_as_bool(grey.closing(bw_img, strel))
    testing.assert_array_equal(binary_res, grey_res)