I am trying to put two images together, so I can show both in one window. The first image is an original three-channel image, the second is a gray version. I did cv2.cvtColor color conversion, converted back to 3-channel with numpy.dstack , and when I try to execute cv2.imshow it gives me an error with an explicit reset . Am I missing something? I need both images to have the same number of channels to stack them with numpy.hstack. This happens on a 64-bit Ubuntu machine.
import cv2 import numpy as np img = cv2.imread("/home/bernie/Dropbox/Python/Opencv/lena512.jpg") gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) gray = np.dstack((gray,gray,gray))
Adding
On the other hand, using
gray = cv2.cvtColor(gray,cv2.COLOR_GRAY2BGR)
line 7 works without complaint, so I will stick to this for now. This means that there is a difference between the result of cv2.cvtColor and the result of numpy.dstack to convert a 1-channel image to a 3-channel image with equal values.
source share