初步完成第二道题
This commit is contained in:
@@ -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()
|
||||||
Reference in New Issue
Block a user