In general, the grayscale level of the binary image is 21 =2 (0\1), the grayscale level of the grayscale image is 28=256 (0-255),
For grayscale images, when the gray value is concentrated at a lower level, the image is darker, conversely, it is brighter, and the gray value distribution is more uniform, the contrast of the image will be more obvious.
1. How to calculate image histogram
For grayscale images, the grayscale level of the image is 256, the number of pixels in the image corresponding to each gray level from 0 to 255 is counted, and then, by calculating the total number of statistics and the corresponding pixel points of the whole image is worth the probability density value of each gray level in the image, Gray level as an independent variable, the probability of appearing in the image is a variable to get a discrete function, the corresponding two-dimensional discrete image is the histogram of the image.
P (i) =ni/n (i=0, 1, 2........255)
2. Histogram Equalization Method
1) HE
Map function T (n) = (2b-1) ∑i=0 n H (i) +0.5 where H (i) =p (i)
2) Adjust the level of contrast enhancement by adding a control factor.
H (i) =1/(1+λ) *p (i) +λ/(1+λ) *u
3) First smoothing the histogram, removing the point (H (i)-H (i-1) above a certain limit) in the histogram and preventing the image from being viewed in the human eye.
H (i) = ((1+λ) I+γ*dt D)-1 (P (i) +λ*u) where D is a bilateral symmetric matrix, I is the unit matrix
4) Add the idea of the B&w extension method (this method makes the point of the gray value smaller, the gray value is larger, so that the contrast of the image is enhanced),
When B<i<w, H (i) =1/(1+λ) p (i) +λ/(1+λ) u
When I<=b or i>=w, H (i) =1/(1+λ+α) * (P (i) +λu)
5) A new method is proposed after synthesizing the above method.
H1 (i) =p (i/c) satisfies the probability density corresponding to the pixel point of event C,
The pixel point corresponding to event C is the point that satisfies |f (m,n)-F (m,n-2) |>threshold (m,n)
The number of points in the statistical image that satisfy the condition N, and the probability distribution P (i/c) of the gray level corresponding to the points of these satisfying conditions,
The corresponding pseudo-code is
Input: Source image F,
Parameters: Enhanced level G, b&w extended parameter b,w, φ
Output: Image with enhanced contrast F
Initial K
foreach row m do
foreach column n Do
K=k+|f (M,n (-f (m,n-2)
If |f (M,n)-F (m,n-2) |>threshoold
++num[f (M,n)]
++n
End
End
End
Nomalize G*k to get k*
U=min[n/256,umin]
foreach Bin I Do
If B<i<w Then
h[i]= (1-k*) u+k* H1 [i]
Else
H[I]=1/(1+φ) ((1-k*) u+k* H1 [i])
End
End
foreach row m do
foreach column n Do
F (m,n) = (2b-1) C (f (m,n)) +0.5
End
End
where C (f (m,n)) =∑i=0 F (m,n) H (i), k*=1/(1+λ) =nomalize (gk), K is the summation of the difference between the pixels of the image, making the control factor adaptive to the contrast of the image,
The normalization method of GK uses Bit-shift operation
A method of contrast enhancement using histogram of image