An underwater image enhancement model training method, system and device
By preprocessing underwater images with Gaussian filtering, color compensation, and brightness reduction, and then training an underwater image enhancement model using a contrastive learning mechanism, the problems of color shift and low contrast in underwater images are solved, achieving better color calibration and contrast enhancement effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR GENERSOFT CO LTD
- Filing Date
- 2025-11-11
- Publication Date
- 2026-05-05
AI Technical Summary
Existing underwater image enhancement methods cannot effectively adapt to the degradation characteristics of underwater images, resulting in color shift and low contrast. Traditional preprocessing methods fail to address the specific characteristics of underwater images, affecting the robustness and environmental adaptability of the model.
By extracting the natural light field map of underwater images, Gaussian filtering and color compensation are performed. Combined with brightness reduction and Gaussian noise addition, negative and positive samples are constructed to train the underwater image enhancement model. The sample weights are adjusted using a contrastive learning mechanism to expand the training data and adapt to complex degradation scenarios.
It significantly improves the color calibration capability and contrast enhancement performance of the underwater image enhancement model, outputting clear underwater images with natural colors and natural brightness, enhancing the model's generalization ability, and avoiding overfitting to a single degradation type.
Smart Images

Figure CN121095091B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image enhancement technology, and in particular to a method, system and device for training an underwater image enhancement model. Background Technology
[0002] Underwater images, due to their high resolution and rich color information, serve as an important medium for perceiving the underwater environment and acquiring crucial information, and are of great value in fields such as marine scientific research and underwater engineering operations. However, due to the absorption of light at different wavelengths by water and the scattering of light by underwater suspended objects, the acquired underwater images suffer from degradation characteristics such as color shift and low contrast, which severely reduces the visibility and interpretability of the images.
[0003] Traditional underwater image enhancement methods are divided into adjusting the pixel values of the image and constructing a physical imaging model to obtain an enhanced image. These methods are often applicable to very few scenarios and have limited effectiveness in enhancing details.
[0004] Deep learning-based underwater image enhancement models can adaptively learn the degradation features of underwater images, especially supervised training models, which establish a mapping relationship between underwater images and enhanced images, exhibiting strong environmental adaptability. Preprocessing the input images before training can improve the robustness of the trained model and expand the training samples. However, existing preprocessing methods do not specifically address the characteristics of underwater images, thus failing to improve the image enhancement model's ability to learn the physical properties of underwater degradation. Summary of the Invention
[0005] To address the aforementioned issues, this invention proposes a training method, system, and device for an underwater image enhancement model. By combining underwater image degradation characteristics with a contrastive learning mechanism, the method significantly improves the color calibration capability and contrast enhancement performance of the underwater image enhancement model, thus resolving the problems of color shift and low contrast in underwater images.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a method for training an underwater image enhancement model, comprising:
[0008] Extract the natural light field map from the underwater image, and obtain the detail map based on the underwater image and the natural light field map;
[0009] After applying Gaussian filtering to the detail map, it is merged with the natural light field map to obtain the detail degradation map;
[0010] In the green and blue channels of the natural light field map, the non-offset color channels are determined, and color compensation is performed on the red and non-offset color channels. The color-compensated natural light field map and the detail map are then merged into a color-compensated map.
[0011] After reducing the brightness of the underwater image, a low-brightness image is obtained; in this image, the brightness is highest at the center of the spot and gradually decreases along the radial direction.
[0012] Adding Gaussian noise to an underwater image yields a noise map.
[0013] The pre-built underwater image enhancement model is trained by using degraded detail images, low-brightness images, and noisy images as negative samples, and clear reference images and color-compensated images as positive samples.
[0014] As an alternative implementation, the process of determining the non-offset color channel in the green and blue channels of the natural light field map includes:
[0015] Calculate the mean values of the green and blue channels in the underwater image;
[0016] Calculate the mean values of the green and blue channels of the reference clear image;
[0017] Calculate the difference between the mean values of the green and blue channels of the underwater image and the reference clear image. The channel with the largest difference corresponds to the offset color channel, and the other channel is the non-offset color channel.
[0018] As an alternative implementation method, color compensation is as follows:
[0019] ;
[0020] in, The color channel before compensation. The color channel with the highest mean. This is the compensated color channel.
[0021] As an alternative implementation, the brightness reduction processing of the underwater image is as follows:
[0022] ;
[0023] ;
[0024] in, and These represent underwater images and low-light images, respectively. The coordinates of the center of the light spot representing artificial lighting. and Represents the spot radius and maximum illumination brightness. It is the basic brightness coefficient of the area outside the spot in an underwater image.
[0025] As an alternative implementation, during training, the contrastive learning loss function is determined using sample weights. :
[0026] ;
[0027] in, This indicates a reference image; K represents a color compensation image. The weights representing the color compensation map; Output a graph for the model; This indicates the first [item] extracted from the pre-trained ResNet model. There are 1 hidden feature; C is the total number of hidden features; , where is the coefficient, set to 1 / 16, 1 / 8, 1 / 4, and 1; N is the number of negative samples; For the first negative samples The weights; It is a positive number that approaches 0.
[0028] As an alternative implementation, the underwater image enhancement model is trained and iterated multiple times. In each iteration, the loss value is calculated based on the contrastive learning loss function. After every set number of iterations, the positive sample weights and the contrastive learning loss function are recalculated until the loss value is less than a preset value, at which point the training ends.
[0029] As an alternative implementation, the weights of the detail degradation map, low brightness map, and noise map in the contrast learning are set to 1, the weight of the reference clear map in the contrast learning is set to 1, and the weight of the color compensation map in the contrast learning is set to 0.1.
[0030] After each set frequency of iteration, the peak signal-to-noise ratio between the model output image and the color compensation image of the underwater image enhancement model and the reference clear image is calculated respectively.
[0031] If the peak signal-to-noise ratio between the color compensation image and the reference clear image Greater than or equal to the peak signal-to-noise ratio between the model output image and the reference clear image Then, the color compensation image is used as the positive sample, and the weight of the color compensation image is adjusted to... ;
[0032] Otherwise, change the color compensation map to a negative sample in contrastive learning, and adjust the weights of the color compensation map as follows: .
[0033] As an alternative implementation, the underwater image is subjected to multi-scale Gaussian filtering, the filtered underwater image is transformed to the logarithmic domain and scaled to obtain the natural light field map of the underwater image, and the pixel difference between the underwater image and the corresponding natural light field map is calculated to obtain the detail map.
[0034] In a second aspect, the present invention provides an underwater image enhancement model training system, comprising:
[0035] The separation module is configured to extract the natural light field map of the underwater image and obtain a detail map based on the underwater image and the natural light field map;
[0036] The detail image processing module is configured to perform Gaussian filtering on the detail image and then merge it with the natural light field image to obtain a detail degradation image;
[0037] The natural light field image processing module is configured to determine the non-offset color channel in the green and blue channels of the natural light field image, perform color compensation on the red channel and the non-offset color channel, and merge the color-compensated natural light field image with the detail image into a color-compensated image.
[0038] The first processing module of the original image is configured to reduce the brightness of the underwater image to obtain a low-brightness image; in this image, the brightness is highest at the center of the light spot and gradually decreases along the radial direction.
[0039] The second processing module of the original image is configured to add Gaussian noise to the underwater image to obtain a noise map;
[0040] The training module is configured to use degraded detail maps, low-brightness maps, and noisy maps as negative samples, and reference clear maps and color-compensated maps as positive samples, thereby training a pre-built underwater image enhancement model.
[0041] Thirdly, the present invention provides an electronic device including a memory and a processor, and computer instructions stored in the memory and running on the processor, wherein the computer instructions, when executed by the processor, perform the method described in the first aspect.
[0042] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0043] This invention proposes a training method for an underwater image enhancement model. In the preprocessing of underwater images, based on traditional neural network training data augmentation, a novel data augmentation method specifically for underwater environments is constructed. This method not only expands the training data but also incorporates more complex degradation scenarios to add noise to the data, more closely reflecting the degradation distribution of actual underwater scenes. This allows the underwater image enhancement model to adapt to complex combinations of nonlinear degradation, avoiding overfitting to a single degradation type and enhancing generalization ability. Consequently, during training, the underwater image enhancement model progressively moves away from degradation and over-enhanced features. The trained underwater image enhancement model outputs clear underwater images containing natural colors and natural brightness, solving the problems of color shift and low contrast in underwater images.
[0044] In this invention, the method for processing underwater images and training an underwater image enhancement model involves merging a detail image (Gaussian filtering) with a natural light field image to obtain a detail degradation image. Non-offset color channels are determined from the green and blue channels of the natural light field image, and color compensation is performed on the red and non-offset color channels. The color-compensated natural light field image is then merged with the detail image to obtain a color-compensated image. The brightness of the underwater image is reduced to obtain a low-brightness image, and Gaussian noise is added to the underwater image to obtain a noise image. This expands the sample types for contrastive learning, using the detail degradation image, low-brightness image, and noise image as negative samples, and the reference clear image and color-compensated image as positive samples. The weights of the positive samples are adaptively adjusted based on the training results, thereby training the model. By combining underwater image degradation characteristics with a contrastive learning mechanism, the color calibration capability and contrast enhancement performance of the underwater image enhancement model for underwater images are significantly improved.
[0045] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0047] Figure 1 This is a flowchart of the underwater image enhancement model training method provided in Embodiment 1 of the present invention. Detailed Implementation
[0048] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0049] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0050] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form as well. Furthermore, it should be understood that the terms “comprising” and “including”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0051] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0052] Example 1
[0053] This embodiment proposes a training method for an underwater image enhancement model, such as... Figure 1 As shown, it includes:
[0054] Extract the natural light field map from the underwater image, and obtain the detail map based on the underwater image and the natural light field map;
[0055] After applying Gaussian filtering to the detail map, it is merged with the natural light field map to obtain the detail degradation map;
[0056] In the green and blue channels of the natural light field map, the non-offset color channels are determined, and color compensation is performed on the red and non-offset color channels. The color-compensated natural light field map and the detail map are then merged into a color-compensated map.
[0057] After reducing the brightness of the underwater image, a low-brightness image is obtained; in this image, the brightness is highest at the center of the spot and gradually decreases along the radial direction.
[0058] Adding Gaussian noise to an underwater image yields a noise map.
[0059] The pre-built underwater image enhancement model is trained by using degraded detail images, low-brightness images, and noisy images as negative samples, and clear reference images and color-compensated images as positive samples.
[0060] The method of this embodiment will be described in detail below.
[0061] S1: Obtain the training set, which includes underwater images and reference clear images. The underwater images serve as the input for training the underwater image enhancement model and contain degradation features; the reference images are the enhanced clear images and are positive samples.
[0062] S2: Extract the natural light field map from the underwater image, and obtain the detail map based on the underwater image and the natural light field map.
[0063] Specifically:
[0064] (1) Perform multi-scale Gaussian filtering on the underwater image to reduce the level of detail in the underwater image, and average the results of the multi-scale filtering.
[0065] The standard deviation of the Gaussian filter kernel for each scale is selected as 15, 60, and 90.
[0066] (2) In order to eliminate other details in the underwater image, the filtered underwater image is transformed to the logarithmic domain and scaled to obtain the natural light field map of the underwater image.
[0067] (3) The underwater image and the corresponding natural light field image are compared by pixel difference to obtain the corresponding detail image. The pixel difference is expressed as:
[0068] ;
[0069] in, Represents the position coordinates of a pixel in each underwater image. This represents the corresponding detailed image. Represents underwater images, This represents a natural light field diagram.
[0070] S3: After Gaussian filtering the detail map, merge it with the natural light field map to obtain the detail degradation map.
[0071] Specifically, a single-scale Gaussian filter is applied to the detail map to reduce the detail level of the detail degradation map when negative samples are used; the standard deviation of the single-scale Gaussian filter kernel is selected as 15.
[0072] S4: Determine the non-offset color channels in the green and blue channels of the natural light field map, perform color compensation on the red and non-offset color channels, and merge the color-compensated natural light field map with the detail map into a color-compensated map.
[0073] Specifically:
[0074] S4-1: The process of determining the non-offset color channels in the green and blue channels of the natural light field map includes:
[0075] (1) Calculate the mean values of the green and blue channels of the underwater images in the training set, which represent the average brightness of the channels;
[0076] (2) Calculate the mean values of the green and blue channels of the reference clear images in the training set;
[0077] (3) Calculate the difference between the mean values of the green and blue channels of the underwater image and the reference clear image. The channel with the largest difference corresponds to the offset color channel, and the other channel is the non-offset color channel.
[0078] S4-2: Color compensation is:
[0079] ;
[0080] in, The color channel before compensation. The color channel with the highest mean. This is the compensated color channel.
[0081] S4-3: Add the color-compensated natural light field map to the detail map to obtain the color-compensated map.
[0082] In this embodiment, the purpose of this step is to provide a sample that adapts to changes in identity as the model's capabilities change. The color-compensated image is of higher quality than the underwater image, but lower quality than the reference clear image. Therefore, in the early stages of training, the color-compensated image can be used as a positive sample to enable the model to learn color correction more quickly; while in the later stages, it is used as a negative sample to train the model to learn more details.
[0083] S5: The underwater image is reduced to obtain a low-brightness image to simulate the artificial lighting and uneven lighting conditions of underwater exploration in a real underwater environment. This trains the model's ability to handle local brightness changes and improve the model's ability to recover details in dark areas. The brightness is highest at the center of the light spot and gradually decreases along the radial direction.
[0084] Specifically:
[0085] The brightness of underwater images is reduced. The overall brightness of the light depends on the power of the artificial light source, and the position of the light spot in the underwater image depends on the angle of the light.
[0086] Therefore, the brightness reduction process for underwater images is as follows:
[0087] ;
[0088] ;
[0089] in, and These represent underwater images and low-light images, respectively. The coordinates of the center of the light spot representing artificial lighting. and Represents the spot radius and maximum illumination brightness. It is the basic brightness coefficient of the area outside the spot in an underwater image.
[0090] Among them, the coordinates of the center of the light spot underwater images arrive Random sampling is performed within a certain range, where w and h represent the width and length of the underwater image; r is within a certain range. Random sampling within the range Randomly sample within the range (1.0, 1.2). Set it to 0.25.
[0091] S6: Add Gaussian noise to the underwater image to obtain a noise map.
[0092] Specifically:
[0093] (1) Set the mean offset of Gaussian noise to 0 and the standard deviation to be randomly sampled between 10 and 20;
[0094] (2) Create a random noise matrix with the same size as the underwater image;
[0095] (3) Add noise to the underwater image and crop out pixel values that are outside the range of [0, 255].
[0096] S7: Use the detail degradation map, low brightness map and noisy map as negative samples, and the reference clear map and color compensation map as positive samples to complete the training of the pre-built underwater image enhancement model.
[0097] Specifically:
[0098] S7-1: Add the color compensation map, detail degradation map, low brightness map and noise map to the contrast learning simultaneously;
[0099] In this study, the degraded detail map, the low brightness map, and the noisy map were used as negative samples, and their weights in the contrastive learning were set to 1; the reference clear map and the color compensation map were used as positive samples, and their weights in the contrastive learning were set to 1 and 0.1, respectively.
[0100] S7-2: During training, the contrastive learning loss function is determined using sample weights. :
[0101] ;
[0102] in, This indicates a reference image; K represents a color compensation image. The weights representing the color compensation map; Output a graph for the model; This indicates the first [item] extracted from the pre-trained ResNet model. There are 1 hidden feature; C is the total number of hidden features; , where is the coefficient, set to 1 / 16, 1 / 8, 1 / 4, and 1; N is the number of negative samples; For the first negative samples The weights; To obtain a positive number that approaches 0, so as to avoid a denominator of 0.
[0103] S7-3: Perform multiple training iterations on the pre-built underwater image enhancement model; in each iteration, calculate the loss value according to the contrastive learning loss function, and recalculate the positive sample weights and the contrastive learning loss expression after a certain frequency of iterations, with the frequency defaulting to 20; finally, stop iterating when the loss value is less than the preset value, and obtain a converged underwater image enhancement model.
[0104] Specifically: During the training process, after each set number of training rounds (e.g., 20), the peak signal-to-noise ratio (PSNR) between the model output image and color compensation image of the underwater image enhancement model and the reference clear image is calculated.
[0105] If the peak signal-to-noise ratio between the color compensation image and the reference clear image Greater than or equal to the peak signal-to-noise ratio between the model output image and the reference clear image Then, the color compensation image is used as the positive sample, and the weights of the color compensation image are adjusted as follows: ;
[0106] Otherwise, change the color compensation map to a negative sample in contrastive learning, and adjust the weights of the color compensation map as follows: .
[0107] in, Represented as:
[0108] ;
[0109] In the formula, Color compensation image The square of the largest pixel value obtained. This represents the mean square error between the color compensation image and the model output image.
[0110] Represented as:
[0111] ;
[0112] In the formula, For reference, please see the clear image. The square of the largest pixel value obtained. The mean square error is used to compare the clear image with the model output image.
[0113] In this embodiment, the purpose of this step is to dynamically adjust the model training assignment points using the color compensation map. In the early stages of training, when the samples are positive, the color compensation map guides the model to learn more about color distortion handling capabilities. Later, when the samples are negative, the model's capabilities improve, and the focus shifts to aspects such as detail processing and illumination enhancement. Since changes in the weights of dynamic samples can cause training oscillations, other negative samples, similar to underwater images, are used to fix the negative sample gradients, ensuring the overall convergence direction of the training and improving training stability.
[0114] The structure of the underwater image enhancement model is described below.
[0115] (1) The underwater image enhancement model adopts a U-shaped encoder-decoder structure and a backprojection branch. The backprojection branch contains two enhancement operators and one degradation operator. The first enhancement operator predicts the restored image features performed in the encoder. Subsequently, the degradation operator predicts the degradation features from the estimated normal features. The model mainly consists of a feature extraction module and a frequency guidance module.
[0116] (2) Feature extraction module: This module consists of convolutional blocks and attention groups. The convolutional blocks mainly include batch normalization, ordinary convolution, and multi-layer depthwise separable convolution, which can extract richer features and perceive complex environments. The attention groups consist of parallel differential spatial attention mechanisms and differential channel attention mechanisms. The attention results are concatenated and integrated through an MLP (Multilayer Perceptron) (convolution-GeLU activation function-convolution). Finally, the output is summed using element-wise addition.
[0117] (3) Frequency domain guidance module: In the frequency domain, the amplitude represents the intensity of each frequency component of the image, transmitting degraded information and noise, while the phase information serves as a reliable guide to help the network quickly capture spatial information.
[0118] First, color compensation methods are used on the input images for training. The degraded channels are compensated. The compensation operation is represented as:
[0119] ;
[0120] ;
[0121] in, , , These represent the input images respectively. The red, green, and blue color channels, Represents the Hadamard product. and These represent color-compensated images. The red and blue channels.
[0122] Input features of the module and color-compensated images Perform a Fourier transform on each of the above and obtain the corresponding amplitude. ) and phase ( Phase It provides structural information that is closer to a clear structure, but some degradation still exists. Therefore, a set of convolutions is used to pair the phases... Perform a slight correction, multiplying the output by As a phase fusion, the guiding phase is obtained. It is used to help the model reconstruct the overall structure of the image. This is because amplitude represents the intensity of each frequency component of the image, rather than its spatial continuity. Feed it into a 1×1 convolutional layer to integrate cross-domain features and obtain Then, the inverse Fourier transform is used to... and Mapping back to the spatial domain yields frequency domain features. Finally, regarding Perform 1×1 convolution integration and combine with features Add them point by point to get the module output.
[0123] This embodiment proposes a training method for an underwater image enhancement model. In the preprocessing of underwater images, based on traditional neural network training data augmentation, a novel data augmentation method specifically for underwater environments is constructed. This method not only expands the training data but also covers more complex degradation scenarios to add noise to the data, more closely reflecting the degradation distribution of actual underwater scenes. This allows the underwater image enhancement model to adapt to complex combinations of nonlinear degradation, avoiding overfitting to a single degradation type and enhancing generalization ability. As a result, the underwater image enhancement model progressively moves away from degradation and over-enhanced features during training, and the trained underwater image enhancement model outputs clear underwater images containing natural colors and natural brightness, solving the problems of color shift and low contrast in underwater images.
[0124] In the processing of underwater images and the training method of the underwater image enhancement model, the detail map is Gaussian filtered and then merged with the natural light field map to obtain a detail degradation map. Non-offset color channels are determined from the green and blue channels of the natural light field map, and color compensation is performed on the red and non-offset color channels. The color-compensated natural light field map is then merged with the detail map to obtain a color compensation map. The brightness of the underwater image is reduced to obtain a low-brightness map, and Gaussian noise is added to the underwater image to obtain a noise map. This expands the sample types for contrastive learning, using the detail degradation map, low-brightness map, and noise map as negative samples, and the reference clear image and color compensation map as positive samples. The weights of the positive samples are adaptively adjusted based on the training results, thereby training the model. This embodiment, by combining underwater image degradation characteristics with a contrastive learning mechanism, significantly improves the color calibration capability and contrast enhancement performance of the underwater image enhancement model for underwater images.
[0125] Example 2
[0126] This embodiment provides an underwater image enhancement model training system, including:
[0127] The separation module is configured to extract the natural light field map of the underwater image and obtain a detail map based on the underwater image and the natural light field map;
[0128] The detail image processing module is configured to perform Gaussian filtering on the detail image and then merge it with the natural light field image to obtain a detail degradation image;
[0129] The natural light field image processing module is configured to determine the non-offset color channel in the green and blue channels of the natural light field image, perform color compensation on the red channel and the non-offset color channel, and merge the color-compensated natural light field image with the detail image into a color-compensated image.
[0130] The first processing module of the original image is configured to reduce the brightness of the underwater image to obtain a low-brightness image; in this image, the brightness is highest at the center of the light spot and gradually decreases along the radial direction.
[0131] The second processing module of the original image is configured to add Gaussian noise to the underwater image to obtain a noise map;
[0132] The training module is configured to use degraded detail maps, low-brightness maps, and noisy maps as negative samples, and reference clear maps and color-compensated maps as positive samples, thereby training a pre-built underwater image enhancement model.
[0133] It should be noted that the above modules correspond to the steps described in Embodiment 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should also be noted that the above modules, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.
[0134] In further embodiments, the following is also provided:
[0135] An electronic device includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, wherein the computer instructions, when executed by the processor, perform the method described in Embodiment 1. For brevity, further details are omitted here.
[0136] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0137] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.
[0138] A computer-readable storage medium for storing computer instructions, which, when executed by a processor, perform the method described in Embodiment 1.
[0139] The method in Example 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not provided here.
[0140] A computer program product includes a computer program that, when executed by a processor, implements the method described in Embodiment 1.
[0141] The present invention also provides at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes computer-executable instructions, such as instructions included in program modules, which execute in a device on a target real or virtual processor to perform the processes / methods described above. Typically, program modules include routines, programs, libraries, objects, classes, components, data structures, etc., that perform specific tasks or implement specific abstract data types. In various embodiments, the functionality of program modules can be combined or divided among program modules as needed. The machine-executable instructions for the program modules can execute within a local or distributed device. In a distributed device, the program modules can reside in both local and remote storage media.
[0142] The computer program code used to implement the methods of the present invention may be written in one or more programming languages. This computer program code may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the computer or other programmable data processing device, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a computer, partially on a computer, as a stand-alone software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server.
[0143] In the context of this invention, computer program code or related data may be carried by any suitable carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, and the like. Examples of signals may include electrical, optical, radio, sound, or other forms of propagation signals, such as carrier waves, infrared signals, etc.
[0144] Those skilled in the art will recognize that the units and algorithm steps described in conjunction with the embodiments herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0145] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for training an underwater image enhancement model, characterized in that, include: Extract the natural light field map from the underwater image, and obtain the detail map based on the underwater image and the natural light field map; After applying Gaussian filtering to the detail map, it is merged with the natural light field map to obtain the detail degradation map; In the green and blue channels of the natural light field map, the non-offset color channels are determined, and color compensation is performed on the red and non-offset color channels. The color-compensated natural light field map and the detail map are then merged into a color-compensated map. Color compensation is: ; in, The color channel before compensation. The color channel with the highest mean. The compensated color channel; After reducing the brightness of the underwater image, a low-brightness image is obtained; in this image, the brightness is highest at the center of the spot and gradually decreases along the radial direction. Adding Gaussian noise to an underwater image yields a noise map. The pre-built underwater image enhancement model is trained by using degraded detail images, low brightness images, and noisy images as negative samples, and clear reference images and color compensation images as positive samples. Determine the contrastive learning loss function using sample weights : ; in, This indicates a reference image; K represents a color compensation image. The weights representing the color compensation map; Output a graph for the model; This indicates the first [item] extracted from the pre-trained ResNet model. There are 1 hidden feature; C is the total number of hidden features; , where is the coefficient, set to 1 / 16, 1 / 8, 1 / 4, and 1; N is the number of negative samples; For the first negative samples The weights; It is a positive number that approaches 0.
2. The underwater image enhancement model training method as described in claim 1, characterized in that, The process of determining the non-offset color channels in the green and blue channels of a natural light field map includes: Calculate the mean values of the green and blue channels in the underwater image; Calculate the mean values of the green and blue channels of the reference clear image; Calculate the difference between the mean values of the green and blue channels of the underwater image and the reference clear image. The channel with the largest difference corresponds to the offset color channel, and the other channel is the non-offset color channel.
3. The underwater image enhancement model training method as described in claim 1, characterized in that, The brightness reduction process for underwater images is as follows: ; ; in, and These represent underwater images and low-light images, respectively. The coordinates of the center of the light spot representing artificial lighting. and Represents the spot radius and maximum illumination brightness. It is the basic brightness coefficient of the area outside the spot in an underwater image.
4. The underwater image enhancement model training method as described in claim 1, characterized in that, The underwater image enhancement model is trained and iterated multiple times. In each iteration, the loss value is calculated based on the contrastive learning loss function. After every set number of iterations, the weights of the positive samples and the contrastive learning loss function are recalculated until the loss value is less than the preset value, at which point the training ends.
5. The underwater image enhancement model training method as described in claim 4, characterized in that, The weights of the detail degradation map, low brightness map, and noise map in the contrast learning are set to 1, the weight of the reference clear map in the contrast learning is set to 1, and the weight of the color compensation map in the contrast learning is set to 0.
1. After each set frequency of iteration, the peak signal-to-noise ratio between the model output image and the color compensation image of the underwater image enhancement model and the reference clear image is calculated respectively. If the peak signal-to-noise ratio between the color compensation image and the reference clear image Greater than or equal to the peak signal-to-noise ratio between the model output image and the reference clear image Then, the color compensation image is used as the positive sample, and the weight of the color compensation image is adjusted to... ; Otherwise, change the color compensation map to a negative sample in contrastive learning, and adjust the weights of the color compensation map as follows: .
6. The underwater image enhancement model training method as described in claim 1, characterized in that, The underwater image is subjected to multi-scale Gaussian filtering, and the filtered underwater image is transformed to the logarithmic domain and scaled to obtain the natural light field map of the underwater image. The pixel difference between the underwater image and the corresponding natural light field map is calculated to obtain the detail map.
7. An underwater image enhancement model training system, characterized in that, include: The separation module is configured to extract the natural light field map of the underwater image and obtain a detail map based on the underwater image and the natural light field map; The detail image processing module is configured to perform Gaussian filtering on the detail image and then merge it with the natural light field image to obtain a detail degradation image; The natural light field image processing module is configured to determine the non-offset color channels in the green and blue channels of the natural light field image, perform color compensation on the red and non-offset color channels, and merge the color-compensated natural light field image with the detail image into a color-compensated image; the color compensation is as follows: ; in, The color channel before compensation. The color channel with the highest mean. The compensated color channel; The first processing module of the original image is configured to reduce the brightness of the underwater image to obtain a low-brightness image; in this image, the brightness is highest at the center of the light spot and gradually decreases along the radial direction. The second processing module of the original image is configured to add Gaussian noise to the underwater image to obtain a noise map; The training module is configured to use detail degradation maps, low brightness maps, and noisy maps as negative samples, and reference clear maps and color compensation maps as positive samples, in order to train a pre-built underwater image enhancement model. Determine the contrastive learning loss function using sample weights : ; in, This indicates a reference image; K represents a color compensation image. The weights representing the color compensation map; Output a graph for the model; This indicates the first [item] extracted from the pre-trained ResNet model. There are 1 hidden feature; C is the total number of hidden features; , where is the coefficient, set to 1 / 16, 1 / 8, 1 / 4, and 1; N is the number of negative samples; For the first negative samples The weights; It is a positive number that approaches 0.
8. An electronic device, characterized in that, It includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, which, when executed by the processor, perform the method according to any one of claims 1-6.
Citation Information
Patent Citations
Underwater image enhancement method and system and readable storage medium
CN115564676A
Underwater image enhancement method and computer equipment
CN120543446A