python里input输入参数有误_opencv错误:输入参数的大小不匹配

import cv2

import numpy as np,sys

A = cv2.imread('/home/grayhat/apple.jpg')

B = cv2.imread('/home/grayhat/orange.jpg')

# generate Gaussian pyramid for A

G = A.copy()

gpA = [G]

for i in xrange(6):

G = cv2.pyrDown(G)

gpA.append(G)

# generate Gaussian pyramid for B

G = B.copy()

gpB = [G]

for i in xrange(6):

G = cv2.pyrDown(G)

gpB.append(G)

# generate Laplacian Pyramid for A

lpA = [gpA[5]]

for i in xrange(5,0,-1):

GE = cv2.pyrUp(gpA[i])

L = cv2.subtract(gpA[i-1],GE)

lpA.append(L)

# generate Laplacian Pyramid for B

lpB = [gpB[5]]

for i in xrange(5,0,-1):

GE = cv2.pyrUp(gpB[i])

L = cv2.subtract(gpB[i-1],GE)

lpB.append(L)

# Now add left and right halves of images in each level

LS = []

for la,lb in zip(lpA,lpB):

rows,cols,dpt = la.shape

ls = np.hstack((la[:,0:cols/2], lb[:,cols/2:]))

LS.append(ls)

# now reconstruct

ls_ = LS[0]

for i in xrange(1,6):

ls_ = cv2.pyrUp(ls_)

ls_ = cv2.add(ls_, LS[i])

# image with direct connecting each half

real = np.hstack((A[:,:cols/2],B[:,cols/2:]))

cv2.imwrite('Pyramid_blending2.jpg',ls_)

cv2.imwrite('Direct_blending.jpg',real)

错误如下:OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in arithm_op, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/arithm.cpp, line 1287

Traceback (most recent call last):

File "programs/test11.py", line 25, in

L = cv2.subtract(gpA[i-1],GE)

cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/arithm.cpp:1287: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值