Light source estimation model training method and device and light source estimation method and device
The light source estimation model trained through multi-frame image sequences uses spatiotemporal feature extraction and light source estimation networks to solve the problem of unstable light source estimation in single-frame images, achieve more stable and accurate light source estimation, and avoid color jump phenomena, making The color of the image after white balance is consistent with the color of the real scene.
Patent Information
- Application Number
- CN202410907907.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-07-08
AI Technical Summary
Existing light source estimation methods have result instability in single-frame image processing, causing the color of the image after white balance processing to be inconsistent with the color of the real scene. In particular, color jumps occur when the shooting angle and lighting change.
Multi-frame image sequences are used to train the light source estimation model, and the spatiotemporal feature extraction network and light source estimation network are used to adjust the model parameters through the loss function to improve the stability and accuracy of the light source estimation and prevent color jumps.
The light source estimation model trained through multi-frame image sequences can better learn adjacent frame information, reduce single frame estimation errors, adapt to environmental changes, improve the stability and accuracy of white balance results, and make image colors more consistent with real scene colors.
Smart Images

Figure CN118747833A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a light source estimation model training, a light source estimation method and a device. Background Art
[0002] The human visual system has the ability to perceive the color of an object independently of the lighting conditions. This ability to stably perceive its color is called color constancy (CC). White balance is an important correction method to achieve image color constancy, which eliminates the influence of color temperature on image color under different light sources and restores the true color of the object. When white balancing an image, it is necessary to estimate the color of the light source when the image was taken (hereinafter referred to as light source estimation).
[0003] At present, there are two types of methods for light source estimation: 1) statistics-based methods, represented by the gray world algorithm. This type of method is based on some a priori assumptions and links the statistical characteristics of the image with the light source estimation; 2) learning-based methods, which mainly rely on specific databases to learn the input image features through deep learning and then map them to light source estimation.
[0004] Of these two methods, the former has certain limitations in the accuracy of light source estimation. Although the latter has improved accuracy, in actual applications, due to deviations in shooting angles, changes in scenes, lighting and other factors, the light source estimation results of single-frame images may be unstable, resulting in color jumps during image preview, making the color of the image after white balance processing inconsistent with the color of the actual scene. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a light source estimation model training, a light source estimation method and a light source estimation device to solve the problem of unstable light source estimation results of a single frame image.
[0006] In order to solve the above technical problems, this application is implemented as follows:
[0007] In a first aspect, an embodiment of the present application provides a light source estimation model training method, comprising:
[0008] Determine a training data set, the training data set includes multiple groups of training data, each group of the training data includes a first image sequence, a second image sequence, and a reference light source estimation result corresponding to the first image sequence, the first image sequence includes multiple frames of images continuously acquired under a first light source scene, the second image sequence is obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result is used to describe the color characteristics of a real light source under the first light source scene;
[0009] Inputting the first image sequence in a group of the training data into a light source estimation model to obtain a first light source estimation result, and inputting the second image sequence in the same group of the training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation according to the spatiotemporal features;
[0010] Determine a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function;
[0011] Parameters of the light source estimation model are adjusted according to the loss value.
[0012] In a second aspect, an embodiment of the present application provides a light source estimation method, including:
[0013] determining a third image sequence to be processed;
[0014] Inputting the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the light source estimation model training method described in the first aspect, and the number of images contained in the third image sequence is consistent with the number of images in the first image sequence input for training the light source estimation model;
[0015] The output of the light source estimation model is used as a light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
[0016] In a third aspect, an embodiment of the present application provides a light source estimation model training device, comprising:
[0017] a data determination module, used to determine a training data set, the training data set comprising multiple groups of training data, each group of the training data comprising a first image sequence, a second image sequence and a reference light source estimation result corresponding to the first image sequence, the first image sequence comprising multiple frames of images continuously acquired under a first light source scene, the second image sequence being obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result being used to describe the color characteristics of a real light source under the first light source scene;
[0018] a data input module, used for inputting the first image sequence in a group of the training data into a light source estimation model to obtain a first light source estimation result, and inputting the second image sequence in the same group of the training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation according to the spatiotemporal features;
[0019] a loss determination module, configured to determine a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function;
[0020] A parameter adjustment module is used to adjust the parameters of the light source estimation model according to the loss value.
[0021] In a fourth aspect, an embodiment of the present application provides a light source estimation device, including:
[0022] An image determination module, used for determining a third image sequence to be processed;
[0023] an image input module, configured to input the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the light source estimation model training method described in the first aspect, and the number of images included in the third image sequence is consistent with the number of images in the first image sequence input for training the light source estimation model;
[0024] A result output module is used to use the output of the light source estimation model as the light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
[0025] In a fifth aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect or the second aspect.
[0026] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect or the second aspect are implemented.
[0027] In the seventh aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect or the second aspect.
[0028] In an embodiment of the present application, an image sequence (multiple frames of images) is used to train a light source estimation model and estimate the light source. Compared with the use of a single frame of images for light source estimation in the related art, the use of multiple frames of images can better learn the information of adjacent frame images, thereby reducing the error of single frame estimation, adapting to environmental jumps, improving the stability of estimation results, preventing color jumps during image preview, and making the color of the image after white balance processing more consistent with the color of the real scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the framework of a light source estimation solution provided in an embodiment of the present application.
[0030] Figure 2 It is a flowchart of a light source estimation model training method provided in an embodiment of the present application.
[0031] Figure 3 It is a structural diagram of a light source estimation model provided in an embodiment of the present application.
[0032] Figure 4 It is a schematic diagram of the structure of the ConvLSTM provided in the embodiment of the present application.
[0033] Figure 5 It is a structural diagram of a light source estimation network provided in an embodiment of the present application.
[0034] Figure 6 It is a flowchart of a light source estimation method provided in an embodiment of the present application.
[0035] Figure 7 It is a structural schematic diagram of a light source estimation model training device provided in an embodiment of the present application.
[0036] Figure 8 It is a structural schematic diagram of a light source estimation device provided in one embodiment of the present application.
[0037] Fig. 9 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0038] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0040] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally represents that the objects associated with each other are in an "or" relationship.
[0041] In order to solve the problem of unstable light source estimation results of a single frame image, the embodiment of the present application proposes a light source estimation model training method and a light source estimation method. Among them, a light source estimation model training method can be executed by an electronic device, which can include but is not limited to a server or a terminal device; a light source estimation method can be executed by a terminal device.
[0042] Specifically, Figure 1 As shown, the light source estimation scheme proposed in the embodiment of the present application includes two parts: offline training 1 and online prediction 2.
[0043] Among them, offline training 1 corresponds to a light source estimation model training method proposed in an embodiment of the present application, and offline training 1 generally includes: step 11, constructing a training data set including a time-ordered image sequence; step 12, training the light source estimation model; step 13, outputting the light source estimation result, and adjusting the model parameters according to the light source estimation result.
[0044] Among them, online prediction 2 corresponds to a light source estimation method proposed in an embodiment of the present application, and online prediction 2 generally includes: step 21, inputting the image sequence to be estimated into the light source estimation model obtained by offline training 1; step 22, the light source estimation model estimates the light source corresponding to the input image sequence; step 23, the light source estimation model outputs the light source estimation result.
[0045] The light source estimation model training method and the light source estimation method provided in the embodiments of the present application are described in detail below with reference to specific embodiments in conjunction with the accompanying drawings.
[0046] First, a light source estimation model training method provided by an embodiment of the present application is described.
[0047] like Figure 2As shown, the embodiment of the present application provides a light source estimation model training method, which may include:
[0048] Step 201, determine a training data set, the training data set includes multiple groups of training data, each group of the training data includes a first image sequence, a second image sequence and a reference light source estimation result corresponding to the first image sequence, the first image sequence includes multiple frames of images continuously captured under a first light source scene, the second image sequence is obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result is used to describe the color characteristics of a real light source in the first light source scene.
[0049] The training data set is pre-constructed, and the training data set includes multiple sets of training data under multiple light source scenes, and one light source scene corresponds to at least one set of training data. The light source colors of the multiple light source scenes are different from each other. The multiple light source scenes include the first light source scene, or the first light source scene can be any light source scene in the multiple light source scenes.
[0050] In some embodiments, determining the training data set may include: taking each of the plurality of light source scenes as a first light source scene, and performing the following steps:
[0051] Step 1, in the first light source scene, continuously capture n frames of images, and shoot a reference image containing a color card within a first time period after capturing the n frames of images, wherein the first time period is a pre-set shorter time period, for example, the first time period is 3s, and the purpose is to capture the reference image containing the color card immediately after capturing the preview frame data.
[0052] After collecting a number of images and reference images for each light source scene, these data are preprocessed to obtain training data suitable for training the light source estimation model.
[0053] In some embodiments, the image captured by the camera is generally a raw format image, which contains more information. In order to speed up the calculation, before executing step 2, the captured raw format image can be converted into a stats format image.
[0054] Step 2: extract t frames of images every m frames from the n frames of images according to the acquisition time to obtain the first image sequence under the first light source scene.
[0055] The first image sequence can be expressed as: I = (I1, I2, I3, ..., I t ).
[0056] Step 3: Process the reference image in the first light source scene to obtain a reference light source estimation result in the first light source scene.
[0057] Specifically, first, the colors of all pixels in the area where the color card is located in the reference image can be averaged by color channel to obtain a first vector containing the color averages under three color channels, for example, a first vector containing the color averages under three color channels of RGB can be obtained. It can be understood that the first vector contains 3 elements at this time; then, the first vector is normalized by the first color channel to obtain a second vector, wherein the first color channel is any one of the three color channels, for example, the first color channel can be G, and it can be understood that the normalized second vector also includes 3 elements; then, the second vector is used as the reference light source estimation result gtill in the light source scene. The reference light source estimation result in a light source scene can describe the color characteristics of the real light source in the light source scene, which is equivalent to the label of the first image sequence in the light source scene.
[0058] So far, the first image sequence in each light source scene and the corresponding reference light source estimation constitute a set of training data (I,gtill), where I = (I1, I2, I3, ..., I t ).
[0059] In some embodiments, training data with different brightness levels under the same light source scene may also be constructed through the following step 4.
[0060] Step 4: Perform brightness transformation on the first image sequence under the first light source scene to obtain a second image sequence with different brightness under the first light source scene.
[0061] Since humans perceive brightness in an approximately logarithmic manner, this method is more consistent with human perception. Logarithmic transformation changes image brightness, which can reduce extreme brightness differences and enhance dark details of the image. Therefore, the brightness of the first image sequence in the first light source scene can be transformed by logarithmic transformation.
[0062] Assume that the first image sequence is: I = (I1, I2, I3, ..., I t ), the brightness of the images in the first image sequence can be changed by the following logarithmic transformation formula:
[0063] I t ′=c*log(1+I t ) (1)
[0064] Where c = limit / log(1+f max (I t )),I t Represents the original stats image before transformation, I t ′ is the stats image after brightness changes, limit represents the maximum value of the corresponding base of the stored stats image, fmax (·) represents the maximum value function.
[0065] The second image sequence obtained after transformation can be expressed as: I′=(I1′, I2′, I3′, …, I t ′).
[0066] Step 5: correspondingly save the first image sequence, the second image sequence, and the reference light source estimation result under the first light source scene to obtain a set of the training data.
[0067] For example, (I, gtill, I′) is saved as a set of the training data.
[0068] In some other embodiments, determining the training data set may further include:
[0069] Step 6: Select at least one first image sequence from the multiple sets of training data.
[0070] For example, a certain ratio of first image sequences is randomly selected from the multiple sets of training data as objects for light source enhancement.
[0071] Step 7: perform white balance processing on the selected first image sequence.
[0072] Specifically, the existing white balance processing method may be used to perform white balance processing on the selected first image sequence.
[0073] Step 8: Use a light source in a second light source scene to perform light source enhancement on the first image sequence after white balance processing, wherein the light source color in the second light source scene is different from the light source color in the first light source scene.
[0074] Specifically, the principle of implementing light source enhancement on the first image sequence after white balance processing can be described as: using a new light source - the first light source to illuminate the image after white balance, and the new light source is the real light source of the new image. new , restore the white balanced image with the new light source to obtain I new , thus we can get the data pair after the light source enhancement. For one set of training data (I,gtill), randomly select a light source ill from other light sources in the training data set as the first light source, and the training data pair after the light source enhancement (I new ,gtill new ) is calculated as follows:
[0075]
[0076] gtill new =ill (3)
[0077] In some embodiments, determining the training data set may further include:
[0078] Step 9: performing brightness transformation on the first image sequence after light source enhancement to obtain the second image sequence with different brightness under the second light source scene.
[0079] The brightness transformation method may also be a logarithmic transformation.
[0080] Step 10: Save the first image sequence enhanced by the light source in the second light source scene, the second image sequence in the second light source scene, and the light source correspondingly to obtain a new set of training data.
[0081] Assume that the first image sequence after light source enhancement is I new , the first image sequence I new The corresponding reference light source estimation result is gtill new , the second image sequence after brightness transformation is I′ new , then we can convert (I new ,gtill new , I′ new ) as a new set of training data.
[0082] It can be understood that by generating new image sequences through light source enhancement and adding them to the training dataset, the impact of insufficient dataset on the generalization of the model can be compensated and data diversity can be enriched.
[0083] Step 202: input the first image sequence in a group of the training data into a light source estimation model to obtain a first light source estimation result, and input the second image sequence in the same group of the training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation based on the spatiotemporal features.
[0084] Figure 3 FIG. 2 shows a schematic diagram of the structure of a light source estimation model proposed in an embodiment of the present application. Figure 3 As shown, the light source estimation model proposed in the embodiment of the present application includes l-layer light source prediction network 31, wherein the layer of light source prediction network 31 includes a spatiotemporal feature extraction network 311 and a light source estimation network 312.
[0085] Further, such as Figure 3As shown, the spatiotemporal feature extraction network 311 includes k layers of network units connected in sequence, wherein k is a positive integer, and k is consistent with the number of images contained in the input target image sequence (i.e., k=t). The input of the first layer of network units in the k-layer network units is the first image I1 in the target image sequence of the input spatiotemporal feature extraction network 3, and the input of the i-th layer of network units in the k-layer network units includes the i-th image I1 in the target image sequence of the input spatiotemporal feature extraction network 311. i And the output of the i-1th layer network unit, 1<i<k, the output of the kth layer network unit in the k-layer network unit is the spatiotemporal features of the target image sequence input into the spatiotemporal feature extraction network, and the target image sequence includes the first image sequence or the second image sequence.
[0086] As an example, the network unit in the spatiotemporal feature extraction network 311 may be a convolutional long short-term memory network (Convolutional Long Short-Term Memory Network, ConvLSTM), Figure 4 This is a structural diagram of ConvLSTM. ConvLSTM can not only learn the spatial feature information of the image, but also has a certain memory ability, and can capture the long-term dependencies in the input image sequence. This method can reduce the error of single-frame estimation, adapt to environmental jumps, and improve the accuracy, stability and algorithm adaptability of white balance results. It should be noted that Figure 4 The structure of the ConvLSTM shown belongs to the prior art. Figure 4 For the meaning of the physical symbols shown in , please refer to the prior art.
[0087] Specifically, Figure 3 As shown, by inputting the image sequence (I1, I2, ..., I t-1 ,I t ) to obtain the spatiotemporal features of the image sequence. Assume that the image matrix of each frame is represented as (3, h, w), 3 indicates that the stats image is RGB three-channel, and h and w represent the height and width of the input image. Each frame of the image sequence is used as the input of each network unit 3111 in turn. The first frame of image I1 is processed by the first network unit 3111 and then outputs h1 (1) ,c1 (1) , and use it together with the next frame image I2 as the input of the next network unit until the last frame image I t Input, then we can get the spatiotemporal feature output h of the first layer network t (1)The dimension of the spatiotemporal feature is (c, h, w). By analogy, the spatiotemporal features of each subsequent layer can be obtained. The light source estimation network is then used to obtain the light source estimation value y of each layer. 1 ,y 2 To l .
[0088] As an example, Figure 5 As shown, the light source estimation network 312 includes at least one convolution layer, a global average pooling GAP layer and an output data dimension adjustment layer, wherein:
[0089] The at least one convolutional layer is used for further feature extraction from the spatiotemporal features extracted by the spatiotemporal feature extraction network.
[0090] The GAP layer is used to determine the average value of the features extracted by the at least one convolution layer according to the color channel, and obtain a third vector formed by the average value under each color channel.
[0091] The output data dimension adjustment layer is used to perform a dimension adjustment (reshape) operation on the third vector output by the GAP layer to obtain a light source estimation result of the image sequence input into the spatiotemporal feature extraction network.
[0092] Specifically, Figure 5 As shown in the figure, the convolution layer is used to receive spatiotemporal features and further extract features from them. The dimension of the output feature map is (3, h, w); the GAP layer is used to perform color channel average operation on the feature map to obtain the average value of the feature map under each color channel. The output dimension of this layer is (3, 1, 1); finally, the dimension adjustment operation is performed to obtain the predicted light source estimation result y. Here, the GAP layer is used to directly obtain the mean output of each color channel, which can reduce the number of model parameters and calculations, simplify the network structure, and help reduce overfitting and improve the generalization ability of the model compared to the fully connected layer.
[0093] Based on the above introduction, it can be known that the first light source estimation result includes a plurality of first light source estimation sub-results output by the multi-layer light source prediction network, and the plurality of first light source estimation sub-results may include: to The second light source estimation result includes a plurality of second light source estimation sub-results output by the multi-layer light source prediction network, and the plurality of second light source estimation sub-results may include: to
[0094] Step 203: determining a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function.
[0095] The loss function is obtained by weighting the loss function of the multi-layer light source prediction network. Specifically, the loss function can be expressed as:
[0096]
[0097] in, represents the loss function corresponding to the single-layer light source prediction network, α layer Represents the weight of the loss function of a single-layer light source prediction network.
[0098] In some embodiments, the loss function corresponding to the last layer of light source prediction network in the multi-layer light source prediction network is the main loss function, and its weight can be set to 1. The loss functions of the remaining light source prediction networks serve as auxiliary losses, and their weights are set through hyperparameters, and their values do not exceed the weight of the main loss function.
[0099] Hyperparameters in neural networks refer to parameters that are set before the training process and affect model training. The weight of the auxiliary loss function is one of the hyperparameters here. Different values are set according to the depth of the network layer, experience, and experimental debugging. Taking the default setting of the multi-layer light source prediction network to 4 layers as an example, the loss function corresponding to the last layer of the multi-layer light source prediction network is the main loss function with a weight of 1. The initial weight values of the loss functions corresponding to the first to third layers of the light source prediction network can be set to 0.01, 0.05, and 0.125 respectively.
[0100] In some embodiments, the loss function of the single-layer light source prediction network includes a color correction loss function and a light source color consistency loss function under different brightness, where:
[0101] The color correction loss function is used to calculate the loss value of the light source estimation result predicted by the light source estimation model relative to the reference light source estimation result; specifically, in order to evaluate the accuracy of the light source estimation result, the angular error between the predicted light source and the real light source can be used as the color correction loss.
[0102] The light source color consistency loss function under different brightness is used to calculate the light source estimation loss value between sequence images of different brightness under the same light source scene predicted by the light source estimation model.
[0103] In some embodiments, the loss function of the single-layer light source prediction network is composed of an adaptive weighted fusion of a color correction loss function and a light source color consistency loss function under different brightness.
[0104] Specifically, the loss function of a single-layer light source prediction network can be expressed as:
[0105]
[0106] in,
[0107]
[0108]
[0109]
[0110]
[0111] in, represents the color correction loss, w color is the weight of the color correction loss, Indicates the color consistency loss of light source at different brightness, w bright is the weight of the light source color consistency loss under different brightness; y1 and y2 represent the light source estimation result of the first image sequence and the light source estimation result of the second image sequence in the same set of the training data, respectively. represents the reference light source estimation result, n represents the number of samples, "·" represents the dot product of the vector, ‖·‖ represents the modulus of the vector, arccos represents the inverse cosine function, which is used to convert the cosine value into an angle, lr is the learning rate, and Represents the gradient of the loss function with respect to the weights.
[0112] As described above, the loss function designed in the embodiment of the present application not only takes into account the color correction loss, but also takes into account the color consistency problem under different brightness, designs the color consistency loss of the light source under different brightness, and performs adaptive fusion, which helps to improve the accuracy and stability of the light source prediction. In addition, the embodiment of the present application also applies additional auxiliary losses to the middle layer of the multi-layer light prediction network, which can help the network learn more useful features, enhance the feature expression ability and improve generalization.
[0113] Step 204: Adjust the parameters of the light source estimation model according to the loss value.
[0114] It can be understood that two time series image data with different brightness in the same group of training data are respectively sent to the light source estimation model, and the first light source estimation result y1 and the second light source estimation result y2 are output. Then, the parameters of the light source estimation model and the adaptive weight parameters are continuously optimized through the back propagation algorithm to minimize the loss function. After a relatively small loss value is obtained through multiple iterations of training, the model training is regarded as successful, and the model structure and parameters are saved. Specifically, the reference light source estimation result corresponding to the above-mentioned first light source scene, the multiple first light source estimation sub-results, and the multiple second light source estimation sub-results are respectively input into the above-mentioned formulas (6) and (7), and the color estimation loss value corresponding to each single-layer light source prediction network in the multiple light source prediction networks and the light source estimation loss value under different brightness can be obtained; then, the color estimation loss value corresponding to each single-layer light source prediction network and the light source estimation loss value under different brightness are input into the above-mentioned formula (5), and the loss value corresponding to each single-layer light source prediction network can be obtained; and the loss value corresponding to each single-layer light source prediction network is input into the above-mentioned formula (4) to obtain the final loss value. The parameters of the light source estimation model are iteratively optimized based on the final loss value and the loss values corresponding to each single-layer light source prediction network until a preset convergence condition is met, thereby obtaining a trained light source estimation model.
[0115] A light source estimation model training method provided in an embodiment of the present application utilizes an image sequence with spatiotemporal information to train a light source estimation model and estimate the light source. Compared with the use of a single-frame image for light source estimation in the related art, the use of multiple-frame images can better learn the information of adjacent frame images, thereby reducing the error of single-frame estimation, adapting to environmental jumps, improving the stability of estimation results, preventing color jumps during image preview, and making the color of the image after white balance processing more consistent with the color of the real scene.
[0116] In addition, a light source estimation model training method provided in an embodiment of the present application adopts ConvLSTM as the basic unit of a single-layer light source prediction network. Since ConvLSTM can not only learn the spatial feature information of the image but also has a certain memory ability and can capture the long-term dependencies in the input image sequence, it can further reduce the error of single-frame estimation, adapt to environmental jumps, and improve the accuracy, stability and algorithm adaptability of the white balance results.
[0117] Furthermore, a method for training a light source estimation model provided in an embodiment of the present application generates new training data by light source enhancement and adds it to a training data set, which can make up for the impact of insufficient data sets on insufficient generalization of the model and enrich data diversity.
[0118] In addition, the light source estimation model training method provided in the embodiment of the present application not only takes into account the color correction loss when designing the loss function, but also takes into account the color consistency problem under different brightness, designs the light source color consistency loss under different brightness, and performs adaptive fusion, which helps to improve the accuracy and stability of light source prediction. In addition, additional auxiliary losses are applied to the middle layer of the multi-layer light prediction network, which can help the network learn more useful features, enhance the feature expression ability and improve generalization.
[0119] The above introduces a light source estimation model training method proposed in an embodiment of the present application. On this basis, an embodiment of the present application further proposes a light source estimation method, which is described below.
[0120] like Figure 6 As shown, a light source estimation method proposed in an embodiment of the present application may include:
[0121] Step 601: determine a third image sequence to be processed.
[0122] Step 602: input the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the light source estimation model training method, and the number of images contained in the third image sequence is consistent with the number of images in the image sequence input for training the light source estimation model.
[0123] Step 603: Using the output of the light source estimation model as the light source estimation result of the third image sequence, wherein the light source estimation result is used to adjust the color of at least one image in the third image sequence.
[0124] In some embodiments, Figure 6 The method shown may also include: adjusting the color of at least one image in the third image sequence according to the light source estimation result of the third image sequence.
[0125] A light source estimation method proposed in an embodiment of the present application uses a light source estimation model trained by a light source estimation model training method provided in an embodiment of the present application to perform light source estimation. Therefore, it can also reduce the error of single-frame estimation, adapt to environmental jumps, improve the stability of estimation results, prevent color jumps during image preview, and make the color of the image after white balance processing more consistent with the color of the real scene.
[0126] It should be noted that the light source estimation model training method provided in the embodiment of the present application can be executed by a light source estimation model training device, or a control module in the light source estimation model training device for executing the loading light source estimation model training method. In the embodiment of the present application, the light source estimation model training method provided in the embodiment of the present application is explained by taking the light source estimation model training device executing the loading light source estimation model training method as an example.
[0127] It should be noted that the execution subject of the light source estimation method provided in the embodiment of the present application may be a light source estimation device, or a control module in the light source estimation device for executing the loaded light source estimation method. In the embodiment of the present application, the light source estimation method provided in the embodiment of the present application is explained by taking the light source estimation device executing the loaded light source estimation method as an example.
[0128] The light source estimation device provided in the embodiment of the present application is described below.
[0129] like Figure 7 As shown, a light source estimation model training device provided by an embodiment of the present application may include: a data determination module 701, a data input module 702, a loss determination module 703 and a parameter adjustment module 704.
[0130] The data determination module 701 is used to determine a training data set, where the training data set includes multiple groups of training data, each group of the training data includes a first image sequence, a second image sequence, and a reference light source estimation result corresponding to the first image sequence, the first image sequence includes multiple frames of images continuously captured under a first light source scene, the second image sequence is obtained by performing a brightness transformation on the first image sequence, and the reference light source estimation result is used to describe the color characteristics of a real light source under the first light source scene.
[0131] The data input module 702 is used to input the first image sequence in a group of training data into the light source estimation model to obtain a first light source estimation result, and input the second image sequence in the same group of training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation based on the spatiotemporal features.
[0132] In some embodiments, the data determination module 701 is specifically used to: take each of the plurality of light source scenes as a first light source scene, and perform the following steps:
[0133] Step 1, in the first light source scene, continuously capture n frames of images, and shoot a reference image containing a color card within a first time period after capturing the n frames of images, wherein the first time period is a pre-set shorter time period, for example, the first time period is 3s, and the purpose is to capture the reference image containing the color card immediately after capturing the preview frame data.
[0134] After collecting a number of images and reference images for each light source scene, these data are preprocessed to obtain training data suitable for training the light source estimation model.
[0135] In some embodiments, the image captured by the camera is generally a raw format image, which contains more information. In order to speed up the calculation, before executing step 2, the captured raw format image can be converted into a stats format image.
[0136] Step 2: extract t frames of images every m frames from the n frames of images according to the acquisition time to obtain the first image sequence under the first light source scene.
[0137] Step 3: Process the reference image in the first light source scene to obtain a reference light source estimation result in the first light source scene.
[0138] Specifically, first, the colors of all pixels in the area where the color card is located in the reference image can be averaged by color channel to obtain a first vector containing the color averages under three color channels, for example, a first vector containing the color averages under three color channels of RGB can be obtained. It can be understood that the first vector contains 3 elements at this time; then, the first vector is normalized by the first color channel to obtain a second vector, wherein the first color channel is any one of the three color channels, for example, the first color channel can be G, and it can be understood that the normalized second vector also includes 3 elements; then, the second vector is used as the reference light source estimation result gtill in the light source scene. The reference light source estimation result in a light source scene can describe the color characteristics of the real light source in the light source scene, which is equivalent to the label of the first image sequence in the light source scene.
[0139] In some embodiments, training data with different brightness levels under the same light source scene may also be constructed through the following step 4.
[0140] Step 4: Perform brightness transformation on the first image sequence under the first light source scene to obtain a second image sequence with different brightness under the first light source scene.
[0141] Step 5: correspondingly save the first image sequence, the second image sequence, and the reference light source estimation result under the first light source scene to obtain a set of the training data.
[0142] In some other embodiments, the data determination module 701 may also be used to perform the following steps:
[0143] Step 6: Select at least one first image sequence from the multiple sets of training data.
[0144] For example, a certain ratio of first image sequences is randomly selected from the multiple sets of training data as objects for light source enhancement.
[0145] Step 7: perform white balance processing on the selected first image sequence.
[0146] Specifically, the existing white balance processing method may be used to perform white balance processing on the selected first image sequence.
[0147] Step 8: Use a light source in a second light source scene to perform light source enhancement on the first image sequence after white balance processing, wherein the light source color in the second light source scene is different from the light source color in the first light source scene.
[0148] Specifically, the principle of implementing light source enhancement on the first image sequence after white balance processing can be described as: using a new light source - the first light source to illuminate the image after white balance, and the new light source is the real light source of the new image. new , restore the white balanced image with the new light source to obtain I new , thus we can get the data pair after the light source enhancement. For one set of training data (I,gtill), randomly select a light source ill from other light sources in the training data set as the first light source, and the training data pair after the light source enhancement (I new ,gtill new ) is calculated as follows:
[0149]
[0150] gtill new =ill (3)
[0151] In some embodiments, determining the training data set may further include:
[0152] Step 9: performing brightness transformation on the first image sequence after light source enhancement to obtain the second image sequence with different brightness under the second light source scene.
[0153] The brightness transformation method may also be a logarithmic transformation.
[0154] Step 10: Save the first image sequence enhanced by the light source in the second light source scene, the second image sequence in the second light source scene, and the light source correspondingly to obtain a new set of training data.
[0155] Assume that the first image sequence after light source enhancement is I new , the first image sequence I new The corresponding reference light source estimation result is gtill new , the second image sequence after brightness transformation is I′ new , then we can convert (I new ,gtill new , I′ new ) as a new set of training data.
[0156] It can be understood that by generating new image sequences through light source enhancement and adding them to the training dataset, the impact of insufficient dataset on the generalization of the model can be compensated and data diversity can be enriched.
[0157] The loss determination module 703 is used to determine a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function.
[0158] In some embodiments, the spatiotemporal feature extraction network includes k layers of network units connected in sequence, wherein k is a positive integer, k is consistent with the number of images contained in the input target image sequence (i.e., k=t), the input of the first layer of network units in the k-layer network units is the first image I1 in the target image sequence of the input spatiotemporal feature extraction network 3, and the input of the i-th layer of network units in the k-layer network units includes the i-th image I1 in the target image sequence of the input spatiotemporal feature extraction network 311. i And the output of the i-1th layer network unit, 1<i<k, the output of the kth layer network unit in the k-layer network unit is the spatiotemporal features of the target image sequence input into the spatiotemporal feature extraction network, and the target image sequence includes the first image sequence or the second image sequence.
[0159] Wherein, the network unit is a convolutional long short-term memory network ConvLSTM.
[0160] The light source estimation network includes at least one convolution layer, a global average pooling GAP layer and an output data dimension adjustment layer, wherein:
[0161] The at least one convolutional layer is used for further feature extraction from the spatiotemporal features extracted by the spatiotemporal feature extraction network;
[0162] The GAP layer is used to determine the average value of the features extracted by the at least one convolution layer according to the color channel, and obtain a third vector formed by the average value under each color channel;
[0163] The output data dimension adjustment layer is used to perform a dimension adjustment operation on the third vector output by the GAP layer to obtain a light source estimation result of the image sequence input into the spatiotemporal feature extraction network.
[0164] In some embodiments, the loss function is obtained by weighting the loss function of the multi-layer light source prediction network, and the loss function of the single-layer light source prediction network includes a color correction loss function and a light source color consistency loss function under different brightness, wherein,
[0165] The color correction loss function is used to calculate the loss value of the light source estimation result predicted by the light source estimation model relative to the reference light source estimation result;
[0166] The light source color consistency loss function under different brightness is used to calculate the light source estimation loss value between sequence images of different brightness under the same light source scene predicted by the light source estimation model.
[0167] The loss function of the single-layer light source prediction network is detailed in the above formulas (5) to (9), which will not be repeated here.
[0168] The parameter adjustment module 704 is used to adjust the parameters of the light source estimation model according to the loss value.
[0169] It can be understood that two time series image data with different brightness in the same group of training data are respectively sent to the light source estimation model, and the first light source estimation result y1 and the second light source estimation result y2 are output. Then, the parameters of the light source estimation model and the adaptive weight parameters are continuously optimized through the back propagation algorithm to minimize the loss function. After a relatively small loss value is obtained through multiple iterations of training, the model training is regarded as successful, and the model structure and parameters are saved. Specifically, the reference light source estimation result corresponding to the above-mentioned first light source scene, the multiple first light source estimation sub-results, and the multiple second light source estimation sub-results are respectively input into the above-mentioned formulas (6) and (7), and the color estimation loss value corresponding to each single-layer light source prediction network in the multiple light source prediction networks and the light source estimation loss value under different brightness can be obtained; then, the color estimation loss value corresponding to each single-layer light source prediction network and the light source estimation loss value under different brightness are input into the above-mentioned formula (5), and the loss value corresponding to each single-layer light source prediction network can be obtained; and the loss value corresponding to each single-layer light source prediction network is input into the above-mentioned formula (4) to obtain the final loss value. The parameters of the light source estimation model are iteratively optimized based on the final loss value and the loss values corresponding to each single-layer light source prediction network until a preset convergence condition is met, thereby obtaining a trained light source estimation model.
[0170] A light source estimation model training device provided in an embodiment of the present application utilizes an image sequence with spatiotemporal information to train a light source estimation model and estimate the light source. Compared with the use of a single-frame image for light source estimation in the related art, the use of multiple-frame images can better learn the information of adjacent frame images, thereby reducing the error of single-frame estimation, adapting to environmental jumps, improving the stability of estimation results, preventing color jumps during image preview, and making the color of the image after white balance processing more consistent with the color of the real scene.
[0171] In addition, a light source estimation model training device provided in an embodiment of the present application adopts ConvLSTM as the basic unit of a single-layer light source prediction network. Since ConvLSTM can not only learn the spatial feature information of the image but also has a certain memory ability and can capture the long-term dependencies in the input image sequence, it can further reduce the error of single-frame estimation, adapt to environmental jumps, and improve the accuracy, stability and algorithm adaptability of white balance results.
[0172] Furthermore, an embodiment of the present application provides a light source estimation model training device, which generates new training data by light source enhancement and adds it to the training data set, thereby compensating for the impact of insufficient data sets on insufficient model generalization and enriching data diversity.
[0173] In addition, the light source estimation model training device provided by the embodiment of the present application not only takes into account the color correction loss when designing the loss function, but also takes into account the color consistency problem under different brightness, designs the light source color consistency loss under different brightness, and performs adaptive fusion, which helps to improve the accuracy and stability of light source prediction. In addition, additional auxiliary losses are applied to the middle layer of the multi-layer light prediction network, which can help the network learn more useful features, enhance the feature expression ability and improve generalization.
[0174] The above introduces a light source estimation model training device proposed in an embodiment of the present application. On this basis, an embodiment of the present application further proposes a light source estimation device, which is described below.
[0175] like Figure 8 As shown, a light source estimation device proposed in an embodiment of the present application may include: an image determination module 801, an image input module 802 and a result output module 803.
[0176] The image determination module 801 is used to determine a third image sequence to be processed.
[0177] The image input module 802 is used to input the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the above-mentioned light source estimation model training method, and the number of images contained in the third image sequence is consistent with the number of images in the image sequence input for training the light source estimation model.
[0178] The result output module 803 is used to use the output of the light source estimation model as the light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
[0179] In some embodiments, Figure 8 The device shown may also include: a color adjustment module, configured to adjust the color of at least one image in the third image sequence according to the light source estimation result of the third image sequence.
[0180] A light source estimation device proposed in an embodiment of the present application uses a light source estimation model trained by a light source estimation model training method provided in an embodiment of the present application to perform light source estimation. Therefore, it can also reduce the error of single-frame estimation, adapt to environmental jumps, improve the stability of estimation results, prevent color jumps during image preview, and make the color of the image after white balance processing more consistent with the color of the real scene.
[0181] Alternatively, if Fig. 9As shown, an embodiment of the present application also provides an electronic device 900, including a processor 901 and a memory 902, wherein the memory 902 stores a program or instruction that can be executed on the processor 901, and when the program or instruction is executed by the processor 901, each step of the above-mentioned light source estimation model training method or light source estimation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0182] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0183] Fig.10 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0184] The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009 and a processor 1010 and other components.
[0185] Those skilled in the art will appreciate that the electronic device 1000 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0186] Processor 1010 is used to determine a training data set, wherein the training data set includes multiple groups of training data, each group of the training data includes a first image sequence, a second image sequence, and a reference light source estimation result corresponding to the first image sequence, the first image sequence includes multiple frames of images continuously acquired in a first light source scene, the second image sequence is obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result is used to describe the color characteristics of a real light source in the first light source scene; the first image sequence in a group of the training data is input into a light source estimation model to obtain a first light source estimation result, and the second image sequence in the same group of the training data is input into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation according to the spatiotemporal features; a loss value is determined according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function; and parameters of the light source estimation model are adjusted according to the loss value.
[0187] Alternatively, the processor 1010 is used to determine a third image sequence to be processed; input the third image sequence into a light source estimation model; use the output of the light source estimation model as a light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
[0188] In an embodiment of the present application, an image sequence (multiple frames of images) is used to train a light source estimation model and estimate the light source. Compared with the use of a single frame of images for light source estimation in the related art, the use of multiple frames of images can better learn the information of adjacent frame images, thereby reducing the error of single frame estimation, adapting to environmental jumps, improving the stability of estimation results, preventing color jumps during image preview, and making the color of the image after white balance processing more consistent with the color of the real scene.
[0189] It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processor (Graphics Processing Unit, GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0190] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be 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), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0191] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0192] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned light source estimation model training method or light source estimation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0193] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0194] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned light source estimation model training method or the light source estimation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0195] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0196] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0197] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0198] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present application, all of which are within the protection of the present application.
Claims
1. A light source estimation model training method, characterized in that: The method comprises: Determine a training data set, the training data set includes multiple groups of training data, each group of the training data includes a first image sequence, a second image sequence, and a reference light source estimation result corresponding to the first image sequence, the first image sequence includes multiple frames of images continuously acquired under a first light source scene, the second image sequence is obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result is used to describe the color characteristics of a real light source under the first light source scene; Inputting the first image sequence in a group of the training data into a light source estimation model to obtain a first light source estimation result, and inputting the second image sequence in the same group of the training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation according to the spatiotemporal features; Determine a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function; Parameters of the light source estimation model are adjusted according to the loss value.
2. The method according to claim 1, characterized in that The determining of the training data set comprises: In the first light source scene, continuously acquiring n frames of images, and shooting a reference image including a color card within a first time period after acquiring the n frames of images; Extracting t frames of images every m frames from the n frames of images according to the acquisition time to obtain the first image sequence under the first light source scene; Processing the reference image under the first light source scene to obtain a reference light source estimation result under the first light source scene; Performing brightness transformation on the first image sequence to obtain the second image sequence with different brightness under the first light source scene; wherein n, m, and t are all positive integers, and n>t; The first image sequence, the second image sequence, and the reference light source estimation result under the first light source scene are correspondingly saved to obtain a set of the training data.
3. The method according to claim 2, characterized in that The determining of the training data set further includes: Selecting at least one first image sequence from the plurality of sets of training data; Performing white balance processing on the selected first image sequence; Performing light source enhancement on the first image sequence after white balance processing using a light source in a second light source scene, wherein a light source color in the second light source scene is different from a light source color in the first light source scene; Performing brightness transformation on the first image sequence after light source enhancement to obtain the second image sequence with different brightness under the second light source scene; The first image sequence enhanced by the light source in the second light source scene, the second image sequence in the second light source scene, and the light source are correspondingly saved to obtain a new set of the training data.
4. The method according to claim 2 or 3, characterized in that: The processing of the reference image in the first light source scene to obtain a reference light source estimation result in the first light source scene includes: Taking average values of all pixels in the area where the color card is located in the reference image under the first light source scene according to color channels to obtain a first vector containing color average values under three color channels; Normalizing the first vector according to a first color channel to obtain a second vector, wherein the first color channel is any one of the three color channels; The second vector is used as a reference light source estimation result in the first light source scene.
5. The method according to claim 1, characterized in that The spatiotemporal feature extraction network includes k layers of network units connected in sequence, wherein k is a positive integer, k is consistent with the number of images contained in the input target image sequence, the input of the first layer of network units in the k layers of network units is the first image in the target image sequence, the input of the i-th layer of network units in the k layers of network units includes the i-th image in the target image sequence and the output of the i-1-th layer of network units, 1<i<k, and the output of the k-th layer of network units in the k layers of network units is the spatiotemporal features of the target image sequence, and the target image sequence includes the first image sequence or the second image sequence.
6. The method according to claim 1, characterized in that The light source estimation network includes at least one convolution layer, a global average pooling GAP layer and an output data dimension adjustment layer, wherein: The at least one convolutional layer is used for further feature extraction from the spatiotemporal features extracted by the spatiotemporal feature extraction network; The GAP layer is used to determine the average value of the features extracted by the at least one convolution layer according to the color channel, and obtain a third vector formed by the average value under each color channel; The output data dimension adjustment layer is used to perform a dimension adjustment operation on the third vector output by the GAP layer to obtain a light source estimation result of the image sequence input into the spatiotemporal feature extraction network.
7. The method according to claim 1, characterized in that The loss function is obtained by weighting the loss function of the multi-layer light source prediction network. The loss function of the single-layer light source prediction network includes a color correction loss function and a light source color consistency loss function under different brightness, wherein: The color correction loss function is used to calculate the loss value of the light source estimation result predicted by the light source estimation model relative to the reference light source estimation result; The light source color consistency loss function under different brightness is used to calculate the light source estimation loss value between sequence images of different brightness under the same light source scene predicted by the light source estimation model.
8. The method according to claim 7, characterized in that The loss function of a single-layer light source prediction network is: in, in, represents the color correction loss, w color is the weight of the color correction loss, Indicates the color consistency loss of light source at different brightness, w bright is the weight of the light source color consistency loss under different brightness; y1 and y2 represent the light source estimation result of the first image sequence and the light source estimation result of the second image sequence in the same set of the training data, respectively. represents the reference light source estimation result, n represents the number of samples, "·" represents the dot product of the vector, ‖·‖ represents the modulus of the vector, arccos represents the inverse cosine function, which is used to convert the cosine value into an angle, lr is the learning rate, and Represents the gradient of the loss function with respect to the weights.
9. A light source estimation method, characterized in that: The method comprises: determining a third image sequence to be processed; Inputting the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the light source estimation model training method according to any one of claims 1 to 8, and the number of images contained in the third image sequence is consistent with the number of images in the first image sequence input for training the light source estimation model; The output of the light source estimation model is used as a light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
10. A light source estimation model training device, characterized in that: The device comprises: a data determination module, used to determine a training data set, the training data set comprising multiple groups of training data, each group of the training data comprising a first image sequence, a second image sequence and a reference light source estimation result corresponding to the first image sequence, the first image sequence comprising multiple frames of images continuously acquired under a first light source scene, the second image sequence being obtained by performing brightness transformation on the first image sequence, and the reference light source estimation result being used to describe the color characteristics of a real light source under the first light source scene; a data input module, used for inputting the first image sequence in a group of the training data into a light source estimation model to obtain a first light source estimation result, and inputting the second image sequence in the same group of the training data into the light source estimation model to obtain a second light source estimation result, wherein the light source estimation model includes at least two layers of light source prediction networks, each layer of the light source prediction network includes a spatiotemporal feature extraction network and a light source estimation network, the spatiotemporal feature extraction network is used to extract spatiotemporal features from the input image sequence, and the light source estimation network is used to perform light source estimation according to the spatiotemporal features; a loss determination module, configured to determine a loss value according to the first light source estimation result, the second light source estimation result, the reference light source estimation result in the same group of the training data, and a loss function; A parameter adjustment module is used to adjust the parameters of the light source estimation model according to the loss value.
11. A light source estimation device, characterized in that: The device comprises: An image determination module, used for determining a third image sequence to be processed; an image input module, configured to input the third image sequence into a light source estimation model, wherein the light source estimation model is trained by the light source estimation model training method according to any one of claims 1 to 8, and the number of images contained in the third image sequence is consistent with the number of images in the first image sequence input for training the light source estimation model; A result output module is used to use the output of the light source estimation model as the light source estimation result of the third image sequence, and the light source estimation result is used to adjust the color of at least one image in the third image sequence.
Citation Information
Patent Citations
A hyperspectral image classification method based on SRCM and a convolutional neural network
CN109598306A
Method and device for training optical flow estimation model and readable storage medium
CN115272423A
Method and system for establishing light source information prediction model
US20210216816A1
Cited By
Digital display visualization system based on XR technology
CN121053346A
Digital exhibition visualization system based on XR technology
CN121053346B
