(image)
| 26 | |
| 27 | |
| 28 | def gaussian_noise(image): # 加高斯噪声 |
| 29 | h, w, c = image.shape |
| 30 | for row in range(h): |
| 31 | for col in range(w): |
| 32 | s = np.random.normal(0, 20, 3) |
| 33 | b = image[row, col, 0] # blue |
| 34 | g = image[row, col, 1] # green |
| 35 | r = image[row, col, 2] # red |
| 36 | image[row, col, 0] = clamp(b + s[0]) |
| 37 | image[row, col, 1] = clamp(g + s[1]) |
| 38 | image[row, col, 2] = clamp(r + s[2]) |
| 39 | |
| 40 | |
| 41 | src = cv.imread('img2.png') |