diff --git a/test/2024,9,10/set_alpha.py b/test/2024,9,10/set_alpha.py new file mode 100644 index 0000000..24227a3 --- /dev/null +++ b/test/2024,9,10/set_alpha.py @@ -0,0 +1,16 @@ +import cv2 as cv + +# read image +img=cv.imread("opencv_logo.png",cv.IMREAD_UNCHANGED) +# concert to rgba +img_rgba=cv.cvtColor(img,cv.COLOR_BGR2BGRA) +# split alpha channel +blue,green,red,alpha = cv.split(img_rgba) +#set alpha channel +alpha[int(alpha.shape[0]/2):alpha.shape[0],int(alpha.shape[1]/2):alpha.shape[1]]=0 +# remix alpha to img_rgba +img_rgba=cv.merge((blue,green,red,alpha)) +# show +cv.imshow("changed",img_rgba) +cv.waitKey(0) +cv.destroyAllWindows() \ No newline at end of file