我有以下代码:
import cv2
import numpy as np
img = cv2.imread('a.jpg')
gray = cv2.imread('b.jpg')
gray = cv2.cvtColor(gray, cv2.COLOR_BGR2GRAY)
print('a shape:', img.shape) # a shape: (50,50,3)
print('b shape:', img.shape) # b shape: (50,50)
result = np.concatenate((img, gray), axis=2)
print('result: ', result.shape) # hope result shape: (50, 50, 4)
我得到如下例外:
ValueError: all the input arrays must have same number of dimensions
我想得到result.shape =(50,50,4), 4个频道。如何修改我的代码?