0x01 各种签名抠图都要钱 不如直接写一个扣扣得了 0x02 直接在当前目录下放置jpg即可,注意安装好库 import cv2 import numpy as np import time def gen_sig(img): name = str(time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime())) + '.png' # 设置阈值 temp = img[:, :, 0] # 取图像第一个通道 mmax = np.max(temp) mmin = np.min(temp) thresh = mmax * 0.5 + mmin * 0.5 - 15 result = cv2.cvtColor(img, cv2.COLOR_BGR2BGRA) B, G, R, _ = cv2.split(result) _, R = cv2.threshold(R, thresh, 255, cv2.THRESH_BINARY) _, Alpha = cv2.threshold(R, thresh, 255, cv2.THRESH_BINARY_INV) result[:, :, 3] = Alpha cv2.imwrite(name, result) def main(path): img = cv2.imread(path) gen_sig(img) if __name__ == '__main__': # 载入原图,并转化为灰度图像 path = r'./2.jpg' main(path)
0x03
关于库,可能有时候就是安装不了,不嫌麻烦可以加群768493664