gpt4 book ai didi

python - Python 3中的NP.max函数错误

转载 作者:行者123 更新时间:2023-12-02 16:54:22 24 4
gpt4 key购买 nike

我正在使用OpenCV代码从中学习后台删除
http://www.codepasta.com/site/vision/segmentation/

错误来自np.max

edgeImg = np.max( np.array([ edgedetect(blurred[:,:, 0]), edgedetect(blurred[:,:, 1]), edgedetect(blurred[:,:, 2]) ]), axis=0 )

当我从np.max更改为np.maximum时,错误如下:
Traceback (most recent call last):
File "deteksipinggir-sobel.py", line 77, in <module>
segment('078.jpg')
File "deteksipinggir-sobel.py", line 49, in segment
np.array([edgedetect(blurred[:, :, 0]), edgedetect(blurred[:, :, 1]), edgedetect(blurred[:, :, 2])]), axis=0)
ValueError: invalid number of arguments

当我从np.max更改为np.amax时,错误如下:
Traceback (most recent call last):
File "deteksipinggir-sobel.py", line 77, in <module>
segment('078.jpg')
File "deteksipinggir-sobel.py", line 49, in segment
np.array([edgedetect(blurred[:, :, 0]), edgedetect(blurred[:, :, 1]), edgedetect(blurred[:, :, 2])]), axis=0)
File "E:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 2272, in amax
out=out, **kwargs)
File "E:\Anaconda3\lib\site-packages\numpy\core\_methods.py", line 26, in _amax
return umr_maximum(a, axis, None, out, keepdims)
TypeError: '>=' not supported between instances of 'NoneType' and 'NoneType'

我正在使用python 3,请帮忙,谢谢。

最佳答案

从numpy文档here中:numpy.maximum需要两个输入数组作为参数:

numpy.maximum(arr1, arr2)

numpy.max仅需要一个输入数组作为参数:
numpy.max(arr1)

确保您至少提供 numpy.maximum两个数组作为参数。

关于python - Python 3中的NP.max函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50348640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com