MCPcopy Create free account
hub / github.com/ZhengPeng7/BiRefNet / random_pepper

Function random_pepper

preproc.py:75–85  ·  view source on GitHub ↗
(img, N=0.0015)

Source from the content-addressed store, hash-verified

73
74
75def random_pepper(img, N=0.0015):
76 img = np.array(img)
77 noiseNum = int(N * img.shape[0] * img.shape[1])
78 for i in range(noiseNum):
79 randX = random.randint(0, img.shape[0] - 1)
80 randY = random.randint(0, img.shape[1] - 1)
81 if random.randint(0, 1) == 0:
82 img[randX, randY] = 0
83 else:
84 img[randX, randY] = 255
85 return Image.fromarray(img)

Callers 1

preprocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected