当前位置: 首页>>代码示例>>Python>>正文


Python cv2.randn方法代码示例

本文整理汇总了Python中cv2.randn方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.randn方法的具体用法?Python cv2.randn怎么用?Python cv2.randn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2的用法示例。


在下文中一共展示了cv2.randn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: augment_image

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:jremmons,项目名称:AWSLambdaFace,代码行数:27,代码来源:faceaugmentation.py

示例2: read

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:17,代码来源:video.py

示例3: read

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:mengli,项目名称:MachineLearning,代码行数:17,代码来源:video.py

示例4: add_gauss_noise

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:andrewekhalel,项目名称:edafa,代码行数:15,代码来源:utils.py

示例5: gaussian_noise

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:PRBonn,项目名称:bonnet,代码行数:37,代码来源:augment_data.py

示例6: apply_gauss_noise

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:Sanster,项目名称:text_renderer,代码行数:13,代码来源:noiser.py

示例7: read

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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 
开发者ID:thunil,项目名称:TecoGAN,代码行数:17,代码来源:video.py

示例8: gaussian_noise

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import randn [as 别名]
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") 
开发者ID:Belval,项目名称:TextRecognitionDataGenerator,代码行数:14,代码来源:background_generator.py


注:本文中的cv2.randn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。