Skip to content

Commit 1aeb1b7

Browse files
authored
Add files via upload
1 parent 91faff3 commit 1aeb1b7

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

blog41-smoth/blog41-09-noise.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding:utf-8 -*-
2+
import cv2
3+
import numpy as np
4+
5+
#读取图片
6+
img = cv2.imread("yn.png", cv2.IMREAD_UNCHANGED)
7+
rows, cols, chn = img.shape
8+
9+
#加噪声
10+
for i in range(5000):
11+
x = np.random.randint(0, rows)
12+
y = np.random.randint(0, cols)
13+
img[x,y,:] = 255
14+
15+
cv2.imshow("noise", img)
16+
17+
#等待显示
18+
cv2.waitKey(0)
19+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)