当前位置: 首页>>代码示例>>Python>>正文


Python watershed.watershed函数代码示例

本文整理汇总了Python中skimage.morphology.watershed.watershed函数的典型用法代码示例。如果您正苦于以下问题:Python watershed函数的具体用法?Python watershed怎么用?Python watershed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了watershed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_watershed06

 def test_watershed06(self):
     "watershed 6"
     data = np.array([[0, 1, 0, 0, 0, 1, 0],
                      [0, 1, 0, 0, 0, 1, 0],
                      [0, 1, 0, 0, 0, 1, 0],
                      [0, 1, 1, 1, 1, 1, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0]], np.uint8)
     markers = np.array([[0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 1, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [-1, 0, 0, 0, 0, 0, 0]], np.int8)
     out = watershed(data, markers, self.eight)
     error = diff([[-1,  1,  1,  1,  1,  1, -1],
                   [-1,  1,  1,  1,  1,  1, -1],
                   [-1,  1,  1,  1,  1,  1, -1],
                   [-1,  1,  1,  1,  1,  1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1]], out)
     self.failUnless(error < eps)
开发者ID:ChrisBeaumont,项目名称:scikit-image,代码行数:31,代码来源:test_watershed.py

示例2: test_watershed03

 def test_watershed03(self):
     "watershed 3"
     data = np.array([[0, 0, 0, 0, 0, 0, 0],
                      [0, 1, 1, 1, 1, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 1, 1, 1, 1, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0]], np.uint8)
     markers = np.array([[0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 2, 0, 3, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, -1]], np.int8)
     out = watershed(data, markers)
     error = diff([[-1, -1, -1, -1, -1, -1, -1],
                   [-1,  0,  2,  0,  3,  0, -1],
                   [-1,  2,  2,  0,  3,  3, -1],
                   [-1,  2,  2,  0,  3,  3, -1],
                   [-1,  2,  2,  0,  3,  3, -1],
                   [-1,  0,  2,  0,  3,  0, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1]], out)
     self.failUnless(error < eps)
开发者ID:ChrisBeaumont,项目名称:scikit-image,代码行数:34,代码来源:test_watershed.py

示例3: test_watershed05

 def test_watershed05(self):
     "watershed 5"
     data = np.array([[0, 0, 0, 0, 0, 0, 0],
                      [0, 1, 1, 1, 1, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 0, 1, 0, 1, 0],
                      [0, 1, 1, 1, 1, 1, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 0, 0, 0, 0]], np.uint8)
     markers = np.array([[0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 3, 0, 2, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, -1]], np.int8)
     out = watershed(data, markers, self.eight)
     error = diff([[-1, -1, -1, -1, -1, -1, -1],
                   [-1,  3,  3,  0,  2,  2, -1],
                   [-1,  3,  3,  0,  2,  2, -1],
                   [-1,  3,  3,  0,  2,  2, -1],
                   [-1,  3,  3,  0,  2,  2, -1],
                   [-1,  3,  3,  0,  2,  2, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1],
                   [-1, -1, -1, -1, -1, -1, -1]], out)
     self.assertTrue(error < eps)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:34,代码来源:test_watershed.py

示例4: test_watershed07

 def test_watershed07(self):
     "A regression test of a competitive case that failed"
     data = np.array([[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255],
                      [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255],
                      [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255],
                      [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255],
                      [255,255,204,153,111, 72, 39,  1, 1, 39, 72,111,153,204,255,255],
                      [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255],
                      [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255],
                      [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255],
                      [255,255,255,255,255,204,153,103,103,153,204,255,255,255,255,255],
                      [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255],
                      [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255],
                      [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255],
                      [255,255,204,153,111, 72, 39,  1,  1, 39, 72,111,153,204,255,255],
                      [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255],
                      [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255],
                      [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255],
                      [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]])
     mask = (data != 255)
     markers = np.zeros(data.shape, int)
     markers[6, 7] = 1
     markers[14, 7] = 2
     out = watershed(data, markers, self.eight, mask=mask)
     #
     # The two objects should be the same size, except possibly for the
     # border region
     #
     size1 = np.sum(out == 1)
     size2 = np.sum(out == 2)
     self.assertTrue(abs(size1 - size2) <= 6)
开发者ID:ChrisBeaumont,项目名称:scikit-image,代码行数:35,代码来源:test_watershed.py

示例5: test_watershed08

 def test_watershed08(self):
     "The border pixels + an edge are all the same value"
     data = np.array([[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255],
                      [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255],
                      [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255],
                      [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255],
                      [255,255,204,153,111, 72, 39,  1,  1, 39, 72,111,153,204,255,255],
                      [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255],
                      [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255],
                      [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255],
                      [255,255,255,255,255,204,153,141,141,153,204,255,255,255,255,255],
                      [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255],
                      [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255],
                      [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255],
                      [255,255,204,153,111, 72, 39,  1,  1, 39, 72,111,153,204,255,255],
                      [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255],
                      [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255],
                      [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255],
                      [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
                      [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]])
     mask = (data != 255)
     markers = np.zeros(data.shape, int)
     markers[6, 7] = 1
     markers[14, 7] = 2
     out = watershed(data, markers, self.eight, mask=mask)
     #
     # The two objects should be the same size, except possibly for the
     # border region
     #
     size1 = np.sum(out == 1)
     size2 = np.sum(out == 2)
     self.assertTrue(abs(size1 - size2) <= 6)
开发者ID:ChrisBeaumont,项目名称:scikit-image,代码行数:35,代码来源:test_watershed.py

示例6: test_compact_watershed

def test_compact_watershed():
    image = np.zeros((5, 6))
    image[:, 3:] = 1
    seeds = np.zeros((5, 6), dtype=int)
    seeds[2, 0] = 1
    seeds[2, 3] = 2
    compact = watershed(image, seeds, compactness=0.01)
    expected = np.array([[1, 1, 1, 2, 2, 2],
                         [1, 1, 1, 2, 2, 2],
                         [1, 1, 1, 2, 2, 2],
                         [1, 1, 1, 2, 2, 2],
                         [1, 1, 1, 2, 2, 2]], dtype=int)
    np.testing.assert_equal(compact, expected)
    normal = watershed(image, seeds)
    expected = np.ones(image.shape, dtype=int)
    expected[2, 3:] = 2
    np.testing.assert_equal(normal, expected)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:17,代码来源:test_watershed.py

示例7: test_watershed09

    def test_watershed09(self):
        """Test on an image of reasonable size

        This is here both for timing (does it take forever?) and to
        ensure that the memory constraints are reasonable
        """
        image = np.zeros((1000, 1000))
        coords = np.random.uniform(0, 1000, (100, 2)).astype(int)
        markers = np.zeros((1000, 1000), int)
        idx = 1
        for x, y in coords:
            image[x, y] = 1
            markers[x, y] = idx
            idx += 1

        image = ndi.gaussian_filter(image, 4)
        watershed(image, markers, self.eight)
        ndi.watershed_ift(image.astype(np.uint16), markers, self.eight)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:18,代码来源:test_watershed.py

示例8: test_numeric_seed_watershed

def test_numeric_seed_watershed():
    """Test that passing just the number of seeds to watershed works."""
    image = np.zeros((5, 6))
    image[:, 3:] = 1
    compact = watershed(image, 2, compactness=0.01)
    expected = np.array([[1, 1, 1, 1, 2, 2],
                         [1, 1, 1, 1, 2, 2],
                         [1, 1, 1, 1, 2, 2],
                         [1, 1, 1, 1, 2, 2],
                         [1, 1, 1, 1, 2, 2]], dtype=np.int32)
    np.testing.assert_equal(compact, expected)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:11,代码来源:test_watershed.py

示例9: test_watershed01

 def test_watershed01(self):
     "watershed 1"
     data = np.array(
         [
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
         ],
         np.uint8,
     )
     markers = np.array(
         [
             [-1, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
         ],
         np.int8,
     )
     out = watershed(data, markers, self.eight)
     expected = np.array(
         [
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
         ]
     )
     error = diff(expected, out)
     assert error < eps
     out = _slow_watershed(data, markers, 8)
     error = diff(expected, out)
     assert error < eps
开发者ID:neurodebian,项目名称:scikits.image-1,代码行数:52,代码来源:test_watershed.py

示例10: test_watershed02

 def test_watershed02(self):
     "watershed 2"
     data = np.array(
         [
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 0, 0, 0, 1, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
         ],
         np.uint8,
     )
     markers = np.array(
         [
             [-1, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
         ],
         np.int8,
     )
     out = watershed(data, markers)
     error = diff(
         [
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, 1, 1, 1, -1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, 1, 1, 1, 1, 1, -1],
             [-1, -1, 1, 1, 1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
         ],
         out,
     )
     self.failUnless(error < eps)
开发者ID:neurodebian,项目名称:scikits.image-1,代码行数:52,代码来源:test_watershed.py

示例11: test_watershed05

 def test_watershed05(self):
     "watershed 5"
     data = np.array(
         [
             [0, 0, 0, 0, 0, 0, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 1, 0, 1, 0, 1, 0],
             [0, 1, 0, 1, 0, 1, 0],
             [0, 1, 0, 1, 0, 1, 0],
             [0, 1, 1, 1, 1, 1, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
         ],
         np.uint8,
     )
     markers = np.array(
         [
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 3, 0, 2, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, -1],
         ],
         np.int8,
     )
     out = watershed(data, markers, self.eight)
     error = diff(
         [
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, 3, 3, 0, 2, 2, -1],
             [-1, 3, 3, 0, 2, 2, -1],
             [-1, 3, 3, 0, 2, 2, -1],
             [-1, 3, 3, 0, 2, 2, -1],
             [-1, 3, 3, 0, 2, 2, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
             [-1, -1, -1, -1, -1, -1, -1],
         ],
         out,
     )
     self.failUnless(error < eps)
开发者ID:neurodebian,项目名称:scikits.image-1,代码行数:49,代码来源:test_watershed.py

示例12: test_watershed07

 def test_watershed07(self):
     "A regression test of a competitive case that failed"
     data = blob
     mask = (data != 255)
     markers = np.zeros(data.shape, int)
     markers[6, 7] = 1
     markers[14, 7] = 2
     out = watershed(data, markers, self.eight, mask=mask)
     #
     # The two objects should be the same size, except possibly for the
     # border region
     #
     size1 = np.sum(out == 1)
     size2 = np.sum(out == 2)
     self.assertTrue(abs(size1 - size2) <= 6)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:15,代码来源:test_watershed.py

示例13: test_watershed08

 def test_watershed08(self):
     "The border pixels + an edge are all the same value"
     data = blob.copy()
     data[10, 7:9] = 141
     mask = (data != 255)
     markers = np.zeros(data.shape, int)
     markers[6, 7] = 1
     markers[14, 7] = 2
     out = watershed(data, markers, self.eight, mask=mask)
     #
     # The two objects should be the same size, except possibly for the
     # border region
     #
     size1 = np.sum(out == 1)
     size2 = np.sum(out == 2)
     self.assertTrue(abs(size1 - size2) <= 6)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:16,代码来源:test_watershed.py

示例14: test_watershed10

 def test_watershed10(self):
     "watershed 10"
     data = np.array([[1, 1, 1, 1],
                      [1, 1, 1, 1],
                      [1, 1, 1, 1],
                      [1, 1, 1, 1]], np.uint8)
     markers = np.array([[1, 0, 0, 2],
                         [0, 0, 0, 0],
                         [0, 0, 0, 0],
                         [3, 0, 0, 4]], np.int8)
     out = watershed(data, markers, self.eight)
     error = diff([[1, 1, 2, 2],
                   [1, 1, 2, 2],
                   [3, 3, 4, 4],
                   [3, 3, 4, 4]], out)
     self.assertTrue(error < eps)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:16,代码来源:test_watershed.py

示例15: test_watershed12

 def test_watershed12(self):
     "The watershed line"
     data = np.array([[203, 255, 203, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153],
                      [203, 255, 203, 153, 153, 153, 102, 102, 102, 102, 102, 102, 153, 153, 153, 153],
                      [203, 255, 203, 203, 153, 153, 102, 102,  77,   0, 102, 102, 153, 153, 203, 203],
                      [203, 255, 255, 203, 153, 153, 153, 102, 102, 102, 102, 153, 153, 203, 203, 255],
                      [203, 203, 255, 203, 203, 203, 153, 153, 153, 153, 153, 153, 203, 203, 255, 255],
                      [153, 203, 255, 255, 255, 203, 203, 203, 203, 203, 203, 203, 203, 255, 255, 203],
                      [153, 203, 203, 203, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 203, 203],
                      [153, 153, 153, 203, 203, 203, 203, 203, 255, 203, 203, 203, 203, 203, 203, 153],
                      [102, 102, 153, 153, 153, 153, 203, 203, 255, 203, 203, 255, 203, 153, 153, 153],
                      [102, 102, 102, 102, 102, 153, 203, 255, 255, 203, 203, 203, 203, 153, 102, 153],
                      [102,  51,  51, 102, 102, 153, 203, 255, 203, 203, 153, 153, 153, 153, 102, 153],
                      [ 77,  51,  51, 102, 153, 153, 203, 255, 203, 203, 203, 153, 102, 102, 102, 153],
                      [ 77,   0,  51, 102, 153, 203, 203, 255, 203, 255, 203, 153, 102,  51, 102, 153],
                      [ 77,   0,  51, 102, 153, 203, 255, 255, 203, 203, 203, 153, 102,   0, 102, 153],
                      [102,   0,  51, 102, 153, 203, 255, 203, 203, 153, 153, 153, 102, 102, 102, 153],
                      [102, 102, 102, 102, 153, 203, 255, 203, 153, 153, 153, 153, 153, 153, 153, 153]])
     markerbin = (data==0)
     marker = label(markerbin)
     ws = watershed(data, marker, connectivity=2, watershed_line=True)
     for lab, area in zip(range(4), [34,74,74,74]):
         self.assertTrue(np.sum(ws == lab) == area)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:23,代码来源:test_watershed.py


注:本文中的skimage.morphology.watershed.watershed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。