# -*- coding: utf-8 -*-
# Author: Xiaofeng Li
#
#.jpg image generate noise
#
import cv2
import matplotlib.pyplot as plt
import numpy as np
import os
import random
from PIL import Image
class NoiseGenerator(object):
def generated_noise(self, img):
"""
Choose which noise to produce.
:param img(.jpg):
"""
noise_count = random.randint(1, 6)
for i in range(noise_count):
index_noise = random.randint(0, 5)
if index_noise == 0:
img = self.gaussian_img(img)
elif index_noise == 1:
img = self.salt_img(img)
elif index_noise == 2:
img = self.line_img(img)
elif index_noise == 3:
img = self.rotate_whole_img(img)
elif index_noise == 4:
img = self.erode_img(img)
elif index_noise == 5:
img = self.rotate_local_img(img)
return img
def gaussian_
opencv之随机添加噪音
最新推荐文章于 2022-12-18 10:05:24 发布