我正在尝试读取图像,然后仅保留red输出图像中的通道。这是我所做的:
color = cv2.imread("lohri.jpg")
b,g,r = cv2.split(color)
zeros = np.zeros([b.shape[0], b.shape[1]])
# Make other 2 channels as zeros
only_red = cv2.merge((zeros, zeros, r))
但是当我这样做时,我收到一条错误消息:
OpenCV(3.4.1) Error: Assertion failed (mv[i].size == mv[0].size && mv[i].depth() == depth) in merge, file /io/opencv/modules/core/src/merge.cpp, line 458
Traceback (most recent call last):
File "inspect.py", line 23, in <module>
only_red = cv2.merge((zeros, zeros, r))
cv2.error: OpenCV(3.4.1) /io/opencv/modules/core/src/merge.cpp:458:
error: (-215) mv[i].size == mv[0].size && mv[i].depth() == depth in
function merge
我无法理解这样做的原因。为什么我会收到这个错误?
守着星空守着你
相关分类