• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python peak.peak_local_max函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_trivial_case

 def test_trivial_case(self):
     trivial = np.zeros((25, 25))
     peak_indices = peak.peak_local_max(trivial, min_distance=1, indices=True)
     assert type(peak_indices) is np.ndarray
     assert not peak_indices     # inherent boolean-ness of empty list
     peaks = peak.peak_local_max(trivial, min_distance=1, indices=False)
     assert (peaks.astype(np.bool) == trivial).all()
开发者ID:andreydung,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py


示例2: test_trivial_case

 def test_trivial_case(self):
     trivial = np.zeros((25, 25))
     peak_indices = peak.peak_local_max(trivial, min_distance=1, indices=True)
     assert type(peak_indices) is np.ndarray
     assert peak_indices.size == 0
     peaks = peak.peak_local_max(trivial, min_distance=1, indices=False)
     assert (peaks.astype(np.bool) == trivial).all()
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py


示例3: test_4D

def test_4D():
    image = np.zeros((30, 30, 30, 30))
    image[15, 15, 15, 15] = 1
    image[5, 5, 5, 5] = 1
    assert_equal(peak.peak_local_max(image), [[15, 15, 15, 15]])
    assert_equal(peak.peak_local_max(image, min_distance=6), [[15, 15, 15, 15]])
    assert_equal(peak.peak_local_max(image, exclude_border=False),
                 [[5, 5, 5, 5], [15, 15, 15, 15]])
    assert_equal(peak.peak_local_max(image, min_distance=5),
                 [[5, 5, 5, 5], [15, 15, 15, 15]])
开发者ID:JeanKossaifi,项目名称:scikit-image,代码行数:10,代码来源:test_peak.py


示例4: test_num_peaks

def test_num_peaks():
    image = np.zeros((3, 7), dtype=np.uint8)
    image[1, 1] = 10
    image[1, 3] = 11
    image[1, 5] = 12
    assert len(peak.peak_local_max(image, min_distance=1)) == 3
    peaks_limited = peak.peak_local_max(image, min_distance=1, num_peaks=2)
    assert len(peaks_limited) == 2
    assert (1, 3) in peaks_limited
    assert (1, 5) in peaks_limited
开发者ID:amueller,项目名称:scikit-image,代码行数:10,代码来源:test_peak.py


示例5: test_threshold_rel_default

    def test_threshold_rel_default(self):
        image = np.ones((5, 5))

        image[2, 2] = 1
        assert len(peak.peak_local_max(image)) == 0

        image[2, 2] = 2
        assert_equal(peak.peak_local_max(image), [[2, 2]])

        image[2, 2] = 0
        assert len(peak.peak_local_max(image, min_distance=0)) == image.size - 1
开发者ID:andreydung,项目名称:scikit-image,代码行数:11,代码来源:test_peak.py


示例6: test_sorted_peaks

    def test_sorted_peaks(self):
        image = np.zeros((5, 5), dtype=np.uint8)
        image[1, 1] = 20
        image[3, 3] = 10
        peaks = peak.peak_local_max(image, min_distance=1)
        assert peaks.tolist() == [[3, 3], [1, 1]]

        image = np.zeros((3, 10))
        image[1, (1, 3, 5, 7)] = (1, 3, 2, 4)
        peaks = peak.peak_local_max(image, min_distance=1)
        assert peaks.tolist() == [[1, 7], [1, 5], [1, 3], [1, 1]]
开发者ID:andreydung,项目名称:scikit-image,代码行数:11,代码来源:test_peak.py


示例7: test_disk

def test_disk():
    '''regression test of img-1194, footprint = [1]
    Test peak.peak_local_max when every point is a local maximum
    '''
    image = np.random.uniform(size=(10, 20))
    footprint = np.array([[1]])
    result = peak.peak_local_max(image, labels=np.ones((10, 20)),
                                 footprint=footprint,
                                 min_distance=1, threshold_rel=0,
                                 indices=False, exclude_border=False)
    assert np.all(result)
    result = peak.peak_local_max(image, footprint=footprint)
    assert np.all(result)
开发者ID:JeanKossaifi,项目名称:scikit-image,代码行数:13,代码来源:test_peak.py


示例8: test_3D

def test_3D():
    image = np.zeros((30, 30, 30))
    image[15, 15, 15] = 1
    image[5, 5, 5] = 1
    assert_equal(peak.peak_local_max(image, min_distance=10, threshold_rel=0),
                 [[15, 15, 15]])
    assert_equal(peak.peak_local_max(image, min_distance=6, threshold_rel=0),
                 [[15, 15, 15]])
    assert_equal(peak.peak_local_max(image, min_distance=10, threshold_rel=0,
                                     exclude_border=False),
                 [[5, 5, 5], [15, 15, 15]])
    assert_equal(peak.peak_local_max(image, min_distance=5, threshold_rel=0),
                 [[5, 5, 5], [15, 15, 15]])
开发者ID:akuchibotla,项目名称:scikit-image,代码行数:13,代码来源:test_peak.py


示例9: test_4D

 def test_4D(self):
     image = np.zeros((30, 30, 30, 30))
     image[15, 15, 15, 15] = 1
     image[5, 5, 5, 5] = 1
     assert_equal(peak.peak_local_max(image, min_distance=10, threshold_rel=0),
                  [[15, 15, 15, 15]])
     assert_equal(peak.peak_local_max(image, min_distance=6, threshold_rel=0),
                  [[15, 15, 15, 15]])
     assert sorted(peak.peak_local_max(image, min_distance=10, threshold_rel=0,
                                       exclude_border=False).tolist()) == \
         [[5, 5, 5, 5], [15, 15, 15, 15]]
     assert sorted(peak.peak_local_max(image, min_distance=5,
                                       threshold_rel=0).tolist()) == \
         [[5, 5, 5, 5], [15, 15, 15, 15]]
开发者ID:andreydung,项目名称:scikit-image,代码行数:14,代码来源:test_peak.py


示例10: test_num_peaks_and_labels

 def test_num_peaks_and_labels(self):
     image = np.zeros((7, 7), dtype=np.uint8)
     labels = np.zeros((7, 7), dtype=np.uint8) + 20
     image[1, 1] = 10
     image[1, 3] = 11
     image[1, 5] = 12
     image[3, 5] = 8
     image[5, 3] = 7
     peaks_limited = peak.peak_local_max(
         image, min_distance=1, threshold_abs=0, labels=labels)
     assert len(peaks_limited) == 5
     peaks_limited = peak.peak_local_max(
         image, min_distance=1, threshold_abs=0, labels=labels, num_peaks=2)
     assert len(peaks_limited) == 2
开发者ID:andreydung,项目名称:scikit-image,代码行数:14,代码来源:test_peak.py


示例11: test_adjacent_and_different

 def test_adjacent_and_different(self):
     image = np.zeros((10, 20))
     labels = np.zeros((10, 20), int)
     image[5, 5] = 1
     image[5, 6] = .5
     labels[5, 5:6] = 1
     expected = (image == 1)
     result = peak.peak_local_max(image, labels=labels,
                                  footprint=np.ones((3, 3), bool),
                                  min_distance=1, threshold_rel=0,
                                  indices=False, exclude_border=False)
     assert np.all(result == expected)
     result = peak.peak_local_max(image, labels=labels,
                                  min_distance=1, threshold_rel=0,
                                  indices=False, exclude_border=False)
     assert np.all(result == expected)
开发者ID:andreydung,项目名称:scikit-image,代码行数:16,代码来源:test_peak.py


示例12: test_num_peaks3D

 def test_num_peaks3D(self):
     # Issue 1354: the old code only hold for 2D arrays
     # and this code would die with IndexError
     image = np.zeros((10, 10, 100))
     image[5,5,::5] = np.arange(20)
     peaks_limited = peak.peak_local_max(image, min_distance=1, num_peaks=2)
     assert len(peaks_limited) == 2
开发者ID:andreydung,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py


示例13: test_relative_threshold

 def test_relative_threshold(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     image[1, 1] = 10
     image[3, 3] = 20
     peaks = peak.peak_local_max(image, min_distance=1, threshold_rel=0.5)
     assert len(peaks) == 1
     assert_array_almost_equal(peaks, [(3, 3)])
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py


示例14: test_absolute_threshold

 def test_absolute_threshold(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     image[1, 1] = 10
     image[3, 3] = 20
     peaks = peak.peak_local_max(image, min_distance=1, threshold_abs=10)
     assert len(peaks) == 1
     assert_close(peaks, [(3, 3)])
开发者ID:andreydung,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py


示例15: test_empty

 def test_empty(self):
     image = np.zeros((10, 20))
     labels = np.zeros((10, 20), int)
     result = peak.peak_local_max(image, labels=labels,
                                  footprint=np.ones((3, 3), bool),
                                  min_distance=1, threshold_rel=0,
                                  indices=False, exclude_border=False)
     assert np.all(~ result)
开发者ID:andreydung,项目名称:scikit-image,代码行数:8,代码来源:test_peak.py


示例16: test_ndarray_exclude_border

 def test_ndarray_exclude_border(self):
     nd_image = np.zeros((5, 5, 5))
     nd_image[[1, 0, 0], [0, 1, 0], [0, 0, 1]] = 1
     nd_image[3, 0, 0] = 1
     nd_image[2, 2, 2] = 1
     expected = np.zeros_like(nd_image, dtype=np.bool)
     expected[2, 2, 2] = True
     expectedNoBorder = nd_image > 0
     result = peak.peak_local_max(nd_image, min_distance=2,
         exclude_border=2, indices=False)
     assert_equal(result, expected)
     # Check that bools work as expected
     assert_equal(
         peak.peak_local_max(nd_image, min_distance=2,
             exclude_border=2, indices=False),
         peak.peak_local_max(nd_image, min_distance=2,
             exclude_border=True, indices=False)
         )
     assert_equal(
         peak.peak_local_max(nd_image, min_distance=2,
             exclude_border=0, indices=False),
         peak.peak_local_max(nd_image, min_distance=2,
             exclude_border=False, indices=False)
         )
     # Check both versions with  no border
     assert_equal(
         peak.peak_local_max(nd_image, min_distance=2,
             exclude_border=0, indices=False),
         expectedNoBorder,
         )
     assert_equal(
         peak.peak_local_max(nd_image,
             exclude_border=False, indices=False),
         expectedNoBorder,
         )
开发者ID:andreydung,项目名称:scikit-image,代码行数:35,代码来源:test_peak.py


示例17: test_ndarray_exclude_border

def test_ndarray_exclude_border():
    nd_image = np.zeros((5,5,5))
    nd_image[[1,0,0],[0,1,0],[0,0,1]] = 1
    nd_image[3,0,0] = 1
    nd_image[2,2,2] = 1
    expected = np.zeros_like(nd_image, dtype=np.bool)
    expected[2,2,2] = True
    result = peak.peak_local_max(nd_image, min_distance=2, indices=False)
    assert (result == expected).all()
开发者ID:JeanKossaifi,项目名称:scikit-image,代码行数:9,代码来源:test_peak.py


示例18: test_adjacent_and_same

 def test_adjacent_and_same(self):
     image = np.zeros((10, 20))
     labels = np.zeros((10, 20), int)
     image[5, 5:6] = 1
     labels[5, 5:6] = 1
     result = peak.peak_local_max(image, labels=labels,
                                  footprint=np.ones((3, 3), bool),
                                  min_distance=1, threshold_rel=0,
                                  indices=False, exclude_border=False)
     assert np.all(result == (labels == 1))
开发者ID:andreydung,项目名称:scikit-image,代码行数:10,代码来源:test_peak.py


示例19: test_input_labels_unmodified

 def test_input_labels_unmodified(self):
     image = np.zeros((10, 20))
     labels = np.zeros((10, 20), int)
     image[5, 5] = 1
     labels[5, 5] = 1
     labelsin = labels.copy()
     result = peak.peak_local_max(image, labels=labels,
                                  footprint=np.ones((3, 3), bool),
                                  min_distance=1, threshold_rel=0,
                                  indices=False, exclude_border=False)
     assert np.all(labels == labelsin)
开发者ID:andreydung,项目名称:scikit-image,代码行数:11,代码来源:test_peak.py


示例20: test_num_peaks

 def test_num_peaks(self):
     image = np.zeros((7, 7), dtype=np.uint8)
     image[1, 1] = 10
     image[1, 3] = 11
     image[1, 5] = 12
     image[3, 5] = 8
     image[5, 3] = 7
     assert len(peak.peak_local_max(image, min_distance=1, threshold_abs=0)) == 5
     peaks_limited = peak.peak_local_max(
         image, min_distance=1, threshold_abs=0, num_peaks=2)
     assert len(peaks_limited) == 2
     assert (1, 3) in peaks_limited
     assert (1, 5) in peaks_limited
     peaks_limited = peak.peak_local_max(
         image, min_distance=1, threshold_abs=0, num_peaks=4)
     assert len(peaks_limited) == 4
     assert (1, 3) in peaks_limited
     assert (1, 5) in peaks_limited
     assert (1, 1) in peaks_limited
     assert (3, 5) in peaks_limited
开发者ID:andreydung,项目名称:scikit-image,代码行数:20,代码来源:test_peak.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python filter.canny函数代码示例发布时间:2022-05-27
下一篇:
Python feature.ORB类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap