值在python中堆叠图像时出错

值在python中堆叠图像时出错,python,python-3.x,opencv,image-processing,Python,Python 3.x,Opencv,Image Processing,我正试图聚焦几个图像,但我一直收到下面的错误。为什么我会收到这个错误,我应该如何修复它 任何关于如何解决此问题的建议和代码片段都将不胜感激 我已经看过了,但仍然不确定这个错误在我的场景中的意义 文件“/Users/…”,第32行,在堆栈中 最大值=最大值(轴=0) amax中的文件“/anaconda3/lib/python3.5/site packages/numpy/core/_methods.py”,第26行 返回umr_最大值(a、轴、无、输出、保持) ValueError:包含多个元素

我正试图聚焦几个图像,但我一直收到下面的错误。为什么我会收到这个错误,我应该如何修复它

任何关于如何解决此问题的建议和代码片段都将不胜感激

我已经看过了,但仍然不确定这个错误在我的场景中的意义

文件“/Users/…”,第32行,在堆栈中 最大值=最大值(轴=0)

amax中的文件“/anaconda3/lib/python3.5/site packages/numpy/core/_methods.py”,第26行 返回umr_最大值(a、轴、无、输出、保持)

ValueError:包含多个元素的数组的真值不明确。使用a.any()或a.all()

下面提供了上面错误中指出的堆叠方法,堆叠器方法也是如此

def stacker(folder, num):
    images = []
    for filename in os.listdir(folder):
        img = cv2.imread(os.path.join(folder,filename))
        if img is not None:
            images.append(img)
    stacked = stack(images)
    newpath = "key-frames" #destination of final image
    os.chdir(newpath)
    cv2.imwrite("Stacked%d.png" % num, stacked)
堆栈方法如下所示

def stack(imgs):
    #aligns the images
    images = imageAlignment(imgs)
    laps = []

    #loop through images and compute lap
    for i in range(len(images)):
        grayImg = cv2.cvtColor(images[i],cv2.COLOR_BGR2GRAY)
        laps.append(findLap(grayImg))

    #converts input to array
    laps = np.asarray(laps)

    #creates empty array
    output = np.zeros(shape=images[0].shape, dtype=images[0].dtype)

    #find absolute value of laps
    abs_laps = np.absolute(laps)

    #find maximum of laps
    maximum = abs_laps.max(axis=0)

    #boolean to determine if lap for image is max
    booleanChecker = abs_laps == maximum

    #pixels are unit8 and uint8 will wrap
    mask = booleanChecker.astype(np.uint8)

    #inverts every bit of array using mask that specifies of output array 
    #to be changed
    for i in range(0,len(images)):
        output = cv2.bitwise_not(images[i],output, mask=mask[i])

    return 255 - output
编辑

下面是abs_laps的材质示例

[0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00>0.000e+00 0.000e+00 0.000e+00 2.000e+00 1.600e+01 6.400e+01 1.800e+02>3.800e+02]


输入数据中有错误。您应该打印出代码在哪个图像上中断并检查数据。很可能要堆叠的图像集中有一个空图像。

请提供。你能给我们看看abs\u laps的样子吗?描述它的形状和里面有什么,或者打印出来?@JayCalamari它是26乘540数组的圈数的所有绝对值的列表。@JayCalamari我添加了一个看起来像编辑的样本。