Picture three-channel to single-channel python implementation

def convert_img():
    img_path = r'F:/wrong/3665965028_31833752716_1615948849585_ir.png'
    ir_img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
    # ir_imgr, ir_imgg, ir_imgb = ir_img.split()
    print(ir_img.shape)
    ir_img = ir_img.astype(np.uint16)*4
    cv2.imwrite('F:/wrong/img_0317.png', ir_img)
    cv2.imshow('img',ir_img)
    cv2.waitKey(0)
if __name__ == '__main__':
    convert_img()

cv2.IMREAD_GRAYSCALE is a single channel for reading grayscale images, because the project needs to convert the image to 16bit

Guess you like

Origin blog.csdn.net/qq_35037684/article/details/114926858