Method and apparatus for color restoration of underwater images and videos
The method addresses the distortion of underwater images by converting pixel values to linear sRGB space, adjusting based on channel averages, and fusing pixel values to restore natural colors, outperforming manual adjustments in image quality.
Patent Information
- Application Number
- JP2023524834
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-10-23
- Filing Date
- 2021-10-22
- Publication Date
- 2024-10-10
- Estimated Expiration
- 2041-10-22
AI Technical Summary
Conventional underwater image processing methods fail to accurately restore red colors, resulting in distorted images with a blue or green bias, and manual adjustments are time-consuming and lack pixel-specific precision.
A method involving pixel value conversion to linear sRGB space, adjustment based on channel averages, weight calculation, gain calculation, and pixel value fusion to restore natural colors in underwater images and videos.
The method achieves natural and rich colors in underwater imagery, enhancing the viewing experience by preserving the blue-green background while correcting red deficiencies, surpassing manual adjustments in effectiveness.
Smart Images

Figure 0007565445000004 
Figure 0007565445000005 
Figure 0007565445000006
Abstract
Description
[Technical field]
[0001] The present application relates to the technical field of image processing, and in particular to a method, apparatus and computer-readable storage medium for color restoration of underwater images and videos. [Background technology]
[0002] Obtaining real underwater images is particularly important because underwater vision is not only widely applied in scientific research activities such as ocean sounding and underwater construction monitoring, but is also an important source of photography materials for many photography enthusiasts.
[0003] Among visible light, red light has a longer wavelength, and therefore is attenuated more when propagating through water than blue and green light. As a result, the image sensor of the photographing device receives much less red light information than blue and green light information, resulting in a serious lack of red in the image photographed underwater, distorting the colors of underwater scenery, and causing the overall color to be biased toward blue or green. Summary of the Invention [Problem to be solved by the invention]
[0004] The auto white balance of a normal camera cannot handle scenes with serious underwater red information loss, and the processed image often has missing or overcompensated red information, making the whole image biased toward purple. Subsequent manual video color adjustment can restore the proper underwater color to some extent, but it takes a lot of time and cannot specially adjust each pixel of the image for each frame.
[0005] SUMMARY OF THE PRESENT DISCLOSURE The objective of the present invention is to provide a method, apparatus, electronic device and computer-readable storage medium for color restoration of underwater images, so as to overcome the shortcomings existing in the conventional underwater image restoration methods. [Means for solving the problem]
[0006] According to a first aspect, the present invention provides a method for producing a method for manufacturing a semiconductor device comprising the steps of: The 8-bit RGB pixel value of each pixel in the underwater image is obtained and converted into the linear sRGB space, that is, the pixel value r i-0 , the pixel value in the green channel g i-0 , the pixel value in the blue channel b i-0 , and converts the pixel value r i-1 , the pixel value in the green channel g i-1 , the pixel value in the blue channel b i-1 Step S1 to obtain Based on the relative magnitude of the pixel average value in each channel of each pixel acquired in step S1, the pixel value in each channel of each pixel is adjusted, and the pixel value r i-2 , the pixel value in the green channel g i-2 , the pixel value in the blue channel b i-2 Step S2 to obtain Based on the pixel values in each channel of each pixel after the adjustment in step S2, the weight value ω i Step S3 of calculating The weight value ω obtained in step S3 i Based on the above, the gain Rg of the red channel and the gain Bg of the blue channel of the image are calculated, and the pixel values of each pixel in each channel after the adjustment in step S2 are adjusted based on the gain Rg of the red channel and the gain Bg of the blue channel. The pixel values r of the red channel of each pixel after the adjustment are calculated. i-2 , the pixel value in the green channel g i-2 , the pixel value in the blue channel b i-2 Step S4 to obtain The pixel value in the linear sRGB space of each pixel after the adjustment in step S4 is converted to an 8-bit RGB pixel value, and the pixel value r in the red channel of each pixel after the conversion is i-3 , the pixel value in the green channel g i-3 , the pixel value in the blue channel b i-3 Step S5 to obtain Step S6: sorting the pixel values of each pixel in each channel in step S5 according to the magnitude, and obtaining the large and small adjustment values of each channel based on the sorting result, and obtaining the large and small adjustment values of each channel, i.e., the large adjustment value Rmax and the small adjustment value Rmin of the red channel, the large adjustment value Gmax and the small adjustment value Gmin of the green channel, and the large adjustment value Bmax and the small adjustment value Bmin of the blue channel; Based on the large adjustment value of each channel and the small adjustment value of each channel in step S6, the pixel value in each channel of each pixel in step S5 is adjusted, and the pixel value r in the red channel of each pixel after adjustment is i-4 , the pixel value in the green channel g i-4 , the pixel value in the blue channel b i-4 Step S7 to obtain Weight value ω in step S3 i Based on the above, the 8-bit RGB pixel value of each pixel acquired in step S1 is combined with the pixel value in each channel of each pixel after adjustment in step S7, and the pixel value r in the red channel of each pixel after the combination is obtained. i-5 , the pixel value in the green channel g i-5 , the pixel value in the blue channel b i-5 and outputting a restored underwater image based on the pixel values in each channel of each pixel after the fusion.
[0007] According to a second aspect, the present invention provides a method for producing a method for manufacturing a semiconductor device comprising the steps of: Obtaining an underwater video to be restored; and processing each video frame of the underwater video to be restored with the underwater image color restoration method to obtain a color restored video.
[0008] According to a third aspect, the present invention provides a method for producing a method for manufacturing a semiconductor device comprising the steps of: a first acquisition module for acquiring an 8-bit RGB pixel value of each pixel of the underwater image; a first transformation module for transforming the 8-bit RGB pixel value of each pixel into a linear sRGB space; a first adjustment module for adjusting a pixel value in each channel of each pixel based on a relative magnitude of a pixel average value in each channel of each pixel in a linear sRGB space; a weight calculation module for calculating pixel values in each channel of each pixel adjusted by the first adjustment module and calculating a weight value of each pixel; a gain calculation module for calculating gains for red and blue channels of the image based on the weight values; a second adjustment module for adjusting the pixel value in each channel of each pixel adjusted by the first adjustment module according to the gain of the red channel and the gain of the blue channel; a second conversion module for converting the pixel value in the linear sRGB space of each pixel adjusted by the second adjustment module into an 8-bit RGB pixel value; a second acquisition module for acquiring a large adjustment value and a small adjustment value of each channel converted by the second conversion module, the large adjustment value and the small adjustment value of each channel being related to a sorting result after sorting the pixel values of each pixel in each channel according to magnitude; a third adjustment module for adjusting pixel values in each channel of each pixel transformed by the second transformation module according to the large adjustment value and the small adjustment value of each channel; a fusion module for fusing the 8-bit RGB pixel value of each pixel acquired by the first acquisition module and the pixel value of each channel of each pixel adjusted by the third adjustment module based on the weight value calculated by the weight calculation module to obtain a pixel value of each channel of each pixel after fusion; and an output module for outputting pixel values in each channel of each pixel fused by the fusion module.
[0009] According to a fourth aspect, the present invention provides a method for producing a method for manufacturing a semiconductor device comprising the steps of: a video capture module for capturing underwater video to be restored; and a video restoration module for processing each video frame of the underwater video to be restored with the above-mentioned underwater image color restoration method to obtain a color-restored video.
[0010] According to a fifth aspect, the present invention provides a method for producing a method for manufacturing a semiconductor device comprising the steps of: A memory in which a computer program is stored; and a processor for executing the computer program to implement the above-mentioned method for color restoration of underwater images or underwater videos.
[0011] According to a sixth aspect, the present invention provides a computer-readable storage medium having a computer program stored therein, the computer program realizing the above-mentioned underwater image or underwater video color restoration method when executed by a processor. Effect of the Invention
[0012] Compared with the prior art, the present invention performs color restoration in specific steps for each pixel in an underwater image, so that the color of the foreground objects in the underwater images or underwater videos processed in the manner of the present invention is natural and rich, while retaining the natural blue-green color of the background seawater, thereby obviously improving the overall viewing experience and reaching and even exceeding the effects that can be achieved by a large amount of manual color adjustment. [Brief description of the drawings]
[0013] [Figure 1] 2 is a flowchart of a method for color restoration of underwater images in an embodiment of the present invention. [Diagram 2] FIG. 2 is a structural block diagram of an underwater image color restoration device according to an embodiment of the present invention; [Diagram 3] FIG. 2 is a structural block diagram of an underwater video color restoration device according to an embodiment of the present invention; [Figure 4] FIG. 2 is a structural block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0014] In order to clarify the objectives, technical solutions and beneficial effects of the present invention, the present invention will be described in more detail with reference to the drawings and examples below. It should be noted that the specific examples described herein are only for interpreting the present invention and are not used to limit the present invention.
[0015] In order to illustrate the technical solution described in the present invention, specific examples are given below. Example 1
[0016] As shown in FIG. 1, this embodiment discloses a method for color restoration of underwater images, which includes the following steps:
[0017] In this embodiment, the underwater images are photographs or video frames taken underwater by a photographing device.
[0018] S0: Convert underwater images from other color spaces to 8-bit RGB space.
[0019] If the captured photo or video frame is originally in 8-bit RGB space, then directly enter step S1; if the captured photo or video frame is in other space (e.g. YUV), then it needs to be converted to 8-bit RGB space and then enter step S1.
[0020] S1: Obtain the 8-bit RGB pixel value of each pixel of the underwater image and convert it into linear sRGB space, i.e., the pixel value r i-0 , the pixel value in the green channel g i-0 , the pixel value in the blue channel b i-0 , and converts the pixel value r i-1 , the pixel value in the green channel g i-1 , the pixel value in the blue channel b i-1 get.
[0021] First, for each pixel, the pixel value r in the red channel of the 8-bit RGB pixel value (range 0-255) i-0 , the pixel value in the green channel g i-0 and the pixel value b in the blue channel i-0 Then, the pixel values in each channel are converted to the linear sRGB space by adopting the sRGB standard, and the pixel value r in the red channel of each pixel in the linear sRGB space is obtained. i-1 , the pixel value in the green channel g i-1 and the pixel value b in the blue channel i-1 The range of pixel values in the linear sRGB space after conversion is 0 to 1. For specific conversion information, see https: / / www.w3.org / Graphics / Color / sRGB.
[0022] In this embodiment, for any pixel of the underwater image, the pixel values in each channel thereof can be transformed from 8-bit RGB space to linear sRGB space as follows:
[0023] Divide the pixel value of each channel in the 8-bit RGB space (range 0-255) of each acquired pixel by 255, and obtain r i-0 ÷255, g i-0 ÷255, b i-0 If ÷255 is less than 0.03928, the pixel value of each pixel in the linear sRGB space after conversion is r i-1 =r i- 0÷255÷12.92, g i-1 =g i-0 ÷255÷12.92, b i-1 =b i-0 ÷255÷12.92, otherwise the pixel values in linear sRGB space of each pixel after conversion are r i-1 =[(r i-0 ÷255+0.055)÷1.055]^2.4, g i-1 =[(g i-0 ÷255+0.055)÷1.055]^2.4, b i-1 =[(bi-0 ÷255+0.055)÷1.055]^2.4.
[0024] S2: Based on the relative magnitude of the pixel average value in each channel of each pixel acquired in step S1, the pixel value in each channel of each pixel is adjusted, and the pixel value r in the red channel of each pixel after the adjustment is calculated. i-2 , the pixel value in the green channel g i-2 , the pixel value in the blue channel b i-2 get.
[0025] In this embodiment, the pixel average value Ra in the red channel, the pixel average value Ga in the green channel, and the pixel average value Ba in the blue channel are obtained for each pixel. When the pixel average value Ga in the green channel is the largest, the pixel value r in the adjusted red channel is i-2 =r i-1 +(Ga-Ra)×(1.5-r i-1 )×g i-1 Then, the pixel value b in the adjusted blue channel i-2 =b i-1 +(Ga-Ba)×(1-b i-1 )×g i-1 Then, the pixel value g in the adjusted green channel i-2 =g i-1 When the average pixel value Ba in the blue channel is the largest, the pixel value r i-2 =r i-1 +(Ba-Ra)×(1.5-r i-1 )×g i-1 Then, the pixel value b in the adjusted blue channel i-2 =b i-1 Then, the pixel value g in the adjusted green channel i-2 =g i-1 -(Ba-Ga) x (1-g i-1 )×g i-1 If the pixel average value Ra in the red channel is the largest, the pixel values are not adjusted, that is, the pixel value r i-2 =r i-1 , the pixel value in the green channel g i-2 =g i-1, and the pixel value b in the blue channel i-2 =b i-1 It is.
[0026] S3: Based on the pixel values in each channel of each pixel after adjustment in step S2, a weight value ω i Calculate.
[0027] In this embodiment, the weight value ω of each pixel i The formula for calculating ω i =(r i-2 +α)*β / (b i-2 +α), where α and β are empirical values. Specifically, in one optimal embodiment of this embodiment, the value of α is 0.00015, the value of β is 3, and the weight value ω i is adjusted based on the calculation results, and ω i If the calculated value of is less than 0.1, then ω i Adjust the value of to 0.1 and ω i If the calculated value of is greater than 0.8, then ω i Adjust the value of to 0.8 and ω i If the calculated value of is between 0.1 and 0.8, then ω i Do not adjust the value of
[0028] S4: The weight value ω obtained in step S3 i Based on the above, the gain Rg of the red channel and the gain Bg of the blue channel of the image are calculated, and the pixel values of each pixel in each channel after the adjustment in step S2 are adjusted based on the gain Rg of the red channel and the gain Bg of the blue channel. The pixel values r of the red channel of each pixel after the adjustment are calculated. i-3 , the pixel value in the green channel g i-3 , the pixel value in the blue channel b i-3 get.
[0029] Step S4 in this embodiment includes the following sub-steps.
[0030] S41: Pixel value r in the red channel of each pixel i-2 , the pixel value in the green channel g i-2, the pixel value in the blue channel b i-2 and weight value ω i Based on the above, the weighted average value in the red channel, the weighted average value in the green channel, and the weighted average value in the blue channel of each pixel are calculated. Here, the weighted average value in the red channel is calculated by the following formula: JPEG0007565445000001.jpg15170The formula for the weighted average value in the green channel is: JPEG0007565445000002.jpg16170The formula for the weighted average value in the blue channel is: JPEG0007565445000003.jpg17170 where n represents the number of pixels in the image.
[0031] S42: The red channel gain Rg=Gaw / Raw and the blue channel gain Bg=Gaw / Baw are calculated.
[0032] S43: Pixel value r after gain of the red channel of each pixel i-3 =r i-2 *Pixel value b after gain of Rg and blue channels i-3 =b i-2 *Calculate Rg, but if the pixel value after gain is greater than 1, adjust the pixel value to 1 to satisfy the requirement that the pixel value range of each pixel in the linear sRGB space is 0 to 1.
[0033] S5: Convert the pixel value in the linear sRGB space of each pixel after the adjustment in step S4 into an 8-bit RGB pixel value, and convert the pixel value r i-4 , the pixel value in the green channel g i-4 , the pixel value in the blue channel b i-4 get.
[0034] According to the sRGB standard, the pixel value of each channel of each pixel is converted from linear sRGB (0-1) to 8-bit RGB (0-255), and the conversion method is as follows:
[0035] ri-3 , g i-3 , b i-3 If both are smaller than 0.00304, the pixel values in 8-bit RGB of each pixel after conversion are r i-4 =r i-3 *255*12.92, g i-4 =g i-3 *255*12.92, b i-4 =b i-3 *255*12.92, Otherwise, the pixel values of each pixel after conversion in 8-bit RGB are r i-4 =(1.055*r i-3 ^(1 / 2.4)-0.055)*255, g i-4 =(1.055*g i-3 ^(1 / 2.4)-0.055)*255, b i-4 =(1.055*b i-3 ^(1 / 2.4)-0.055)*255.
[0036] S6: Sort the pixel values of each pixel in each channel in step S5 according to magnitude, and based on the sorting results, obtain the large adjustment value and small adjustment value of each channel, i.e., the large adjustment value Rmax and the small adjustment value Rmin of the red channel, the large adjustment value Gmax and the small adjustment value Gmin of the green channel, and the large adjustment value Bmax and the small adjustment value Bmin of the blue channel.
[0037] In this embodiment, the large and small adjustment values of each channel can be obtained in the following two ways.
[0038] The first method is as follows: First, in step S5, the pixel values of each pixel in each channel are sorted in descending order, and a predetermined percentage (e.g., 0.1%) of pixel values in each channel sorted to the top and a predetermined percentage (e.g., 0.1%) of pixel values in each channel sorted to the bottom are obtained, and the maximum average value and the minimum average value of each channel are obtained by calculation, and the maximum average value and the minimum average value of each channel are respectively set as the large adjustment value and the small adjustment value of each channel, i.e., the large adjustment value Rmax and the small adjustment value Rmin of the red channel, the large adjustment value Gmax and the small adjustment value Gmin of the green channel, and the large adjustment value Bmax and the small adjustment value Bmin of the blue channel.
[0039] The second method is as follows: First, in step S5, the pixel values of each pixel in each channel are sorted in ascending order, and the pixel value of the [n*0.1%]th pixel in each channel sorted in ascending order is set as the large adjustment value for each channel, and the pixel value of the [n*0.1%]th pixel from the end in each channel sorted in descending order is set as the small adjustment value for each channel, where n is the number of pixels and the symbol [ ] is an integer.
[0040] S7: Based on the large adjustment value of each channel in step S6 and the small adjustment value of each channel, the pixel value in each channel of each pixel in step S5 is adjusted, and the pixel value r in the red channel of each pixel after the adjustment is i-5 , the pixel value in the green channel g i-5 , the pixel value in the blue channel b i-5 get.
[0041] In this embodiment, firstly, a maximum value RGBmax is selected from the large adjustment value Rmax of the red channel, the large adjustment value Gmax of the green channel, and the large adjustment value Bmax of the blue channel, i.e., RGBmax=Max(Rmax, Gmax, Bmax), and a minimum value RGBmin is selected from the small adjustment value Rmin of the red channel, the small adjustment value Gmin of the green channel, and the small adjustment value Bmin of the blue channel, i.e., RGBmin=Mmin(Rmin, Gmin, Bmin), and the pixel values of each pixel in each channel are calculated by the following formulas:
[0042] r i-5 =(r i-4 -Rmin)*(RGBmax-RGBmin) / (Rmax-Rmin)+RGBmin g i-5 =(g i-4 -Gmin)*(RGBmax-RGBmin) / (Gmax-Gmin)+RGBmin b i-5 =(b i-4 -Bmin)*(RGBmax-RGBmin) / (Bmax-Bmin)+RGBmin.
[0043] S8: Weight value ω in step S3 i Based on the above, the 8-bit RGB pixel value of each pixel acquired in step S1 is combined with the pixel value in each channel of each pixel after adjustment in step S7, and the pixel value r in the red channel of each pixel after the combination is obtained. i-6 , the pixel value in the green channel g i-6 , the pixel value in the blue channel b i-6 and outputs a restored underwater image based on the pixel values of each pixel in each channel after fusion.
[0044] In this embodiment, the pixel value of each pixel in each channel after fusion can be calculated by the following formula:
[0045] r i-6 =r i-5 *ω i +r i-0 *(1-ωi ), g i-6 =g i-5 *ω i +g i-0 *(1-ω i ), b i-6 =b i-5 *ω i +b i-0 *(1-ω i ).
[0046] Then, based on the pixel values in each channel of each pixel after fusion, r i-6 , g i-6 , b i-6 The restored underwater image is output. Example 2
[0047] In this embodiment, a method for color restoration of underwater video is provided, which includes the following steps.
[0048] Step 1: Obtain the underwater video to be restored.
[0049] Step 2: Process each video frame of the underwater video to be restored with the underwater image color restoration method in embodiment 1 to obtain color restored video frames, and output the video frames in order to obtain color restored video.
[0050] In the best mode of this embodiment, when performing color restoration on a video frame other than the first frame of the underwater video to be restored, the gains of the red and blue channels of the current frame in step S4 are calculated according to the following formulas:
[0051] Rg i =Rg i-1 *θ1+Gaw / Raw*(1-θ1), Bg i =Bg i- 1*θ1+Gaw / Baw*(1-θ1), However, Rg i is the gain of the red channel of the current frame, Rg i-1is the gain of the red channel of the frame before the current frame, and Bg i is the gain of the blue channel of the current frame, Bg i-1 is the gain of the blue channel of the frame previous to the current frame, Raw is the weighted average value in the red channel of each pixel of the current frame calculated based on the weight value, Gaw is the weighted average value in the green channel of each pixel of the current frame calculated based on the weight value, and Baw is the weighted average value in the blue channel of each pixel of the current frame calculated based on the weight value, where Raw, Gaw, and Baw can be obtained by the calculation formula in Example 1, θ1 is the update rate and is an empirical value, and in this embodiment, the value of θ1 is 0.98.
[0052] In another optimal embodiment of this embodiment, when performing color restoration on a video frame other than the first frame of the underwater video to be restored, the large adjustment value and the small adjustment value of each channel in step S6 are calculated by the following formula:
[0053] Rmax i =Rmax i-1 *θ2+Rmax*(1-θ2), Rmin i =Rmin i-1 *θ2+Rmin*(1-θ2), Gmax i =Gmax i-1 *θ2+Gmax*(1-θ2), Gmin i =Gmin i-1 *θ2+Gmin*(1-θ2), Bmax i =Bmax i-1 *θ2+Bmax*(1-θ2), Bmin i =Bmin i-1 *θ2+Bmin*(1-θ2), However, Rmax i is the large adjustment value of the red channel of the current frame, Rmax i-1is the red channel maximum adjustment value of the previous frame of the current frame, Rmax is the red channel maximum adjustment value of each pixel in the current frame, which is calculated by sorting the pixel values according to the red channel, and Gmax i is the large adjustment value of the green channel of the current frame, Gmax i-1 is the maximum adjustment value of the green channel of the frame before the current frame, Gmax is the maximum adjustment value obtained by sorting and directly calculating the pixel values of the green channel of each pixel in the current frame, and Bmax i is the large adjustment value for the blue channel of the current frame, Bmax i-1 is the large adjustment value of the blue channel of the frame before the current frame, Bmax is the large adjustment value obtained by sorting and directly calculating based on the pixel values in the blue channel of each pixel of the current frame, and θ2 is the update rate, which is an empirical value. In this embodiment, θ2 is 0.98.
[0054] As can be seen from the above, in this embodiment, the adjustment of each pixel in a subsequent frame is relative to the corresponding pixel in the previous frame, so that the color conversion between corresponding pixel points in adjacent video frames is smoother, and the video output effect after color adjustment is more natural. Example 3
[0055] As shown in FIG. 3, in this embodiment, a color restoration device for underwater images is disclosed, which includes a first acquisition module for acquiring 8-bit RGB pixel values of each pixel of the underwater image, a first conversion module for converting the 8-bit RGB pixel values of each pixel into a linear sRGB space, a first adjustment module for adjusting pixel values in each channel of each pixel based on the relative magnitude of pixel average values in each channel of each pixel in the linear sRGB space, a weight calculation module for calculating pixel values in each channel of each pixel adjusted by the first adjustment module and calculating weight values of each pixel, a gain calculation module for calculating gains of red and blue channels of the image based on the weight values, a second adjustment module for adjusting the pixel values in each channel of each pixel adjusted by the first adjustment module based on the gains of the red and blue channels, and a pixel value in the linear sRGB space of each pixel adjusted by the second adjustment module. The image processing apparatus includes: a second conversion module for converting each channel into an 8-bit RGB pixel value; a second acquisition module for acquiring a large adjustment value and a small adjustment value of each channel converted by the second conversion module, where the large adjustment value and the small adjustment value of each channel are associated with a sorting result after sorting the pixel values of each pixel in each channel according to magnitude; a third adjustment module for adjusting a pixel value in each channel of each pixel converted by the second conversion module based on the large adjustment value and the small adjustment value of each channel; a fusion module for fusing the 8-bit RGB pixel value of each pixel acquired by the first acquisition module and the pixel value in each channel of each pixel adjusted by the third adjustment module based on a weight value calculated by the weight calculation module, to obtain a pixel value in each channel of each pixel after fusion; and an output module for outputting the pixel value in each channel of each pixel fused by the fusion module.
[0056] In an optimal embodiment of this embodiment, the system further includes an RGB conversion module for converting the underwater image to be restored from another color space into an 8-bit RGB space. Example 4
[0057] As shown in FIG. 4, this embodiment discloses a color restoration device for underwater video, which includes a video acquisition module for acquiring the underwater video to be restored, and a video restoration module for processing each video frame of the underwater video to be restored with the underwater image color restoration method in embodiment 2 to obtain a video after color restoration. Example 5
[0058] This embodiment discloses an electronic device, which includes a memory in which a computer program is stored, and a processor for executing the computer program to realize the underwater image color restoration method or the underwater video color restoration method in embodiment 1 or embodiment 2. Specifically, the electronic device in this embodiment may be a camera or a mobile phone. Example 6
[0059] This embodiment discloses a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, it realizes the underwater image color restoration method or the underwater video color restoration method in embodiment 1 or embodiment 2.
[0060] As can be understood by those skilled in the art, all or some of the steps of the various methods in the above embodiments can be instructed by a program to be completed by related hardware, and the storage medium may be a computer-readable storage medium, for example, a ferromagnetic random access memory (FRAM (registered trademark)), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash, a magnetic surface memory, an optical disk, or an optical disk read-only memory (CD-ROM), or may be various devices including one or any combination of the above memories.
[0061] The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for color restoration of an underwater image, comprising the steps of: The 8-bit RGB pixel value of each pixel of the underwater image is obtained and converted into a linear sRGB space, i.e., the pixel value r in the red channel of the 8-bit RGB of each pixel is i-0 , pixel value g in the green channel i-0 , pixel value b in the blue channel i-0 , and converts the pixel value r i-1 , pixel value g in the green channel i-1 , pixel value b in the blue channel i-1 Step S1 to obtain Based on the relative magnitude of the pixel average value in each channel of each pixel acquired in step S1, the pixel value in each channel of each pixel is adjusted, and the pixel value r i-2 , pixel value g in the green channel i-2 , pixel value b in the blue channel i-2 Step S2 to obtain Based on the pixel values in each channel of each pixel after the adjustment in step S2, the weight value ω i Step S3 of calculating The weight value ω obtained in step S3 i Based on the above, the gain Rg of the red channel and the gain Bg of the blue channel of the image are calculated, and the pixel values of each pixel in each channel after the adjustment in step S2 are adjusted based on the gain Rg of the red channel and the gain Bg of the blue channel. i-3 , pixel value g in the green channel i-3 , pixel value b in the blue channel i-3 Step S4 to obtain The pixel value in the linear sRGB space of each pixel after the adjustment in step S4 is converted to an 8-bit RGB pixel value, and the pixel value r in the red channel of each pixel after the conversion is i-4 , pixel value g in the green channel i-4 , pixel value b in the blue channel i-4 Step S5 to obtain Step S6 of sorting the pixel values of each pixel in each channel in step S5 according to size, and obtaining the large and small adjustment values of each channel based on the sorting results, i.e., the large adjustment value Rmax and the small adjustment value Rmin of the red channel, the large adjustment value Gmax and the small adjustment value Gmin of the green channel, and the large adjustment value Bmax and the small adjustment value Bmin of the blue channel; Based on the large adjustment value and the small adjustment value of each channel in step S6, the pixel value in each channel of each pixel in step S5 is adjusted, and the pixel value r in the red channel of each pixel after adjustment is i-5 , pixel value g in the green channel i-5 , pixel value b in the blue channel i-5 Step S7 to obtain Weight value ω in step S3 i Based on the above, the 8-bit RGB pixel value of each pixel acquired in step S1 is combined with the pixel value in each channel of each pixel after adjustment in step S7, and the pixel value r in the red channel of each pixel after the combination is calculated. i-6 , pixel value g in the green channel i-6 , pixel value b in the blue channel i-6 and outputting a restored underwater image based on the pixel values in each channel of each pixel after fusion.
2. 2. The method of claim 1, further comprising the step S0 of converting the underwater image from another color space into an 8-bit RGB space before step S1.
3. Specifically, in step S2, the pixel average value Ra in the red channel, the pixel average value Ga in the green channel, and the pixel average value Ba in the blue channel of each pixel are obtained, and when the pixel average value Ga in the green channel is the largest, the pixel value r in the adjusted red channel is i-2 = r i-1 +(Ga-Ra)×(1.5-r i-1 ) x g i-1Then, the pixel value b in the adjusted blue channel i-2 = b i-1 +(Ga-Ba)×(1-b i-1 ) x g i-1 Then, the pixel value g in the adjusted green channel i-2 = g i-1 When the average pixel value Ba in the blue channel is the largest, the pixel value r i-2 = r i-1 +(Ba-Ra)×(1.5-r i-1 ) x g i-1 Then, the pixel value b in the adjusted blue channel i-2 = b i-1 Then, the pixel value g in the adjusted green channel i-2 = g i-1 -(Ba-Ga)×(1-g i-1 ) x g i-1 When the pixel average value Ra in the red channel is the largest, the pixel values are not adjusted, i.e., the pixel value r i-2 = r i-1 , pixel value g in the green channel i-2 = g i-1 , pixel value b in the blue channel i-2 = b i-1 2. The method for color restoration of underwater images according to claim 1, wherein:
4. In step S3, specifically, the weighting value of each pixel is calculated by the following formula: i = (r i-2 +α)*β / (b i-2 2. The method of claim 1, wherein α and β are empirical values.
5. The value of α is 0.00015, the value of β is 3, and the weight value ω i is adjusted based on the calculation results, and ω i If the calculated value of is less than 0.1, then i Adjust the value of to 0.1, and ω i If the calculated value of is greater than 0.8, then i Adjust the value of to 0.8, and iIf the calculated value of is between 0.1 and 0.8, then ω i 5. The method for color restoration of underwater images according to claim 4, wherein the value of is not adjusted.
6. The step S4 is The pixel value r in the red channel of each pixel i-2 , pixel value g in the green channel i-2 , pixel value b in the blue channel i-2 and weight value ω i Step S41: calculating a weighted average value Raw in the red channel, a weighted average value Gaw in the green channel, and a weighted average value Baw in the blue channel of each pixel based on the above. A step S42 of calculating a red channel gain Rg=Gaw / Raw and a blue channel gain Bg=Gaw / Baw; The pixel value r of each pixel after gain in the red channel i-3 = r i-2 * Pixel value b after gain of Rg and blue channels i-3 = b i-2 and calculating *Rg, with the proviso that if the pixel value after the gain is greater than 1, adjusting the pixel value to 1.
7. The large and small adjustment values for each channel in step S6 are obtained as follows: The method for color restoration of underwater images as described in claim 1, characterized in that in step S5, the pixel values in each channel of each pixel are first sorted in descending order, and a predetermined percentage of the pixel values of each channel sorted to the top and a predetermined percentage of the pixel values of each channel sorted to the bottom are obtained, and the maximum average value and the minimum average value of each channel are obtained by calculation, and the maximum average value and the minimum average value of each channel are respectively set as the large adjustment value and the small adjustment value of each channel.
8. The large and small adjustment values for each channel in step S6 are obtained as follows: The color restoration method for underwater images described in claim 1, characterized in that in step S5, the pixel values of each pixel in each channel are sorted in ascending order, the pixel value of the [n*0.1%]th pixel sorted in ascending order in each channel is taken as the large adjustment value for each channel, and the pixel value of the [n*0.1%]th pixel from the end sorted in descending order in each channel is taken as the small adjustment value for each channel, where n is the number of pixels and the symbol [ ] indicates that the values are converted to an integer.
9. The pixel value of each pixel in each channel in step S7 is calculated by the following formula: r i-5 = (r i-4 -Rmin)*(RGBmax-RGBmin) / (Rmax-Rmin)+RGBmin, g i-5 = (g i-4 -Gmin)*(RGBmax-RGBmin) / (Gmax-Gmin)+RGBmin, b i-5 = (b i-4 -Bmin)*(RGBmax-RGBmin) / (Bmax-Bmin)+RGBmin, 2. The method of claim 1, wherein RGBmax=Max (Rmax, Gmax, Bmax) and RGBmin=Min (Rmin, Gmin, Bmin).
10. 2. The method for color restoration of underwater images according to claim 1, wherein the pixel value of each pixel in each channel in step S8 is calculated according to the following formula: r i-6 = r i-5 *ω i +r i-0 *(1-ω i ) g i-6 = g i-5 *ω i +g i-0 *(1-ω i ) b i-6 = b i-5 *ω i +b i-0*(1-ω i )
11. 1. A method for color restoration of underwater video, comprising: Obtaining an underwater video to be restored; A color restoration method for underwater videos, comprising: processing each video frame of the underwater video to be restored with the underwater image color restoration method described in any one of claims 1 to 8, and obtaining a color-restored video.
12. When performing color restoration on a video frame other than the first frame of the underwater video to be restored, the gains of the red and blue channels of the current frame in step S4 are calculated according to the following formula: Rg i = Rg i-1 *θ 1 +Gaw / Raw*(1-θ 1 ), Bg i = Bg i-1 *θ 1 +Gaw / Baw*(1-θ 1 ), Where Rg i is the gain of the red channel of the current frame, Rg i-1 is the gain of the red channel of the frame before the current frame, Bg i is the gain of the blue channel of the current frame, Bg i-1 is the gain of the blue channel of the frame preceding the current frame, Raw is the weighted average value of the red channel of each pixel of the current frame calculated based on the weight value, Gaw is the weighted average value of the green channel of each pixel of the current frame calculated based on the weight value, Baw is the weighted average value of the blue channel of each pixel of the current frame calculated based on the weight value, and θ 1 12. The method of claim 11, wherein: is the update rate.
13. When performing color restoration on a video frame other than the first frame of the underwater video to be restored, the large adjustment value and the small adjustment value of each channel in step S6 are calculated according to the following formula: Rmax i = Rmax i-1 *θ 2 + Rmax * (1-θ 2 ), Rmin i = Rmin i-1 *θ 2 + Rmin * (1-θ 2 ), Gmax i = Gmax i-1 *θ 2 + Gmax * (1-θ 2 ), Gmin i = Gmin i-1 *θ 2 + Gmin * (1-θ 2 ), Bmax i = Bmax i-1 *θ 2 + Bmax * (1-θ 2 ), Bmin i = Bmin i-1 *θ 2 + Bmin * (1-θ 2 ), However, Rmax i is the large adjustment value of the red channel of the current frame, Rmax i-1 is the red channel maximum adjustment value of the frame before the current frame, Rmax is the red channel maximum adjustment value obtained by sorting and directly calculating the pixel values of each pixel in the current frame based on the pixel values in the red channel, and Gmax is the maximum adjustment value obtained by directly sorting and calculating the pixel values of each pixel in the current frame based on the pixel values in the red channel. i is the large adjustment value for the green channel of the current frame, Gmax i-1 is the maximum adjustment value of the green channel of the frame before the current frame, Gmax is the maximum adjustment value obtained by sorting and directly calculating the pixel values of the green channel of each pixel of the current frame, and Bmax is the maximum adjustment value obtained by directly sorting and calculating the pixel values of the green channel of each pixel of the current frame. i is the large adjustment value for the blue channel of the current frame, Bmax i-1is the large adjustment value of the blue channel of the frame before the current frame, Bmax is the large adjustment value obtained by sorting and directly calculating the pixel value in the blue channel of each pixel of the current frame, and θ 2 12. The method of claim 11, wherein: is the update rate.
14. An apparatus for color restoration of underwater images, comprising: a first acquisition module for acquiring 8-bit RGB pixel values of each pixel of the underwater image; a first transformation module for transforming the 8-bit RGB pixel values of each pixel into a linear sRGB space; a first adjustment module for adjusting a pixel value in each channel of each pixel based on a relative magnitude of a pixel average value in each channel of each pixel in a linear sRGB space; a weight calculation module for calculating pixel values in each channel of each pixel adjusted by the first adjustment module and calculating a weight value of each pixel; a gain calculation module for calculating gains for red and blue channels of the image based on the weight values; a second adjustment module for adjusting the pixel value in each channel of each pixel adjusted by the first adjustment module based on the gain of the red channel and the gain of the blue channel; a second conversion module for converting the pixel value in the linear sRGB space of each pixel adjusted by the second adjustment module into an 8-bit RGB pixel value; a second acquisition module for acquiring a large adjustment value and a small adjustment value of each channel converted by the second conversion module, the large adjustment value and the small adjustment value of each channel being related to a sorting result after sorting pixel values of each pixel in each channel according to magnitude; a third adjustment module for adjusting pixel values in each channel of each pixel transformed by the second transformation module according to the large adjustment value and the small adjustment value of each channel; a fusion module for fusing the 8-bit RGB pixel value of each pixel acquired by the first acquisition module and the pixel value of each channel of each pixel adjusted by the third adjustment module based on the weight value calculated by the weight calculation module to obtain a pixel value of each channel of each pixel after fusion; and an output module for outputting pixel values in each channel of each pixel fused by the fusion module.
15. 15. The apparatus of claim 14, further comprising an RGB conversion module for converting the underwater image to be restored from another color space into an 8-bit RGB space.
16. 1. An apparatus for color restoration of underwater video, comprising: a video capture module for capturing underwater video to be restored; A color restoration device for underwater videos, comprising: a video restoration module for processing each video frame of the underwater video to be restored with the underwater image color restoration method described in any one of claims 1 to 10, and obtaining a color-restored video.
17. An electronic device, A memory in which a computer program is stored; and a processor for executing the computer program to implement the method according to any one of claims 1 to 13.
18. A computer-readable storage medium having a computer program stored therein, the computer program causing the processor to execute the method according to any one of claims 1 to 13 when the computer program is executed by the processor.
Citation Information
Patent Citations
Image processing device
JP2008227951A
Color compensation system for images captured underwater
US20070236564A1
