In order to make the technical solutions and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention are clearly and completely described below in conjunction with the drawings in the embodiments of the present invention:
 Invented and designed an underwater image enhancement method based on background light optimization and gamma transformation. This method is an underwater image restoration method that combines an improved dark channel prior algorithm and gamma transformation. By considering neighborhood pixel saturation Gamma transformation and color correction are combined to improve the image contrast and restore the real underwater image.
 An underwater image enhancement method based on background light optimization and gamma transformation, comprising the following steps:
 S1: Perform defogging processing on the underwater image to obtain the defogged underwater image;
 S2: Perform gamma transformation on the dehazed underwater image to obtain an underwater image with enhanced contrast;
 S3: For the underwater image after contrast enhancement, color correction is performed by using the method of maximum pixel value of the main channel to obtain a color-balanced underwater image.
 Further, the process of dehazing the underwater image is as follows:
 Combine the dark channel and color saturation to extract the background light of the underwater image to obtain the real background light of the underwater image, and estimate the transmittance of each channel of the underwater image to obtain the red, green and blue of the underwater image The transmittance of the 3 channels, that is, to complete the dehazing process of the underwater image.
 Usually, a complete underwater image mainly consists of direct transmission E D (x), forward scatter E F (x) and backscatter E B (x) consists of three parts, figure 1 It is a schematic diagram of underwater optical imaging, the light intensity E received by pixel point x in the camera λ (x) is:
 E. λ (x)=E D (x)+E F (x)+E B (x) (1)
 Neglecting the image blur caused by forward scattering, the underwater image imaging model is:
 I λ (x)=J λ (x)t λ (x)+B λ,∞ (1-t λ (x)) (2)
 In the formula, I λ (x) is the obtained observation image, J λ (x) is the real scene to be restored, t λ (x) is the transmittance, B λ,∞ for the background light.
 The dark channel prior theory uses the dark pixels in the image to describe the projection information of fog and light, and the main work of restoring the image is to estimate the background light and transmittance of the image.
 The first is to estimate the background light:
 The dark channel of an underwater image refers to the minimum value of light intensity in a certain area in the image, expressed as:
 where Ω(x) is a local window centered at x, I λ (y) is the pixel value of a color channel in the image. According to the dark channel prior theory, in a natural image of a clear, fog-free and non-sky area, the dark channel value in a certain window area tends to be 0, that is:
 J dark →0 (4)
 The traditional dark channel prior method selects the top 0.1% of the pixels with the highest brightness in the dark channel, and searches for the point with the highest brightness value in the image as the background light according to the position of these points. However, due to uneven underwater lighting, the overall brightness It is too dark, which leads to blurred underwater images, and the overall brightness of the dark channel is high, and the underwater images are seriously affected by the noise in the water, which makes the selection of background light easily disturbed, and wrong estimated values are obtained.
 In order to ensure the accuracy of background light selection, the present invention proposes an improved background light extraction method, which combines the characteristics of background light with higher brightness and color saturation to determine whether a candidate point is background light. The combination of dark channel and color Saturation extracts the background light of the underwater image, and the process of obtaining the real background light of the underwater image is as follows:
 S1-1: Select the first 0.1% pixels of the dark channel of the underwater image;
 S1-2: According to the positions of the pixels in the first 0.1% of the dark channel of the underwater image, select the point x with the highest brightness;
 S1-3: Calculate the color saturation S of the point x with the maximum brightness, and establish a local window W with the point x as the center, and set the threshold S according to the average saturation in the local window W L;
 S1-4: When S>S L , then set the pixel value of point x as background light, when S≤S L , select the next brightest pixel, and return to S1-2.
 The color saturation S of the present invention is defined as follows:
 S=max x (R,G,B)-min x (R,G,B) (5)
 max in formula (5) x (R,G,B), min x (R, G, B) are the maximum and minimum values of pixels in the three channels at point x, respectively;
 In formula (6): ω 1 , ω 2 are the length and width of the window W respectively, and ω is taken in the present invention 1 = ω 2 = 3, S i is the color saturation of the pixel at point i;
 S in formula (7) L is the preset threshold, and ρ is the threshold adjustment coefficient.
 When the saturation of the central pixel point in the window W is lower than the preset threshold, it is considered that the point does not have the characteristics that the background light should have and is ignored, and the point with the second brightest brightness in the dark channel is selected as the candidate background light, and the above steps are repeated. , until the saturation of the candidate point is higher than the preset saturation, and the real background light is obtained, image 3 Flow chart of dark channel background light selection combined with color saturation.
 After obtaining the real background light of the underwater image, the transmittance t λ For estimation, according to the underwater image imaging model (2) and the prior condition formula (4), it can be obtained:
 Since the attenuation coefficient of red light in water is the largest, the transmission of the red channel in the underwater image is the smallest, so the transmission rate estimated by using the dark channel prior is the transmission rate of the red channel:
 After obtaining the transmittance of the red channel, estimate the transmittance of the other two color channels; the transmittance of the pixel captured in the underwater image, the distance d from the camera, and the attenuation coefficient η of the corresponding band are called inverse proportional relationships, expressed as:
 Since the distance d between the pixel and the camera is the same in the three channels, the transmittance of different channels is calculated by the ratio of the attenuation coefficients of different color channels, namely:
 In the formula, t λ (x) is the transmittance of the λ channel at the pixel point x, η λ is the attenuation coefficient of the λ channel, (λ=R, G, B).
 In an underwater environment, the scattering rate b of the global background light of the image in water is positively correlated with the attenuation rate of light in water, namely:
 The relationship between light scattering rate and wavelength is shown in the following formula:
 b(λ)=(-0.00113λ+1.62517)b(λ c ) (13)
 In formula (13), λ represents the wavelength, and λ c As the reference wavelength, the present invention selects red, green, and blue wavelengths as 620, 540, and 450 nm, respectively. In this way, the estimated background light of each channel includes the values of three channels, that is, B=[Br, Bg, Bb] into formula (12), combined with formula (13) to solve the ratio of the scattering rate of each channel, through Equation (11) is solved to obtain the transmittance of the G and B channels, and the solution of the transmittance of the three channels is completed.
 Although the image restored by the dark channel method is clearer, the contrast still has a large room for improvement. Based on this, the present invention introduces gamma transformation to further improve the image contrast and make the image more layered. The gamma of the image used in the present invention The horse transformation formula is defined as follows:
 V out =V max (V in /V max ) γ (14)
 where V in , V out are the brightness of pixels in the input and output images, V max is the pixel value with the highest brightness in the channel.
 Finally, color correction is performed on the restored underwater image to balance the colors of each channel and improve the overall visual effect of the underwater image.
 The steps included in the main channel pixel most value method are as follows:
 S3-1: Calculate the maximum pixel value of the three color channels of red, blue, and green in the underwater image after contrast enhancement;
 S3-2: Compare the maximum pixel values of the red, blue, and green color channels, and make the color channel corresponding to the maximum pixel value the main channel, keep the main channel unchanged, and use the other two color channels as secondary channels;
 S3-3: Enlarge the pixel value of the secondary channel according to the enlargement factor, so that the color of the underwater image after the contrast is improved can be balanced.
 Further, the amplification factor g min , g med It is defined as follows:
 Apply a magnification factor to the other two subpasses to obtain a balanced image:
 In the formula, I min (R max ,G max ,B max ) is the color channel with the minimum pixel maximum value, I med (R max ,G max ,B max ) is the color channel centered on the maximum value of the pixel, I min , I med are the pixel values corresponding to the two color channels after balancing.
 Figure 4 (a) is the original picture; (b) is the effect figure after the traditional DCP method is processed to the original picture; (c) is the effect figure after adopting this method to the original picture process, and the experimental results show the image enhanced by the inventive method The contrast is significantly improved, and the visual effect is better.
 The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, any person familiar with the technical field within the technical scope disclosed in the present invention, according to the technical solution of the present invention Any equivalent replacement or change of the inventive concepts thereof shall fall within the protection scope of the present invention.