我想在python中找到3d數組的最大值。 我試圖python中3d數組的最大值
image_file1 = open("lena256x256.bmp","rb")
img_i = PIL.Image.open(image_file1)
pix = numpy.array(img_i);
maxval= max(pix)
,但我得到一個錯誤
File "test.py", line 31, in <module>
maxval= max(pix)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我不能在這裏抓到我的錯,請幫幫我。
這是不正確的。 'numpy.max'是理解多維數組的['numpy.amax'](http://docs.scipy.org/doc/numpy/reference/generated/numpy.amax.html)的別名。然而,OP沒有使用'numpy.max'。 – 2013-04-09 11:53:56