自动抠图,真的很快,加上循环,可以抠多张签名。
#!_*_coding:utf-8_*_ #__author__:"david.z" #首先用pip命令安装模块,pip install opencv-python import cv2 image = cv2.imread(r'qianming.png',cv2.IMREAD_UNCHANGED) size = image.shape print(size,image[0][0]) for i in range(size[0]): for j in range(size[1]): if image[i][j][0]>100 and image[i][j][1]>100 and image[i][j][2]>100: image[i][j][3] = 0 else: image[i][j][0],image[i][j][1],image[i][j][2] = 0,0,0 cv2.imwrite(r'ttt.png',image)
原图:
效果: