Update anti.py

This commit is contained in:
HibiKier
2023-08-17 22:37:50 +08:00
committed by GitHub
parent 6beb421dd0
commit 354643f0f6
+2 -5
View File
@@ -5,7 +5,7 @@ import numpy as np
from PIL import Image from PIL import Image
def pixRandomChange(img): def pix_random_change(img):
# Image转cv2 # Image转cv2
img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
img[0, 0, 0] = random.randint(0, 0xfffffff) img[0, 0, 0] = random.randint(0, 0xfffffff)
@@ -14,13 +14,10 @@ def pixRandomChange(img):
return img return img
def pixRandomChangeFile(path): def pix_random_change_file(path: str):
# 注意:cv2.imread()不支持路径中文 # 注意:cv2.imread()不支持路径中文
warnings.filterwarnings("ignore", category=Warning) warnings.filterwarnings("ignore", category=Warning)
img = cv2.imread(path) img = cv2.imread(path)
img[0, 0, 0] = random.randint(0, 0xfffffff) img[0, 0, 0] = random.randint(0, 0xfffffff)
cv2.imwrite(path, img) cv2.imwrite(path, img)
print('finish')
pixRandomChangeFile('./0.jpg')