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


Python ndimage.center_of_mass方法代码示例

本文整理汇总了Python中scipy.ndimage.center_of_mass方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.center_of_mass方法的具体用法?Python ndimage.center_of_mass怎么用?Python ndimage.center_of_mass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.ndimage的用法示例。


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

示例1: _identify_subpeaks

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def _identify_subpeaks(data):
    # Initial identification of subpeaks with minimal minimum distance
    data_max = ndimage.filters.maximum_filter(data, 3)
    maxima = (data == data_max)
    data_min = ndimage.filters.minimum_filter(data, 3)
    diff = ((data_max - data_min) > 0)
    maxima[diff == 0] = 0

    labeled, n_subpeaks = ndimage.label(maxima)
    labels_index = range(1, n_subpeaks + 1)
    ijk = np.array(ndimage.center_of_mass(data, labeled, labels_index))
    ijk = np.round(ijk).astype(int)
    vals = np.apply_along_axis(arr=ijk, axis=1, func1d=_get_val,
                               input_arr=data)
    return ijk, vals 
开发者ID:nilearn,项目名称:nistats,代码行数:17,代码来源:_get_clusters_table.py

示例2: test_center_of_mass01

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass01():
    "center of mass 1"
    expected = [0.0, 0.0]
    for type in types:
        input = np.array([[1, 0], [0, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例3: test_center_of_mass02

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass02():
    "center of mass 2"
    expected = [1, 0]
    for type in types:
        input = np.array([[0, 0], [1, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例4: test_center_of_mass03

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass03():
    "center of mass 3"
    expected = [0, 1]
    for type in types:
        input = np.array([[0, 1], [0, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例5: test_center_of_mass04

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass04():
    "center of mass 4"
    expected = [1, 1]
    for type in types:
        input = np.array([[0, 0], [0, 1]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例6: test_center_of_mass05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass05():
    "center of mass 5"
    expected = [0.5, 0.5]
    for type in types:
        input = np.array([[1, 1], [1, 1]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例7: test_center_of_mass07

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass07():
    "center of mass 7"
    labels = [1, 0]
    expected = [0.5, 0.0]
    input = np.array([[1, 2], [3, 1]], bool)
    output = ndimage.center_of_mass(input, labels)
    assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例8: test_center_of_mass08

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass08():
    "center of mass 8"
    labels = [1, 2]
    expected = [0.5, 1.0]
    input = np.array([[5, 2], [3, 1]], bool)
    output = ndimage.center_of_mass(input, labels, 2)
    assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例9: test_center_of_mass09

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass09():
    "center of mass 9"
    labels = [1, 2]
    expected = [(0.5, 0.0), (0.5, 1.0)]
    input = np.array([[1, 2], [1, 1]], bool)
    output = ndimage.center_of_mass(input, labels, [1, 2])
    assert_array_almost_equal(output, expected) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_measurements.py

示例10: test_center_of_mass01

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass01():
    expected = [0.0, 0.0]
    for type in types:
        input = np.array([[1, 0], [0, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py

示例11: test_center_of_mass02

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass02():
    expected = [1, 0]
    for type in types:
        input = np.array([[0, 0], [1, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py

示例12: test_center_of_mass03

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass03():
    expected = [0, 1]
    for type in types:
        input = np.array([[0, 1], [0, 0]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py

示例13: test_center_of_mass04

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass04():
    expected = [1, 1]
    for type in types:
        input = np.array([[0, 0], [0, 1]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py

示例14: test_center_of_mass05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass05():
    expected = [0.5, 0.5]
    for type in types:
        input = np.array([[1, 1], [1, 1]], type)
        output = ndimage.center_of_mass(input)
        assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py

示例15: test_center_of_mass07

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import center_of_mass [as 别名]
def test_center_of_mass07():
    labels = [1, 0]
    expected = [0.5, 0.0]
    input = np.array([[1, 2], [3, 1]], bool)
    output = ndimage.center_of_mass(input, labels)
    assert_array_almost_equal(output, expected) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_measurements.py


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