使用np.hstack和vstack返回ValueError:除串联轴外的所有输入数组维必须完全匹配

时间:2018-12-04 17:45:18

标签: python opencv stack axis

此行代码中当前存在值错误

这是我创建的功能

def canny(im=None, sigma=None, scaling=None, vert=None, horz=None):

xscaling = vert
yscaling = horz

hsize = (6 * sigma + 1), (6 * sigma + 1)# The filter size.

gaussian = gauss2D(hsize, sigma)
im = filter2(gaussian, im)# Smoothed image.
#scaling = 0.4
#scaling = tuple(scaling)

im = cv2.resize(im,None, fx=scaling, fy=scaling )  

[rows, cols] = np.shape(im)

im = np.array(im, dtype=float)
print("This is im array")
print(im)
#h =  [  im(:,2:cols)  zeros(rows,1) ] - [  zeros(rows,1)  im(:,1:cols-1)  ];

我当前在这行上有错误

d1 = (np.vstack((np.hstack((im[2:rows,2:cols], np.zeros((rows-1,1))))),np.zeros((1,cols)))) - np.vstack((np.zeros((1,cols)), np.hstack((np.zeros((rows-1,1)),im[1:rows-1,1:cols-1]))))

IDLE返回ValueError:除串联轴外,所有输入数组维必须完全匹配

0 个答案:

没有答案