Underwater light source detection method and system based on dark channel prior defogging algorithm, medium and program product

The dark channel prior defogging algorithm quickly and accurately calculates the location of the underwater light source, solving the problems of underwater image blur and low contrast, and achieving high-precision light source feature extraction and robot position estimation.

CN120374724APending Publication Date: 2025-07-25HARBIN ENG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510441528.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

During the acquisition process of underwater images, there are problems of blurred details and low contrast. Conventional detection methods are difficult to meet the accuracy requirements. It is necessary to quickly and accurately extract the underwater light source information to identify and extract the light source characteristics.

Method used

采用基于暗通道先验去雾算法,通过计算水下光源图像的暗通道、环境光系数和介质透射率系数,生成深度图并提取灯光掩膜图,结合轮廓长度和圆形度筛选轮廓,计算轮廓质心进行水下机器人的位姿估计。

Benefits of technology

It realizes fast and accurate calculation of underwater light source position, and improves the adaptive ability and detection accuracy of morphological feature extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120374724A_ABST
    Figure CN120374724A_ABST
Patent Text Reader

Abstract

The invention discloses an underwater light source detection method and system based on a dark channel prior defogging algorithm, a medium and a program product, and belongs to the field of underwater image processing. Firstly, a dark channel of an underwater light source image is calculated through a dark channel prior algorithm, and a depth map is constructed by combining an ambient light coefficient and a medium transmissivity coefficient; and performing feature extraction on the depth map by using a lamplight mask generation function, screening an effective light source area through double criteria of contour length and circularity in combination with OpenCV contour detection and a morphological screening mechanism, calculating a contour centroid coordinate based on an image moment algorithm, and performing pose estimation of the underwater robot. Compared with the prior art, the method can quickly and accurately calculate the position of the underwater light source, and is higher in adaptive capacity and higher in accuracy compared with normal morphological feature extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of underwater image processing, and specifically relates to an underwater light source detection method, system, medium and program product based on the dark channel prior defogging algorithm. Background Art

[0002] Underwater images, as one of the main carriers of ocean information, play a crucial role in ocean exploration and are widely used in ocean engineering fields such as underwater target recognition, resource development, and underwater robots. However, in the underwater environment, wavelength-related light attenuation causes the longer-wavelength red light to be absorbed first, resulting in a bluish-green bias in underwater images. Moreover, the hardware performance requirements for underwater light source image acquisition are very high, the system is complex and the cost is relatively high. Therefore, the images collected still have problems such as blurred details and low contrast, and it is necessary to use underwater image processing technology to extract the information required in engineering practice from underwater images.

[0003] Due to the relatively complex underwater environment, the target light source is interfered by scattering, absorption, and various noises during the process of reaching the camera's photosensitive element, which changes the shooting performance of the camera. Conventional detection methods often fail to meet the detection accuracy requirements. Therefore, it is necessary to process underwater light source images to more accurately extract the light contour, highlight the light source characteristics, and then identify and extract the light source information to lay a foundation for the next work. Summary of the Invention

[0004] The purpose of the present invention is to provide an underwater light source detection method, system, medium and program product based on the dark channel prior defogging algorithm. The specific steps are as follows:

[0005] An underwater light source extraction method based on the dark channel prior defogging algorithm, and the specific steps are:

[0006] Step 1: Use OpenCV to read the underwater light source image;

[0007] Step 2: Use the function dark_channel() to calculate the dark channel image of the underwater light source image;

[0008] Step 3: Input the underwater light source image read in Step 1 and the dark channel image calculated in Step 2 into the function get_A() to obtain the ambient light coefficient A;

[0009] Step 4: Input the underwater light source image read in Step 1 and the ambient light coefficient A calculated in Step 3 into the function get_t() to obtain the medium transmittance coefficient

[0010] Step 5: Use the medium transmittance coefficient calculated in Step 4 to calculate the depth map of the underwater light source image;

[0011] Step 6: Input the underwater light source image read in Step 1 and the depth map calculated in Step 5 into the function find_light_first() to obtain the light mask image of the underwater light source image;

[0012] Step 7: Use the function findContours() in OpenCV to extract the contours in the light mask image obtained in Step 6, screen the extracted contours according to the contour length and circularity, then calculate the first-order moment of the contour through the function moments() in OpenCV, and further calculate the centroid of the contour for the pose estimation of the underwater robot.

[0013] Further, the dark channel minimum filtering radius in Step 2 is kernel_size = 15, and the dark channel image calculation formula is as follows:

[0014]

[0015] where Ω(x) is the pixel block of the neighborhood size of kernel_size of x, c is the RGB three channels of the image, and J c is the underwater light source image for which the dark channel needs to be calculated.

[0016] Further, the dark channel pixel extraction weight in Step 3 is percent = 0.001; calculate the mean values of the RGB three-channel images of the underwater light source image, and then calculate the mean value of the gray values of the pixels at the corresponding pixel positions in the mean image for the top 0.1% of the pixel brightness in the dark channel image, and use this mean value as the ambient light coefficient A; among them, in order to improve the calculation speed, the mark_top_n() function only calculates the pixel values of the pixel brightness of the 0.1%, assigns 1 to the pixel points in the image greater than this pixel value, and assigns 0 to the pixel points less than this pixel value.

[0017] Further, the medium transmittance coefficient in Step 4 has the following calculation formula:

[0018]

[0019] where ω is the defogging degree weight value, ω = 0.5 in this project, and J c is the underwater light source image for calculating the dark channel, and the minimum value of the medium transmittance coefficient is

[0020] Further, the calculation formula of the depth map in Step 5 is as follows:

[0021]

[0022] where is the medium transmittance coefficient calculated in step 4; the obtained depth map needs to be normalized, and the calculation formula is as follows:

[0023]

[0024] In the formula, depth max and depth min are respectively the maximum and minimum values of the gray values of the depth map depth calculated in the previous step.

[0025] Further, in step 6, the parameters are set as the brightness tolerance error error = 5 and the brightness rate light_percent = 0.85; first, calculate the sum of the RGB three-channel pixel values at each position of the underwater light source image, and use the function mark_top_n() to obtain the positions of the top 0.05% pixel points with the largest values. If the average gray value of these pixel points in the depth map is less than light_percent × 255, it is considered that the light source is pure black in the depth map. On the contrary, if the average gray value of the pixel points in the depth map is greater than light_percent × 255, it is considered that the light source is pure white in the depth map. The error parameter controls the allowable range of pixel values in the depth map. If the light source is pure black, it is considered that the pixel points with pixel values less than 0 + error in the depth map are the light source positions. If the light source is pure white, it is considered that the pixel points with pixel values less than 255 - error in the depth map are the light source positions.

[0026] Further, the condition for the contour in step 7 is that the contour length is greater than 10 and the circularity is greater than 0.6.

[0027] A computer device / system, comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the steps of the underwater light source detection method based on the dark channel prior defogging algorithm.

[0028] A computer-readable storage medium, on which a computer program / instruction is stored, and when the computer program / instruction is executed by a processor, the steps of the underwater light source detection method based on the dark channel prior defogging algorithm are implemented.

[0029] A computer program product, comprising a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the underwater light source detection method based on the dark channel prior defogging algorithm are implemented.

[0030] The beneficial effects of the present invention are as follows:

[0031] The present invention can quickly and accurately calculate the position of the underwater light source, and has stronger adaptive ability and higher accuracy than normal morphological feature extraction. Description of the Drawings

[0032] Figure 1 Flow chart of an underwater light source extraction method for the dark channel prior dehazing algorithm;

[0033] Figure 2 For the light source detection effect;

[0034] Figure 3 Comparison of the results of the light source detection method of this patent and the light source detection method based on the HSV color space;

[0035] Figure 4 Comparison of the results of the light source detection method of this patent and the adaptive underwater light source detection method based on multi-feature fusion. Detailed implementation mode

[0036] The present invention will be further described below with reference to the accompanying drawings.

[0037] To make the technical solutions and advantages of the present invention clearer, the following combines the attached Figure 1 and 2 to clearly and completely describe the technical solutions in the embodiments of the present invention.

[0038] Step 1: Read the underwater light source image. Use OpenCV to read the underwater light source image and input the read image into the function dehaze() of the dark channel prior dehazing. Use the function imread in OpenCV to read the underwater light source image. To make the calculation speed faster, the pixel values of the read picture are stored using 8-bit unsigned integers instead of floating-point numbers.

[0039] Step 2: Calculate the dark channel map. Use the function dark_channel() to calculate the dark channel image of the underwater light source image. Set the parameter of the minimum dark channel filtering radius kernel_size = 15. The formula for the dark channel image is as follows:

[0040]

[0041] In the formula, Ω(x) is the pixel block of the neighborhood size of kernel_size of x, c is the RGB three channels of the image, and J c is the underwater light source image for which the dark channel needs to be calculated.

[0042] Step 3: Calculate the ambient light coefficient A. Input the underwater light source image read in Step 1 and the dark channel image calculated in Step 2 into the function get_A() to obtain the ambient light coefficient A. Set the weight percent of dark channel pixel extraction to 0.001. The ambient light coefficient A needs to calculate the mean values of the RGB three-channel images of the underwater light source image, and then calculate the mean value of the gray values of the pixels at the corresponding positions in the mean image of the top 0.1% of the brightness values of the dark channel image. Use this mean value as the ambient light coefficient A; among them, the pixels of the top 0.1% of the brightness values of the dark channel image are calculated using the mark_top_n() function. To improve the calculation speed, the mark_top_n() function only calculates the pixel values of the pixels with the brightness of the 0.1% pixels. For the pixel points in the image greater than this pixel value, assign 1, and for the pixel points less than this pixel value, assign 0.

[0043] Step 4: Calculate the medium transmittance coefficient Input the underwater light source image read in Step 1 and the ambient light coefficient A calculated in Step 3 into the function get_t() to obtain the medium transmittance coefficient Set the weight ω of the defogging degree to 0.5, and the minimum value of the medium transmittance coefficient The medium transmittance coefficient The calculation formula is as follows:

[0044]

[0045] In the formula, ω is the weight of the defogging degree. In this project, ω = 0.5, c is the RGB three channels of the image, and J c is the underwater light source image for calculating the dark channel. To prevent the brightness of some pixel blocks in the depth map obtained in Step 5 from being too large, the minimum value of the medium transmittance coefficient is set

[0046] Step 5: Calculate the depth map. Use the medium transmittance coefficient calculated in Step 4 to calculate the depth map of the underwater light source image. The calculation formula of the depth map is as follows:

[0047]

[0048] In the formula, the medium transmittance coefficient calculated in Step 4 The obtained depth map also needs to be normalized. The calculation formula is as follows:

[0049]

[0050] In the formula, depth max and depth min are the maximum and minimum values of the gray values of the depth map depth calculated in the previous step, respectively.

[0051] Step 6: Calculate the light mask image. Input the underwater light source image read in Step 1 and the depth map calculated in Step 5 into the function find_light_first() to obtain the light mask image of the underwater light source image. Set the parameters: brightness tolerance error error = 5, and brightness rate light_percent = 0.85. Through experiments, it is found that due to the extremely dark underwater environment and the extremely bright light source, the light source position in the depth map of the underwater light source obtained by the dark channel prior dehazing algorithm is often pure black (pixel value is 0) or pure white (pixel value is 255); first, calculate the sum of the RGB three-channel pixel values at each position of the underwater light source image, and use the function mark_top_n() to obtain the positions of the top 0.05% pixel points with the largest values. If the average gray value of these pixel points in the depth map is less than light_percent × 255, it is considered that the light source is pure black in the depth map, and vice versa. If the average gray value of the pixel points in the depth map is greater than light_percent × 255, it is considered that the light source is pure white in the depth map; the error parameter can control the allowable range of pixel values in the depth map. If the light source is pure black, it is considered that the pixel points with pixel values less than 0 + error in the depth map are the light source positions. If the light source is pure white, it is considered that the pixel points with pixel values less than 255 - error in the depth map are the light source positions.

[0052] Step 7: Calculate the light source position. Use the function findContours() in OpenCV to extract the contours in the light mask image obtained in Step 6, and screen the extracted contours. The screening condition is 7. The centroid of the contour that meets the screening condition is the light source position. The screening conditions for the light contour include the contour length and circularity. The centroid of the contour is calculated by using the function moments() in OpenCV to calculate the first-order moment of the contour, and then calculate the centroid of the contour for the pose estimation of the underwater robot.

[0053] Example 1: To make the advantages of the present invention clearer, the present invention is compared with the underwater light source detection method based on the HSV color space below.

[0054] The flow of the underwater light source detection algorithm based on the HSV color space:

[0055] Step 1: Set hyperparameters. Set the initial HSV threshold range, the minimum threshold range [110, 110, 110], the maximum threshold range [255, 255, 255]; set the minimum area threshold to 100.

[0056] Step 2: Adaptive threshold adjustment. Read the underwater light source image, convert the original image in the RGB color space to the HSV color space, then calculate the luminance channel histogram using the image in the HSV color space, and then use kernel density estimation to analyze the luminance channel histogram to obtain the luminance distribution, and finally dynamically adjust the threshold using the peak value of the luminance distribution.

[0057] Step 3: Detection and analysis of the light source. Use the dynamic threshold obtained in Step 2 to create a binary mask image of the underwater light source image, and use morphological operations to process the mask image for noise reduction.

[0058] Step 4: Light source information extraction. Extract the contours from the denoised binary mask image obtained in Step 3, screen the contours using the area, and finally use the centroid of the contours that meet the requirements as the center of the light source.

[0059] Combined with Figure 3 and Table 1, by comparing the two light source detection algorithms, the conclusion can be drawn that the underwater light source detection method proposed in this patent has higher detection accuracy and better detection effect of the light source center compared with the traditional light source detection method based on the HSV color space; moreover, the light source detection method based on the HSV color space needs to change the initial HSV threshold range according to the change of the underwater environment, and the light source extraction effect also depends on the initial value, while the present invention requires fewer parameters to be adjusted and has higher detection accuracy.

[0060] Table 1 Error comparison between the light source detection method of this patent and the light source detection method based on the HSV color space

[0061]

[0062] Example 2: To make the advantages of the present invention clearer, the present invention will be compared with the adaptive underwater light source detection method based on multi-feature fusion below.

[0063] Steps of the adaptive underwater light source detection method based on multi-feature fusion:

[0064] Step 1: Image enhancement. First, convert the input image from the RGB color space to the LAB color space, then apply CLAHE enhancement to the L channel, and finally convert the enhanced image from the LAB color space to the RGB color space.

[0065] Step 2: Calculation of the light source mask image. Convert the enhanced image obtained in Step 1 from the RGB color space to the HSV color space and the grayscale space respectively, and use the weighted calculation of the V channel in the HSV color space and the grayscale space to obtain the light source mask image.

[0066] Step 3: Image denoising. Automatically determine the gray threshold for the light source mask image obtained in Step 2 using the Otsu method to obtain a gray image, and then use morphological processing to process the noise in the gray image.

[0067] Step 4: Light source information extraction. Extract the contour of the denoised light source mask image obtained in Step 3, screen the contour using the area, and finally use the centroid of the contour that meets the requirements as the center of the light source.

[0068] Combined with the attached Figure 4 , by comparing the two light source detection algorithms, it can be concluded that the underwater light source detection method proposed in this patent has the same detection accuracy as the multi-feature fusion adaptive underwater light source detection method under normal circumstances. However, in the underwater environment, the closer to the light source, the more obvious the halo is, and the halo will affect the detection effect of the multi-feature fusion adaptive underwater light source detection method. As shown in the right image of the attached Figure 4 , the method proposed in the present invention is less affected by the halo and has a better detection effect on the light source.

[0069] The function of the underwater light source detection system based on the dark channel prior defogging algorithm of the present invention can be described by the aforementioned underwater light source detection method based on the dark channel prior defogging algorithm. The system includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage section 308 into the random access memory (RAM) 303, such as executing the method described in the above embodiments. In the RAM 303, various programs and data required for the operation of the rescue response system are also stored. The CPU 301, ROM 302, and RAM 303 are connected to each other through the bus 304. The input / output (I / O) interface 305 is also connected to the bus 304.

[0070] The following components are connected to the I / O interface 305: an input section 306 including an audio input device, a button switch, etc.; an output section 307 including a liquid crystal display (LCD), an audio output device, an indicator light, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. The drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed so that a computer program read from it can be installed into the storage section 308 as needed.

[0071] Specifically, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication section 309, and / or installed from the removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, various functions defined in the present invention are executed.

[0072] It should be noted that specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or combined with an instruction execution system, device, or device.

[0073] Specifically, the underwater light source detection system based on the dark channel prior dehazing algorithm in this embodiment includes a processor and a memory, and a computer program is stored on the memory. When the computer program is executed by the processor, the underwater light source detection method provided in the above embodiment is implemented.

[0074] As another aspect, the present invention further provides a computer-readable storage medium, which may be included in the underwater light source detection system based on the dark channel prior defogging algorithm described in the above embodiments; or it may exist alone without being assembled into the underwater light source detection system based on the dark channel prior defogging algorithm. The above storage medium carries one or more computer programs, and when the above one or more computer programs are executed by a processor of the underwater light source detection system based on the dark channel prior defogging algorithm, the underwater light source detection system based on the dark channel prior defogging algorithm implements the underwater light source detection method based on the dark channel prior defogging algorithm provided in the above embodiments.

[0075] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An underwater light source extraction method based on the dark channel prior defogging algorithm, characterized in that: The specific steps are as follows: Step 1: Use OpenCV to read the underwater light source image; Step 2: Use the function dark_channel() to calculate the dark channel image of the underwater light source image; Step 3: Input the underwater light source image read in Step 1 and the dark channel image calculated in Step 2 into the function get_A() to obtain the ambient light coefficient A; Step 4: Input the underwater light source image read in Step 1 and the ambient light coefficient A calculated in Step 3 into the function get_t() to obtain the medium transmittance coefficient Step 5: Use the medium transmittance coefficient calculated in Step 4 to calculate the depth map of the underwater light source image; Step 6: Input the underwater light source image read in Step 1 and the depth map calculated in Step 5 into the function find_light_first() to obtain the light mask image of the underwater light source image; Step 7: Use the function findContours() in OpenCV to extract the contours in the light mask image obtained in Step 6, filter the extracted contours according to the contour length and circularity, and then calculate the first moment of the contour through the function moments() in OpenCV, and further calculate the centroid of the contour for the pose estimation of the underwater robot.

2. The underwater light source extraction method based on the dark channel prior dehazing algorithm according to claim 1, wherein: The dark channel minimum filtering radius in Step 2 is kernel_size = 15, and the dark channel image calculation formula is as follows: Where, Ω(x) is a pixel block with a neighborhood size of kernel_size of x, c represents the three RGB channels of the image, and J c is the underwater light source image for which the dark channel needs to be calculated.

3. An underwater light source extraction method based on the dark channel prior defogging algorithm according to claim 1, characterized in that: The dark channel pixel extraction weight in Step 3 is percent = 0.001; calculate the mean values of the RGB three-channel images of the underwater light source image, and then calculate the mean value of the gray values of the pixels at the corresponding pixel positions in the mean image for the top 0.1% of the pixel brightness values in the dark channel image, and use this mean value as the ambient light coefficient A; Among them, in order to improve the calculation speed, the mark_top_n() function only calculates the pixel values of the pixel brightness of the top 0.1%, assigns 1 to the pixel points in the image greater than this pixel value, and assigns 0 to the pixel points less than this pixel value.

4. A method for extracting underwater light sources based on the dark channel prior dehazing algorithm according to claim 1, characterized in that: The medium transmittance coefficient in step 4 has the following calculation formula: Where ω is the weight of the defogging degree. In this project, ω = 0.5, and J c is the underwater light source image for calculating the dark channel, and the minimum value of the medium transmittance coefficient is 5. A method for extracting underwater light sources based on the dark channel prior defogging algorithm according to claim 1, characterized in that: The calculation formula of the depth map in Step 5 is as follows: wherein, is the medium transmittance coefficient calculated in Step 4; the obtained depth map needs to be normalized, and the calculation formula is as follows: where depth max and depth min are the maximum and minimum values of the grayscale values of the depth map depth calculated in the previous step, respectively.

6. The underwater light source extraction method based on the dark channel prior dehazing algorithm according to claim 1, characterized in that: In Step 6, set the parameters brightness tolerance error error = 5 and brightness rate light_percent = 0.85; first calculate the sum of the RGB three-channel pixel values at each position of the underwater light source image, use the function mark_top_n() to obtain the positions of the top 0.05% of the pixel points with the largest values, if the average gray value of these pixel points in the depth map is less than light_percent × 255, it is considered that the light source is pure black in the depth map, otherwise if the average gray value of the pixel points in the depth map is greater than light_percent × 255, it is considered that the light source is pure white in the depth map; the error parameter controls the allowable range of pixel values in the depth map, if the light source is pure black, it is considered that the pixel points in the depth map with pixel values less than 0 + error are the light source positions, and if the light source is pure white, it is considered that the pixel points in the depth map with pixel values less than 255 - error are the light source positions.

7. The underwater light source extraction method based on the dark channel prior dehazing algorithm according to claim 1, characterized in that: The condition for the contour in Step 7 is that the contour length is greater than 10 and the circularity is greater than 0.

6.

8. A computer device / apparatus / system, comprising a memory, a processor, and a computer program stored on the memory, characterized in that: The processor executes the computer program to implement the steps of the method described in any one of claims 1 to 6.

9. A computer-readable storage medium having computer programs / instructions stored thereon, characterized in that: When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that: When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 7 are implemented.