python中使用opencv保存带alpha通道的png图像

直接看下面python代码

def save_png():
    image_path = 'src.png'
    img = cv2.imread(image_path, cv2.IMREAD_UNCHANGED) 
    img[63,63,:] = [255,0,0,128]
    print(img)
    cv2.imwrite('dst.png', img, [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
    cv2.namedWindow('win', 0)
    cv2.imshow('win', img)
    cv2.waitKey(0)

参考

https://blog.csdn.net/litdaguang/article/details/45438297

https://www.jianshu.com/p/7fcfc6253c81

猜你喜欢

转载自blog.csdn.net/bcfd_yundou/article/details/90480378
今日推荐