Python cv2.randn() Examples
The following are 20
code examples of cv2.randn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example #1
Source File: faceaugmentation.py From AWSLambdaFace with GNU General Public License v3.0 | 6 votes |
def augment_image(rgbImg): augmented_images = [] # original image augmented_images.append(rgbImg) # fliped x-axis rimg = rgbImg.copy() cv2.flip(rimg, 1, rimg) augmented_images.append(rimg) # add gaussian noise for _ in range(10): gaussian_noise = rgbImg.copy() cv2.randn(gaussian_noise, 0, 150) augmented_images.append(rgbImg + gaussian_noise) augmented_images.append(rimg + gaussian_noise) for _ in range(10): uniform_noise = rgbImg.copy() cv2.randu(uniform_noise, 0, 1) augmented_images.append(rgbImg + uniform_noise) augmented_images.append(rimg + uniform_noise) return augmented_images
Example #2
Source File: video.py From TecoGAN with Apache License 2.0 | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv.add(buf, noise, dtype=cv.CV_8UC3) return True, buf
Example #3
Source File: video.py From OpenCV-Snapchat-DogFilter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example #4
Source File: video.py From OpenCV-Snapchat-DogFilter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example #5
Source File: video.py From OpenCV-Snapchat-DogFilter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #6
Source File: video.py From PyCV-time with MIT License | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #7
Source File: video.py From PyCV-time with MIT License | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #8
Source File: background_generator.py From TextRecognitionDataGenerator with MIT License | 5 votes |
def gaussian_noise(height, width): """ Create a background with Gaussian noise (to mimic paper) """ # We create an all white image image = np.ones((height, width)) * 255 # We add gaussian noise cv2.randn(image, 235, 10) return Image.fromarray(image).convert("RGBA")
Example #9
Source File: video.py From TecoGAN with Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv.add(self.render.getNextFrame(), noise, dtype=cv.CV_8UC3)
Example #10
Source File: video.py From TecoGAN with Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv.add(self.render.getNextFrame(), noise, dtype=cv.CV_8UC3)
Example #11
Source File: video.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #12
Source File: video.py From pi-tracking-telescope with MIT License | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #13
Source File: noiser.py From text_renderer with MIT License | 5 votes |
def apply_gauss_noise(self, img): """ Gaussian-distributed additive noise. """ mean = 0 stddev = np.sqrt(15) gauss_noise = np.zeros(img.shape) cv2.randn(gauss_noise, mean, stddev) out = img + gauss_noise return out
Example #14
Source File: augment_data.py From bonnet with GNU General Public License v3.0 | 5 votes |
def gaussian_noise(images, mean, std): """ Applies gaussian noise to every image in the list "images" with the desired Returns a list with all the original and noisy images. """ # if we only have 1 image, transform into a list to work with same script if type(images) is not list: images = [images] # container for sheared images noisy_images = [] # get every image and apply the number of desired shears for img in images: # get rows and cols apply noise to rows, cols, depth = img.shape # append original image noisy_images.append(img) # fill in the per-channel mean and std m = np.full((1, depth), mean) s = np.full((1, depth), std) # add noise to image # noisy_img = img.copy() noisy_img = np.zeros((rows, cols, depth), dtype=np.uint8) noisy_img = cv2.randn(noisy_img, m, s) noisy_img = img + noisy_img # append noisy image to container noisy_images.append(noisy_img) return noisy_images
Example #15
Source File: utils.py From edafa with MIT License | 5 votes |
def add_gauss_noise(img,bits): """ Add random gaussian noise to image :param img: input image :param bits: number of bits to represent a single color value :returns: image with noise """ MAX = get_max(bits) noise = img.copy() cv2.randn(noise, 0, MAX//2) return img + noise
Example #16
Source File: video.py From MachineLearning with Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example #17
Source File: video.py From MachineLearning with Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example #18
Source File: video.py From MachineLearning with Apache License 2.0 | 5 votes |
def read(self, dst=None): w, h = self.frame_size if self.bg is None: buf = np.zeros((h, w, 3), np.uint8) else: buf = self.bg.copy() self.render(buf) if self.noise > 0.0: noise = np.zeros((h, w, 3), np.int8) cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise) buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3) return True, buf
Example #19
Source File: video.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example #20
Source File: video.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)