Types of image data noise and corresponding noise generated by Python

Foreword

When it comes to image processing and computer vision tasks, noise is a factor that cannot be ignored. Noise can be caused by a variety of factors, such as sensor errors, communication interference, ambient light changes, etc. These noises will cause image quality to degrade, thus affecting subsequent image analysis and processing. Therefore, for applications to obtain accurate information from images, we need to deal with these noises efficiently. In this discussion, we will delve into several common types of noise in image data and corresponding processing methods, aiming to improve the accuracy and stability of image processing tasks.

Types of noise

1.Gaussian Noise

Gaussian noise is a common type of random noise that occurs in many natural phenomena and engineering applications. It is characterized by random amplitude and distribution, consistent with the normal distribution (also called Gaussian distribution). The generation of Gaussian noise can be caused by many factors, such as thermal noise of electronic components, scattering of light, and nonlinear response of sensors.

Gaussian noise can have the following effects on images:

  1. Blurring of image details: Gaussian noise introduces random interference into the image, causing image details to become blurred.
  2. Reduce image contrast: Noise reduces the contrast of an image by destabilizing its pixel values.
  3. Impact on image analysis and processing: In many computer vision and image processing tasks, noise can interfere with the detection, recognition and measurement of targets.

Gaussian noise appears in many scenarios, such as:

  1. Sensor Capture: In sensor equipment such as digital cameras and sound collectors, Gaussian noise will be introduced due to factors such as the characteristics of the sensor and the external environment.
  2. Communication signal transmission: During the signal transmission process such as wireless communication and wired communication, the signal may be interfered, resulting in Gaussian noise.
  3. Astronomical Observation: When a telescope observes objects in outer space, Gaussian noise will be generated due to atmospheric disturbance and other factors.

In the previous chapter, we saw Gaussian noise images. Take the original image as an example for comparison:

import numpy as np
import cv2

# Read pictures
image = cv2.imread('planck.jpg', cv2.IMREAD_COLOR)

# Generate Gaussian noise
mean=0
var=0.8
sigma=var**0.5
gaussian = np.random.normal(mean, sigma, image.shape).astype('uint8')
noisy_image = cv2.add(image, gaussian)

# Display the noisy image
cv2.imshow('Noisy Image', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

The Gaussian noise picture is displayed as:

2.Salt and Pepper Noise

Salt and pepper noise is a common image noise, which is characterized by black and white pixels randomly distributed in the image, usually with black and white points to simulate pepper and salt. This noise may be introduced during image acquisition, transmission or storage, usually due to equipment failure, sensor damage, transmission signal interference or storage media aging.

Salt and pepper noise can have the following effects on images:

  1. Random black and white dots in the image: These black and white dots are randomly distributed in the image, causing a loss of detail and features in the image.
  2. Reduced image quality: Salt and pepper noise will reduce the visual quality of the image, reducing the clarity and details of the image.
  3. Impact on image analysis and processing: In many image processing and computer vision tasks, noise can interfere with the detection, recognition and analysis of targets.

Salt and pepper noise may appear in many scenarios, such as:

  1. Photography: Take photos in low light conditions, or where salt and pepper noise is introduced due to a damaged or dirty camera sensor.
  2. Sensor failure: In sensor equipment such as digital cameras and sound collectors, salt and pepper noise may be introduced due to damage or failure of the sensor.
  3. Image transmission: During the image transmission process, the signal may be interfered with, resulting in salt and pepper noise.

Salt and pepper noise is shown as:

def salt_pepper_noise(image, salt_prob, pepper_prob):
    noisy_image = np.copy(image)
    total_pixels = image.shape[0] * image.shape[1] #Calculate the total number of pixels in the image
    
    num_salt = int(total_pixels * salt_prob) #Get the amount of salt and pepper noise to be added by multiplying the total number of pixels by the specified salt and pepper noise ratio.
    salt_coords = [np.random.randint(0, i-1, num_salt) for i in image.shape]
    noisy_image[salt_coords[0], salt_coords[1]] = 255

    num_pepper = int(total_pixels * pepper_prob)
    pepper_coords = [np.random.randint(0, i-1, num_pepper) for i in image.shape]
    noisy_image[pepper_coords[0], pepper_coords[1]] = 0

    return noisy_image

# Instructions
noisy_image = salt_pepper_noise(image, salt_prob=0.1, pepper_prob=0.1)
# Display the noisy image
cv2.imshow('Noisy Image', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

3.Poisson Noise

Poisson noise is a common image noise that originates from the randomness of photons in the imaging process. Specifically, Poisson noise is caused by the randomness in the number of photons reaching the camera sensor, which is more pronounced in low-light conditions or when shooting at fast shutter speeds.

Poisson noise usually appears as random changes in brightness and color in images. This change is not caused by the characteristics of the real scene, but by the randomness and quantization error of the imaging system.

Specific scenarios include:

  1. Shooting in low light conditions: In low light conditions, the camera sensor receives fewer photons, increasing the chance of Poisson noise.
  2. High ISO settings: High ISO settings amplify the signal received by the sensor, but also amplify noise signals, especially Poisson noise.
  3. Medical Images: In X-ray or MRI, there is Poisson noise in the image due to the randomness of photons or electrons.

The Poisson noise picture is shown as:

# Generate Poisson noise
noise = np.random.poisson(image / 255.0) * 255
noisy_image = np.clip(image + noise, 0, 255).astype('uint8')

# Display the noisy image
cv2.imshow('Noisy Image', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

4.Periodic Noise (Periodic Noise)

Periodic noise is noise that appears repeatedly at a specific frequency and amplitude in an image or signal. It usually takes the form of a sine or cosine waveform with a distinct periodic structure. Periodic noise can appear in fields such as image processing, signal processing, and audio processing.

The occurrence and scenarios of periodic noise:

  1. Sensor interference: During the image or signal collection process, the sensor may be affected by electromagnetic interference or other environmental factors, causing periodic noise to appear in the signal.
  2. Power Interference: During the shooting or recording process, you may be subject to electromagnetic interference from the power supply device, causing periodic stripes or noise to appear in the image.
  3. Light source interference: Shooting images in an environment with unstable lighting conditions may produce periodic noise due to fluctuations in the frequency of the light source.
  4. Transmission noise: During the transmission of images or signals, there may be interference from the transmission medium or equipment, causing periodic changes in the signal.
  5. Device defect: Some cameras or recording devices may have hardware defects that introduce periodic noise.

The existence of periodic noise will affect the image quality or signal accuracy. Therefore, in image processing and signal processing, it is often necessary to adopt corresponding methods to reduce or remove periodic noise to improve the reliability and availability of data.

Periodic noise appears as:

import numpy as np
import cv2

def generate_periodic_noise(image_shape, frequency):
    x = np.arange(image_shape[1])
    y = np.arange(image_shape[0])
    xx, yy = np.meshgrid(x, y)
    noise = np.sin(2 * np.pi * frequency * xx / image_shape[1])
    return noise

# Read pictures
image = cv2.imread('planck.jpg', cv2.IMREAD_COLOR)

# Generate periodic noise
frequency = 0.1 #Adjust this parameter to change the noise frequency
periodic_noise = generate_periodic_noise(image.shape[:2], frequency)

# Map noise to the range 0-255
periodic_noise = ((periodic_noise - periodic_noise.min()) / (periodic_noise.max() - periodic_noise.min()) * 255).astype('uint8')

# Expand the dimensions to match the number of channels in the image
periodic_noise = np.stack((periodic_noise,) * 3, axis=-1)

# Superimpose noise onto the image
noisy_image = cv2.add(image, periodic_noise.astype(np.uint8))

# Display the noisy image
cv2.imshow('Noisy Image with Periodic Noise', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

5. Rayleigh Noise

Rayleigh Noise is a common random noise model in image or signal processing. Its probability density function (PDF) follows the Rayleigh distribution.

Rayleigh noise is usually caused by:

  1. Interference in communication systems: In wireless communications, signals may be affected by multipath propagation, obstruction by obstacles and other factors, resulting in Rayleigh noise in the received signal.
  2. Noise in medical imaging: In fields such as medical imaging such as ultrasound imaging, Rayleigh noise can be caused by the absorption and scattering of sound waves when they propagate in human tissues.
  3. Sensor noise: The uncertainty in the measurement process of some sensors may also exhibit the characteristics of Rayleigh noise.

The characteristic of Rayleigh noise is that its amplitude distribution obeys Rayleigh distribution, while its phase is uniformly distributed.

Rayleigh noise picture display;

def generate_rayleigh_noise(image_shape, scale):
    noise = np.random.rayleigh(scale, image_shape)
    return noise

# Generate Rayleigh noise
scale = 50 # Adjust this parameter to change the noise amplitude
rayleigh_noise = generate_rayleigh_noise(image.shape[:2], scale).astype('uint8')
# Expand the dimensions to match the number of channels in the image
periodic_noise = np.stack((rayleigh_noise,) * 3, axis=-1)
# Superimpose noise onto the image
noisy_image = cv2.add(image, periodic_noise)

# Display the noisy image
cv2.imshow('Noisy Image with Rayleigh Noise', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

6. Irish (gamma) noise

Irish (gamma) noise is a noise model commonly used to describe sensor noise in low-light conditions, such as image sensors or other light-sensitive devices. Its probability density function (PDF) follows the gamma distribution.

Specifically, the probability density function of Irish noise is as follows:

Among them, k and θ are the parameters of the distribution, and Γ(k) is the gamma function.

In the world of image processing, Irish noise is often caused by electronic noise or sensor characteristics in low light conditions. It causes some pixels in the image to become abnormally bright or dark, thereby reducing the quality of the image.

In image processing, we can use some filtering techniques or adopt other post-processing methods to reduce or remove Irish noise to improve the quality and usability of the image.

Gamma noise display:

# Generate gamma noise
shape, scale = 10.0,10.0 # Set the parameters of the gamma distribution
gamma_noise = np.random.gamma(shape, scale, image.shape).astype('uint8')

# Superimpose noise onto the image
noise_image = cv2.add(image, gamma_noise)

# Display the noisy image
cv2.imshow('Noisy Image with Gamma Noise', noisy_image)
cv2.waitKey(0)
cv2.destroyAllWindows()


Image data noise is undesirable random or artificial interference introduced during image acquisition, transmission, or processing, which affects image quality and usability. Common types of image noise include Gaussian noise, salt and pepper noise, Poisson noise, speckle noise, periodic noise, etc.

In Python, we can utilize libraries such as NumPy and OpenCV to generate various types of noise. For example, you can simulate Gaussian noise by generating random numbers and superimposing them on the image, or randomly generate black and white pixels in the image to simulate salt and pepper noise. For Poisson noise and speckle noise, corresponding mathematical models can be used to generate them.

Methods for processing image noise include mean filtering, median filtering, Gaussian filtering, etc. These methods can select appropriate filters according to different types of noise to remove interference, thereby improving image quality.
In the next chapter I will summarize all image denoising methods and code implementations.

Pay attention to prevent getting lost. If there are any mistakes, please leave a message for advice. Thank you very much

That’s all for this issue. My name is fanstuck. If you have any questions, feel free to leave a message for discussion. See you in the next issue.