Last active
April 23, 2020 05:35
-
-
Save ryul99/7dfa5c0345fde286e8c359e90c861044 to your computer and use it in GitHub Desktop.
testing gaussian noise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# made by @mori_inj | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import cv2 | |
p = 2#np.inf | |
pert = 100#1000 | |
im = cv2.imread('00000000.png') | |
#print(type(im)) # 처음부터 numpy | |
#print(im.shape) # (H, W, C) | |
print(im.size) # H x W x C | |
noise = np.random.normal(0, 1, np.size(im)) | |
noise = noise / np.linalg.norm(noise, p) * pert | |
print(np.linalg.norm(noise, p), pert) | |
im += noise.reshape(im.shape).astype(np.uint8) | |
print(np.amax(im), np.amin(im), type(im[0, 0, 0])) # np.uint8 (0 ~ 255) | |
plt.imshow(im[:,:,::-1], interpolation='bicubic') # R G B | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment