什么用于skimage.measure.moments_central()的参数?

时间:2015-08-19 16:48:25

标签: python-2.7 scikit-image

我正在尝试使用sci-kit图像的测量模块来查找图像的Hu矩不变量,但是我在其中一个先决方法中遇到了问题。

该函数被定义为here

skimage.measure.moments_central(image, cr, cc, order=3)

其中cr和cc分别被定义为中心行坐标和中心列坐标。最初,我认为这只是意味着中点,但在更深入地观察中心时刻之后,我开始认为它应该更像是图像中物体的质心或几何中心的线条。我正专注于。有没有人对cr和cc的值应该有什么直觉?在线文档非常有限。

1 个答案:

答案 0 :(得分:2)

您必须传递感兴趣对象的质心。我提交了一个修复程序,通过示例改进文档,这也应该对您有所帮助。请参阅:https://github.com/scikit-image/scikit-image/pull/1636/files

用法:

>>> image = np.zeros((20, 20), dtype=np.double)
>>> image[13:17, 13:17] = 1
>>> m = moments(image)
>>> cr = m[0, 1] / m[0, 0]
>>> cc = m[1, 0] / m[0, 0]
>>> moments_central(image, cr, cc)
array([[ 16.,   0.,  20.,   0.],
       [  0.,   0.,   0.,   0.],
       [ 20.,   0.,  25.,   0.],
       [  0.,   0.,   0.,   0.]])