當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.measure.moments_coords用法及代碼示例

用法:

skimage.measure.moments_coords(coords, order=3)

計算達到特定順序的所有原始圖像時刻。

可以從原始圖像時刻計算以下屬性:
  • 區域為:M[0, 0]
  • 質心為:{ M[1, 0] / M[0, 0] , M[0, 1] / M[0, 0] }。

請注意,原始矩既不是平移、縮放也不是旋轉不變的。

參數

coords(N, D) 雙精度或 uint8 數組

說明笛卡爾空間中 D 維圖像的 N 點數組。

orderint 可選

時刻的最大順序。默認值為 3。

返回

M(order + 1order + 1,...)數組

原始圖像時刻。 (D 尺寸)

參考

1

Johannes Kilian. Simple Image Analysis By Moments. Durham University, version 0.2, Durham, 2001.

例子

>>> coords = np.array([[row, col]
...                    for row in range(13, 17)
...                    for col in range(14, 18)], dtype=np.double)
>>> M = moments_coords(coords)
>>> centroid = (M[1, 0] / M[0, 0], M[0, 1] / M[0, 0])
>>> centroid
(14.5, 15.5)

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.measure.moments_coords。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。