當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。