I simply imported an image. I want to merge each BGR channel with zero arrays and then show them. I've written my code as follows:
import cv2
import numpy as np
image = cv2.imread('./images/input.jpg')
B, G, R = cv2.split(image)
zeros = np.zeros((image.shape[:2]), dtype = 'int8')
cv2.imshow("Red", cv2.merge([zeros1, zeros1, R]))
cv2.imshow("Green", cv2.merge([zeros, G, zeros]))
cv2.imshow("Blue", cv2.merge([B, zeros, zeros]))
cv2.waitKey(500)
cv2.destroyAllWindows()
After running this code I get the following error.
error Traceback (most recent call last)
<ipython-input-13-9252d63ed763> in <module>
7 zeros = np.zeros((image.shape[:2]), dtype = 'int8')
8
----> 9 cv2.imshow("Red", cv2.merge([zeros1, zeros1, R]))
10 cv2.imshow("Green", cv2.merge([zeros, G, zeros]))
11 cv2.imshow("Blue", cv2.merge([B, zeros, zeros]))
error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\core\src\merge.dispatch.cpp:129: error: (-215:Assertion failed) mv[i].size == mv[0].size && mv[i].depth() == depth in function 'cv::merge'
It seems correct to me. what is the problem and how can I Fix this?