import os,cv2,shutil
import numpy as np
import random
#对比度和亮度
def Contrast_and_Brightness(alpha, beta, img):
blank = np.zeros(img.shape, img.dtype)
# dst = alpha * img + beta * blank
dst = cv2.addWeighted(img, alpha, blank, 1-alpha, beta)
return dst
def darker(image,percetage):
image_copy = image.copy()
w = image.shape[1]
h = image.shape[0]
#get darker
for xi in range(0,w):
for xj in range(0,h):
image_copy[xj,xi,0] = int(image[xj,xi,0]*percetage)
image_copy[xj,xi,1] = int(image[xj,xi,1]*percetage)
image_copy[xj,xi,2] = int(image[xj,xi,2]*percetage)
return image_copy
def brighter(image, percetage):
w = image.shape[1]
h = image.shape[0]
#get brighter
for xi in range(0,w):
for xj in range(0,h):
image[xj,xi,0] = np.clip(int(image[xj,xi