Randomly add noise to the image

        For images, image enhancement generally requires algorithms/models with good denoising effects. Then corresponding to the image, the original image generally has more or less noise, which can be denoised by our own innovative algorithm. There can also be many objective indicators to evaluate the effect of the image after denoising. 

The following picture shows the image processed by my own algorithm, including before and after processing:

          

        It can be seen that my algorithm mainly performs non-uniform brightness adaptive correction for the uneven illumination of the image. Of course, it also includes the enhancement of low-light images, which can not only adjust the brightness of dark areas, but also adjust the brightness of bright areas adaptively. That is, in a picture, the bright area will not be brighter while brightening the low illuminance (the third picture is someone else's algorithm, the dark area is bright while the bright area is brighter, obviously, it is not what we want. desired enhancements).

 The effect of random noise addition:

        But how can you prove that your algorithm is very robust? One of the ideas expressed in this paper is to artificially add noise to the image, add different types, and different densities. You can use different algorithms to denoise and compare, and then compare the objective indicators of the processed image to see if your algorithm can stand the test. You can also verify whether your algorithm can only remove the fixed noise of the original image. We add different types. If the denoising effect is still very good, it means that our algorithm is indeed very robust. So, your algorithm It has strong robustness, which is not what you say. It needs to be verified by experiments. Then this kind of random noise addition is a good evidence. (good idea for writing a thesis)


import cv2
import skimage


#img = cv2.imread('E:/python/CSDN/image/1.bmp',cv2.IMREAD_GRAYSCALE)
img = cv2.imread("img/1-7.jpg")
cv2.imshow("original",img)
# fig=plt.figure(figsize=(10, 50))
#显示原图
# plt.subplot(12,3,1),plt.imshow(img,'gray'),plt.title('original')

def addGaussNoise(origin,var):#添加高斯噪声函数
    #var = random.uniform(0.0001, 0.04)
    noisy = skimage.util.random_noise(origin, mode='gaussian', var=var)
    return noisy

def addSaltNoise(origin,var):#添加椒盐噪声函数
    #var = random.uniform(0.01, 0.2)
    noisy = skimage.util.random_noise(origin, mode='s&p', amount=var)
    return noisy

def addSpeckleNoise(origin,var):#添加乘法噪声函数
    #var = random.uniform(0.0001, 0.04)
    noisy = skimage.util.random_noise(origin, mode='speckle', var=var)
    return noisy

img1 = addGaussNoise(img,0.02)
img2 = addGaussNoise(img,0.04)
img3 = addGaussNoise(img,0.06)
img4 = addGaussNoise(img,0.08)
img5 = addGaussNoise(img,0.10)

# img1 = addSaltNoise(img,0.02)
# img2 = addSaltNoise(img,0.04)
# img3 = addSaltNoise(img,0.06)
# img4 = addSaltNoise(img,0.08)
# img5 = addSaltNoise(img,0.10)

#img = addSpeckleNoise(img)
# img1 = addSpeckleNoise(img,0.02)
# img2 = addSpeckleNoise(img,0.04)
# img3 = addSpeckleNoise(img,0.06)
# img4 = addSpeckleNoise(img,0.08)
# img5 = addSpeckleNoise(img,0.10)

#显示添加噪声的原图
# # plt.subplot(12,3,4),plt.imshow(img,'gray'),plt.title('img_add_gaussin')
cv2.imshow('add1', img1)#显示读取的图
cv2.imshow('add2', img2)#显示读取的图
cv2.imshow('add3', img3)#显示读取的图
cv2.imshow('add4', img4)#显示读取的图
cv2.imshow('add5', img5)#显示读取的图

# #保存图片
# cv2.imwrite("img2/2222.jpg",img1)


cv2.waitKey()

Original image:

Noise addition effect: According to the commonness, breadth and classification type, three typical noises were selected in the experiment to fully prove the robustness of the algorithm, and the densities were added 0.02, 0.04, 0.06, 0.08, 0.1

Gauss:

Add salt and pepper:

Add multiplicative noise:

 1. According to the relationship between the image and the noise, the noise is divided into the following three forms:

  (1) Additive noise, the additive noise in the image is generally generated by the "channel noise" and the digitization of the image by the CCD camera during the transmission of the image.

  (2) Multiplicative noise . The multiplicative noise in the image is generally caused by particles in the film, noise in the flying spot scanning image, and TV scanning raster.

  (3) Quantization noise, the quantization noise in the image is the difference produced by the image from analog to digital in the process of image quantization, and it is the error in the process of image quantization.

2. The noise in the image can be divided into Gaussian noise (Gaussian noise), impulse noise (salt and pepper noise) (Impulsive noise), Rayleigh noise (Rayleigh noise), Gamma noise (Gamma noise), exponential noise according to its probability distribution Various forms of noise (Exponential noise) and uniform noise (Uniform noise).

       Among them , Gaussian noise is the most widely used of all noises. Gaussian noise is a kind of additive noise, that is, the noise is directly added to the original image , so it can be filtered out by a linear filter . The noise generated by sensors under low illumination or high temperature conditions is Gaussian noise, and the noise generated in electronic circuits is also Gaussian noise. There are many other noises that can be described in the form of Gaussian distribution (normal distribution). The Gaussian noise model is suitable for sensor noise caused by electronic circuits, low illumination, and high temperature.

       Salt and pepper noise , also known as impulse noise, is a random white point (salt noise) or black point (pepper noise), which may be black pixels in bright areas or white pixels in dark areas (or two Both), similar to sprinkling salt and pepper on the image, hence the name, such as snowflake noise on TV. Salt and pepper noise is neither additive noise nor multiplicative noise. Salt and pepper noise can be considered as a kind of logic noise . The result of filtering with linear filter is not good, and generally using median filter can get better results. The salt and pepper noise model is used for noise caused by misoperation of switching operations in imaging, etc. It is a kind of noise often seen in images . The salt and pepper noise may be caused by sudden and strong interference of the video signal, analog-to-digital converter or bit transmission error, etc. For example, a failed sensor results in a minimum pixel value, and a saturated sensor results in a maximum pixel value.

Guess you like

Origin blog.csdn.net/m0_63172128/article/details/127518737