错误信息:
operands could not be broadcast together with shapes (603) (613)
我该怎么办?
两个列表是否需要相同的长度?
或者我应该零填充它?
这是我的代码:
def gaussian_smooth1(img, sigma):
'''
Do gaussian smoothing with sigma.
Returns the smoothed image.
'''
result = np.zeros_like(img)
#get the filter
filter = gaussian_filter(sigma)
#get the height and width of img
width = len(img[0])
height = len(img)
#smooth every color-channel
for c in range(3):
#smooth the 2D image img[:,:,c]
#tip: make use of numpy.convolve
for x in range(height):
result[x,:,c] = np.convolve(filter,img[x,:,c])
for y in range(width):
result[:,y,c] = np.convolve(filter,img[:,y,c])
return result