I am creating an image so:
image = np.empty(shape=(height, width, 1), dtype = np.uint16)
After that I convert the image to BGR model:
I suggest you to use this :
outputImg8U = cv2.convertScaleAbs(inputImg16U, alpha=(255.0/65535.0))
this will output a uint8 image & assign value between 0-255 with respect to there previous value between 0-65535
exemple :
pixel with value == 65535 will output with value 255
pixel with value == 1300 will output with value 5 etc...
You can use cv2.convertScaleAbs
for this problem. See the Documentation.
Check out the command terminal demo below :
>>> img = np.empty((100,100,1),dtype = np.uint16)
>>> image = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
>>> cvuint8 = cv2.convertScaleAbs(image)
>>> cvuint8.dtype
dtype('uint8')
Hope it helps!!!