You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
414 B

# import numpy as np
# import cv2
from numpy import array,random,clip,uint8
def gasuss_noise(image, var=0.1, mean=0):
image = array(image/255, dtype=float)
# 高斯分布
noise = random.normal(mean, var ** 0.5, image.shape)
out = image + noise
if out.min() < 0:
low_clip = -1.
else:
low_clip = 0.
out = clip(out, low_clip, 1.0)
out = uint8(out*255)
return out