如何在python中创建具有随机透明值的alpha通道?有人请帮忙吗?我已经完成了以下代码,但是没有用
import numpy
import cv2
from PIL import Image
import matplotlib.image
img = Image.open('compressed_img.png')
b, g, r = cv2.split(img)
alpha_channel = numpy.ones(b.shape, dtype=b.dtype) * 50
imgA = cv2.merge((b, g_channel, r, alpha_channel))
imgA.save('alpha channel.png')
imgA.show('alpha channel.png')