Python 不规则形状上的Zernike矩错误?
当我在某些包含非常不规则形状的图像上调用Python 不规则形状上的Zernike矩错误?,python,opencv,cv2,mahotas,Python,Opencv,Cv2,Mahotas,当我在某些包含非常不规则形状的图像上调用mahotas.features.zernike_矩时,我得到以下错误: fv = mahotas.features.zernike_moments(mask, cv2.minEnclosingCircle(cnt)[1], degree=8) File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\mahotas\features\zernike.py",
mahotas.features.zernike_矩时,我得到以下错误:
fv = mahotas.features.zernike_moments(mask, cv2.minEnclosingCircle(cnt)[1], degree=8)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\mahotas\features\zernike.py", line 59, in zernike_moments
c0,c1 = center_of_mass(im)
ValueError: too many values to unpack (expected 2)
它适用于以下简单形状:
但是我在下面的图片中用下面的代码得到了错误。知道我做错了什么吗
编辑如果我将遮罩调整为500像素宽,代码是否有效?mahotas是否具有形状所需的最小尺寸?这里是mahotas的作者
mask
是三维图像(尽管最后一个维度是1
),而该函数仅适用于一维图像。尝试:
fv = mahotas.features.zernike_moments(mask[:,:,0], \
cv2.minEnclosingCircle(cnt)[1], \
degree=8)
fv = mahotas.features.zernike_moments(mask[:,:,0], \
cv2.minEnclosingCircle(cnt)[1], \
degree=8)