【发布时间】:2021-04-03 11:32:06
【问题描述】:
我不断收到此错误消息:
newmaxleft=cl1count.index(max(cl1count))
AttributeError: 'numpy.ndarray' object has no attribute 'index'
代码的目的是找到白色像素最多的列的第一个出现点。
我的代码:
cl = cl[top:bottom, left:right]
cl1mask = np.uint8(np.where(cl == 0, 0, 1))
cl1count = cv2.reduce(cl1mask, 0, cv2.REDUCE_SUM, dtype=cv2.CV_32SC1)
cl1count.flatten().tolist()
newmaxleft=cl1count.index(max(cl1count))
【问题讨论】:
-
numpy.ndarray与pandas.Series不同。 -
你想要
argmax
标签: python arrays python-3.x indexing