Background of the problem:
When conducting noise addition experiments, it is necessary to add Poisson noise to the image. The following provides the code for adding Poisson noise:
What is Poisson noise:Gaussian noise and shot noise often appear in RAW format images. Gaussian noise is independent of the strength of the light, which means that regardless of the pixel value of the image, the average level of noise remains unchanged. Another type is shot noise, which conforms to a Poisson distribution and is therefore also known as Poisson noise. The intensity of Poisson noise increases with the intensity of light, which means that the larger the pixel value of the image, the higher the frequency of Poisson noise occurrence. The principle of Poisson noise generation: The photons emitted by the light source are irradiated on the CMOS, forming a visible light spot. Sometimes CMOS may not be able to receive all photons, or sometimes it may receive a large number of photons, which can cause fluctuations in grayscale values and result in Poisson noise.
Solution:In order to simulate the Poisson noise generated by industrial cameras when capturing images, the image dataset is subjected to noise addition processing. The processing process is as follows:
import os
import numpy as np
import cv2
path = './.../.../'
img_name = 'xx.jpg'
image = cv2.imread(os.path.join(path,img_name)) #reading images path to store image paths, img_name for image file names
#add noise
noise_type = np.random.poisson(lam=0.03,size=(2177,2233,1)).astype(dtype='uint8') # lam>= the smaller the value of 0, the lower the frequency of noise, size for image size
noise_image = noise_type+image #overlay the original image with noise
cv2.imshow('image after adding noise',noise_image)
cv2.waitKey(0)
cv2.destroyWindow()