[OpenCV complete routine] 93 Histogram of noise model
Welcome to pay attention "100 complete OpenCV routines" Series, continuously updating
Welcome to pay attention "Python Xiaobai's OpenCV learning course" Series, continuously updating
2. Noise model
The noise source in digital image mainly comes from the process of image acquisition and transmission. When acquiring an image, the light level and sensor temperature affect the noise in the image. When transmitting an image, the interference in the transmission channel pollutes the image.
2.7 summary of image noise
The above noise model provides an effective tool for the modeling of various image noise. For example:
Gaussian noise: it is often used in the modeling of noise caused by electronic circuit and sensor noise (caused by insufficient illumination and / or high temperature);
Rayleigh noise: commonly used for noise modeling in range imaging;
Exponential noise and gamma noise: commonly used in noise modeling in laser imaging;
Impulse noise: it is often used for noise modeling of fast transients (such as switch failure) during imaging;
Uniform noise: it is the most basic description of the actual situation and the basis of various random number generators in digital image processing.
Routine 9.7: histogram distribution of various noise models
# OpenCVdemo09.py # Demo09 of OpenCV # 9. Image restoration and reconstruction # Copyright 2021 Youcans, XUPT # Crated: 2021-01-30 # # 9.7: histogram distribution of various noise models img = cv2.imread("../images/Fig0503.tif", 0) # flags=0 read as grayscale image mu, sigma = 0.0, 20.0 noiseGause = np.random.normal(mu, sigma, img.shape) imgGaussNoise = img + noiseGause imgGaussNoise = np.uint8(cv2.normalize(imgGaussNoise, None, 0, 255, cv2.NORM_MINMAX)) # Normalized to [0255] a = 30.0 noiseRayleigh = np.random.rayleigh(a, size=img.shape) imgRayleighNoise = img + noiseRayleigh imgRayleighNoise = np.uint8(cv2.normalize(imgRayleighNoise, None, 0, 255, cv2.NORM_MINMAX)) # Normalized to [0255] a, b = 10.0, 2.5 noiseGamma = np.random.gamma(shape=b, scale=a, size=img.shape) imgGammaNoise = img + noiseGamma imgGammaNoise = np.uint8(cv2.normalize(imgGammaNoise, None, 0, 255, cv2.NORM_MINMAX)) # Normalized to [0255] a = 10.0 noiseExponent = np.random.exponential(scale=a, size=img.shape) imgExponentNoise = img + noiseExponent imgExponentNoise = np.uint8(cv2.normalize(imgExponentNoise, None, 0, 255, cv2.NORM_MINMAX)) # Normalized to [0255] mean, sigma = 10, 100 a = 2 * mean - np.sqrt(12 * sigma) # a = -14.64 b = 2 * mean + np.sqrt(12 * sigma) # b = 54.64 noiseUniform = np.random.uniform(a, b, img.shape) imgUniformNoise = img + noiseUniform imgUniformNoise = np.uint8(cv2.normalize(imgUniformNoise, None, 0, 255, cv2.NORM_MINMAX)) # Normalized to [0255] ps, pp = 0.05, 0.02 mask = np.random.choice((0, 0.5, 1), size=img.shape[:2], p=[pp, (1-ps-pp), ps]) imgChoiceNoise = img.copy() imgChoiceNoise[mask==1] = 255 imgChoiceNoise[mask==0] = 0 plt.figure(figsize=(12, 8)) plt.subplot(231), plt.title("Gauss noise") histNP, bins = np.histogram(imgGaussNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.subplot(232), plt.title("Rayleigh noise") histNP, bins = np.histogram(imgRayleighNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.subplot(233), plt.title("Gamma noise") histNP, bins = np.histogram(imgGammaNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.subplot(234), plt.title("Exponential noise") histNP, bins = np.histogram(imgExponentNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.subplot(235), plt.title("Uniform noise") histNP, bins = np.histogram(imgUniformNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.subplot(236), plt.title("Salt-pepper noise") histNP, bins = np.histogram(imgChoiceNoise.flatten(), bins=255, range=[0, 255], density=True) plt.bar(bins[:-1], histNP[:]) plt.tight_layout() plt.show()
(end of this section)
Copyright notice:
youcans@xupt Original works, reprint must be marked with the original link
Copyright 2021 youcans, XUPT
Crated: 2022-2-1
Welcome to pay attention "100 complete OpenCV routines" Series, continuously updating
Welcome to pay attention "Python Xiaobai's OpenCV learning course" Series, continuously updating
[OpenCV complete routine] 01 Image reading (cv2.imread)
[OpenCV complete routine] 02 Image saving (cv2.imwrite)
[OpenCV complete routine] 03 Image display (cv2.imshow)
[OpenCV complete routine] 04 Displaying images with matplotlib (plt.imshow)
[OpenCV complete routine] 05 Image properties (np.shape)
[OpenCV complete routine] 06 Pixel editing (img.itemset)
[OpenCV complete routine] 07 Image creation (np.zeros)
[OpenCV complete routine] 08 Copy of image (np.copy)
[OpenCV complete routine] 09 Image clipping (cv2.selectROI)
[OpenCV complete routine] 10 Image mosaic (np.hstack)
[OpenCV complete routine] 11 Split of image channel (cv2.split)
[OpenCV complete routine] 12 Merging of image channels (cv2.merge)
[OpenCV complete routine] 13 Image addition (cv2.add)
[OpenCV complete routine] 14 Image and scalar addition (cv2.add)
[OpenCV complete routine] 15 Weighted addition of images (cv2.addWeight)
[OpenCV complete routine] 16 Image addition of different sizes
[OpenCV complete routine] 17 Gradient switching between two images
[OpenCV complete routine] 18 Mask addition of image
[OpenCV complete routine] 19 Circular mask of image
[OpenCV complete routine] 20 Bitwise operation of image
[OpenCV complete routine] 21 Image overlay
[OpenCV complete routine] 22 Add non Chinese text to the image
[OpenCV complete routine] 23 Add Chinese text to image
[OpenCV complete routine] 23 Add Chinese text to image
[OpenCV complete routine] 24 Affine transformation of image
[OpenCV complete routine] 25 Image Translation
[OpenCV complete routine] 26 Rotation of the image (centered on the origin)
[OpenCV complete routine] 27 Rotation of the image (centered on any point)
[OpenCV complete routine] 28 Image rotation (right angle rotation)
[OpenCV complete routine] 29 Image flip (cv2.flip)
[OpenCV complete routine] 30 Zoom of image (cv2.resize)
[OpenCV complete routine] 31 Image pyramid (cv2.pyrDown)
[OpenCV complete routine] 32 Image twist (stagger)
[OpenCV complete routine] 33 Composite transformation of image
[OpenCV complete routine] 34 Projection transformation of image
[OpenCV complete routine] 35 Projection transformation of image (boundary filling)
[OpenCV complete routine] 36 Conversion between rectangular coordinates and polar coordinates
[OpenCV complete routine] 37 Gray processing and binary processing of image
[OpenCV complete routine] 38 Inverse color transformation of image (image inversion)
[OpenCV complete routine] 39 Linear transformation of image gray
[OpenCV complete routine] 40 Image piecewise linear gray scale transformation
[OpenCV complete routine] 41 Gray level transformation of image (gray level layering)
[OpenCV complete routine] 42 Gray level transformation of image (bit plane layering)
[OpenCV complete routine] 43 Gray scale transformation of image (logarithmic transformation)
[OpenCV complete routine] 44 Gray scale transformation of image (gamma transformation)
[OpenCV complete routine] 45 Gray histogram of image
[OpenCV complete routine] 46 Histogram equalization
[OpenCV complete routine] 47 Image enhancement histogram matching
[OpenCV complete routine] 48 Image enhancement - color histogram matching
[OpenCV complete routine] 49 Image enhancement - local histogram processing
[complete] OpenCV.50 Image enhancement - histogram statistics image enhancement
[OpenCV complete routine] 51 Image enhancement histogram backtracking
[OpenCV complete routine] 52 Image correlation and convolution
[OpenCV complete routine] 53 SciPy realizes two-dimensional image convolution
[opencv complete routine] 54 OpenCV to realize image two-dimensional convolution
[OpenCV complete routine] 55 Separable convolution kernel
[OpenCV complete routine] 56 Low pass box filter
[OpenCV complete routine] 57 Low pass Gaussian filter
[OpenCV complete routine] 58 Nonlinear filtering median filtering
[OpenCV complete routine] 59 Nonlinear filtering bilateral filtering
[OpenCV complete routine] 60 Nonlinear filtering - joint bilateral filtering
[OpenCV complete routine] 61 Guided filter
[OpenCV complete routine] 62 Image sharpening - passivation masking
[OpenCV complete routine] 63 Image sharpening Laplacian operator
[OpenCV complete routine] 64 Image sharpening -- Sobel operator
[OpenCV complete routine] 65 Image sharpening -- Scharr operator
[OpenCV complete routine] 66 Low pass / high pass / band stop / band pass of image filtering
[OpenCV complete routine] 67 Comprehensive application of image enhancement in spatial domain
[OpenCV complete routine] 68 Comprehensive application of image enhancement in spatial domain
[OpenCV complete routine] 69 Fourier coefficients of continuous aperiodic signals
[OpenCV complete routine] 70 Fourier transform of one-dimensional continuous function
[OpenCV complete routine] 71 Sampling of continuous functions
[OpenCV complete routine] 72 One dimensional discrete Fourier transform
[OpenCV complete routine] 73 Two dimensional continuous Fourier transform
[OpenCV complete routine] 74 Anti aliasing of image
[OpenCV complete routine] 75 Implementation of image Fourier transform with numpy
[OpenCV complete routine] 76 OpenCV realizes image Fourier transform
[OpenCV complete routine] 77 OpenCV implements fast Fourier transform
[OpenCV complete routine] 78 Fundamentals of image filtering in frequency domain
[OpenCV complete routine] 79 Basic steps of image filtering in frequency domain
[OpenCV complete routine] 80 Detailed steps of image filtering in frequency domain
[OpenCV complete routine] 81 Gaussian low pass filter in frequency domain
[OpenCV complete routine] 82 Butterworth low pass filter in frequency domain
[OpenCV complete routine] 83 Low pass filtering in frequency domain: character restoration of printed text
[OpenCV complete routine] 84 The high pass filter is obtained from the low pass filter
[OpenCV complete routine] 85 Application of high pass filter in frequency domain
[OpenCV complete routine] 86 Application of frequency domain filtering: fingerprint image processing
[OpenCV complete routine] 87 Frequency domain passivation masking
[OpenCV complete routine] 88 Laplace high pass filter in frequency domain
[OpenCV complete routine] 89 Transfer function of band stop filter
[OpenCV complete routine] 90 Frequency domain notch filter
[OpenCV complete routine] 91 Gaussian noise, Rayleigh noise, Irish noise
[OpenCV complete routine] 92 Exponential noise, uniform noise, salt and pepper noise
[OpenCV complete routine] 93 Histogram of noise model