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.
16 lines
393 B
16 lines
393 B
from numpy import array,clip,uint8
|
|
from numpy.random import uniform
|
|
def uniform_noise(image,hight=1.0,low=0.0):
|
|
|
|
image = array(image/255, dtype=float)
|
|
# 均匀分布
|
|
noise = uniform(low,hight,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
|