Reputation: 442
Is there any OpenCV
function to convert three channel binary image to 3 channel RGB image?
Here is my code where disparitySGB.jpg
is a grayscale (3 channel image).
import cv2
import numpy as np
image=cv2.imread("disparitySGB.jpg")
thresh=cv2.inRange(image,np.array([89,89,89]),np.array([140,140,140]));
cv2.rectangle(np.array(thresh),(100,100),(120,120),(255,255,0),3)
cv2.imshow("thresh",thresh)
cv2.waitKey()
inRange
returns 8U image.My concern is that the rectangle drawn must be colored.In this case it is white.(I think it is because the image is three channel binary image).
Upvotes: 0
Views: 2526
Reputation: 39796
# my dummy channels:
r = np.ones((100,100),np.uint8) * 100
g = np.ones((100,100),np.uint8) * 70
b = np.ones((100,100),np.uint8) * 10
#now, just merge them:
rgb = cv2.merge((r,g,b))
you can only draw coloured things on 3channel mats. you probably need to : thresh_col = cv2.cvtColor(thresh,cv2.COLOR_GRAY2BGR) and then draw into that
Upvotes: 1