How can I create an alpha channel with random transparent values in python? Anybody please help? I have done the following code, but it doesn't work
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')
Aucun commentaire:
Enregistrer un commentaire