Image color correction method and system based on combined model
By adopting an integrated learning method based on a combination model in image color correction, combining adaptive enhancement algorithm and gradient enhancement decision tree algorithm, the problem of poor color correction effect in the existing technology is solved, and a color correction effect with higher accuracy and applicability is achieved.
Patent Information
- Application Number
- CN202211290804.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-21
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-10-21
AI Technical Summary
The prior art has problems with poor results in color correction, especially in strict application scenarios such as Chinese herbal medicine grading and similar color segmentation, and images with severe color distortion, especially underwater images, have insufficient correction effect and robustness.
Using the image color correction method based on the combined model, through integrated learning ideas, the adaptive enhancement algorithm and the gradient enhancement decision tree algorithm are combined to establish multiple color correction models, and through weight allocation and combination, a higher precision model is formed for color correction.
It improves the accuracy and effect of image color correction, can better restore the color of the image, solves the problem of distortion of image color acquisition by the device, and shows higher applicability in strict application scenarios.
Smart Images

Figure CN115482300B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an image color correction method and system based on a combination model, and belongs to the technical field of image color correction. Background Art
[0002] Nowadays, high-quality images are an important prerequisite for image processing. However, due to the influence of environmental factors and camera equipment parameters, the collected images often have serious color distortion problems, which increases the difficulty of subsequent image processing.
[0003] The purpose of color correction is to solve the problem of color distortion that occurs during the acquisition process of the equipment, and to restore the color presented in the captured image to what the human eye intuitively perceives as much as possible, that is, "what you see is what you get". At present, polynomial regression or the method of establishing a color correction matrix has been widely used in related fields, and these methods have also achieved remarkable results in color correction. However, these methods can only achieve a certain effect of restoration for images with severe color distortion, and for relatively strict application scenarios, such as Chinese herbal medicine grading and similar color segmentation, the effect is often unsatisfactory. In addition, the method of combining color compensation with linear mapping has gradually emerged, and its color correction effect is better, but for images with severe color distortion, especially underwater images with severe loss of some details, the effectiveness and robustness of its correction are greatly reduced, so it is not widely applicable.
[0004] In recent years, machine learning has gradually emerged and shined in related fields such as data analysis, prediction and classification, providing a driving force for many life services used today. In order to solve the problems of the above methods and introduce machine learning methods into the direction of image color correction, researchers have been looking for an ideal technical solution. Summary of the invention
[0005] The present invention provides an image color correction method and system based on a combined model, which uses the ensemble learning concept in machine learning and combines two models after assigning weights, so that the final model has higher accuracy, thereby better restoring the color of the image and solving the color distortion problem generated during the camera's image acquisition process.
[0006] The technical solution of the present invention is: an image color correction method based on a combined model, comprising:
[0007] Read the Lab value of each color block on the color card, convert the Lab value into RGB value according to the conversion matrix, separate the three channels of RGB value, and establish a three-channel real value data set;
[0008] Use a camera to take a picture of the color card, and use a computer to segment each color block and read the average RGB value of each color block, separate the three channels, and establish a three-channel measurement value data set;
[0009] An adaptive enhancement algorithm is used to fit the three-channel real value data set and the measured value data set respectively, and the parameters are optimized to obtain the R1, G1, and B1 color correction models with the best parameters.
[0010] A gradient boosting decision tree algorithm is used to fit the true value data set and the measured value data set of the three channels respectively, and the parameters are optimized to obtain the R2, G2, and B2 color correction models with the best parameters.
[0011] The weights of the two color correction models corresponding to the three channels R, G, and B are respectively assigned and combined into three combination models: R combination, G combination, and B combination, to perform color correction on the image.
[0012] The conversion matrix used when converting the L*ab value to the RGB value is selected according to the parameters of the camera.
[0013] The specific process of the adaptive enhancement algorithm is as follows:
[0014] S31, initialize the weight of the sample set: W1 = [w 1,1 ,w 1,2 ,…,w 1,i ,…,w 1,m ], represents the weight of the i-th sample at the first iteration, and m is the total number of samples in the sample set; the sample set is constructed using the real value data set and the measured value data set;
[0015] S32, train the jth weak learner G according to the weight j (x);
[0016] S33, calculate the maximum error: E j =max|y i -G j (x)|; where E j represents the maximum error at the jth iteration, y i is the true value corresponding to the i-th sample;
[0017] S34. Calculate the relative square error of each sample: Among them, e ji Represents the relative square error of the i-th sample at the j-th iteration;
[0018] S35. Calculate the error rate: Among them, e j represents the error rate of the jth iteration;
[0019] S36. Calculate the coefficients of the weak learner:
[0020] S37. Update the weight distribution of samples: Among them, Z j is the normalization factor;
[0021] S38, repeat the above process from S32 to S37 until k weak learners are trained;
[0022] S39. Perform weighted combination on the obtained k weak learners to construct a strong learner.
[0023] The gradient boosting decision tree algorithm includes:
[0024] S41, randomly shuffle the samples in the sample set, and estimate the first-order and second-order gradients of the sample prediction results;
[0025] S42, use gradient estimation to build a tree structure, and finally the threshold of each leaf node is determined by the entire sample;
[0026] S43. During the training process, by integrating weak learners in series, the weights are continuously replaced according to the learning results of the previous round, so as to continuously reduce the deviation caused by noise;
[0027] S44. Finally, the final strong learner is obtained by weighting the regression values of all weak learners trained.
[0028] The weights of the two color correction models corresponding to the three channels R, G, and B are determined as follows: in, That is, it represents the predicted value of the tth correction model and the true value y i The sum of the squares of the differences.
[0029] According to another aspect of an embodiment of the present invention, there is also provided an image color correction system based on a combination model, comprising:
[0030] The first establishment module is used to read the Lab value of each color block on the color card, convert the Lab value into RGB value according to the conversion matrix, separate the three channels of RGB value, and establish a three-channel real value data set;
[0031] The second establishment module is used to use a camera to shoot the color card, and divide each color block by a computer and read the average RGB value of each color block, separate the three channels, and establish a three-channel measurement value data set;
[0032] The first acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through an adaptive enhancement algorithm, perform parameter optimization, and obtain the R1, G1, and B1 color correction models with the best parameters;
[0033] The second acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through a gradient boosting decision tree algorithm, perform parameter optimization, and obtain the R2, G2, and B2 color correction models with the best parameters;
[0034] The correction module is used to respectively assign weights of the two color correction models corresponding to the three channels of R, G, and B, and combine them into three combination models of R combination, G combination, and B combination to perform color correction on the image.
[0035] The beneficial effects of the present invention are as follows: the present invention digitizes the image pixels, performs targeted processing on the values of the three channels respectively, establishes different model parameters, uses machine learning methods, obtains good color correction effects, and solves the problem of color distortion of images collected by the device well. Different conversion matrices are selected according to different camera setting parameters to make the converted values more accurate. In addition, the method of data fitting using a combined model is introduced into the field of color correction to improve fitting accuracy and further enhance the effect of color correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of a flow chart of an image color correction method based on a combined model of the present invention;
[0037] Figure 2 is a principle flow chart of the adaptive enhancement method used in step S3 of the present invention;
[0038] Figure 3 A structural diagram of a tree of the gradient boosting decision tree algorithm used in step S4 of the present invention;
[0039] Figure 4 The color difference line graph after correction of two single models combining the present invention and the polynomial regression method;
[0040] Figure 5 For randomly selecting ten color blocks, a color comparison diagram is shown after correction by two single models combining the present invention and the polynomial regression method. DETAILED DESCRIPTION
[0041] The invention is further described below in conjunction with the accompanying drawings and embodiments, but the content of the invention is not limited to the scope of the embodiments.
[0042] Example 1: Figure 1-5As shown, a method for image color correction based on a combination model includes: reading the Lab value of each color block on a color card, converting the Lab value into an RGB value according to a conversion matrix, separating the three channels of the RGB value, and establishing a three-channel true value data set; using a camera to shoot the color card, and using a computer to segment each color block and read the average RGB value of each color block, separating the three channels, and establishing a three-channel measured value data set; using an adaptive enhancement algorithm to fit the three-channel true value data set and the measured value data set, respectively, and perform parameter optimization to obtain R1, G1, and B1 color correction models with optimal parameters; using a gradient boosting decision tree algorithm to fit the three-channel true value data set and the measured value data set, respectively, and perform parameter optimization to obtain R2, G2, and B2 color correction models with optimal parameters; and respectively assigning weights to the two color correction models corresponding to the three channels of R, G, and B, and combining them into three combination models of R combination, G combination, and B combination to perform color correction on the image.
[0043] Furthermore, the conversion matrix used when converting the L*ab value to the RGB value is selected according to the parameters of the camera.
[0044] Furthermore, the specific process of the adaptive enhancement algorithm is as follows:
[0045] S31, initialize the weight of the sample set: W1 = [w 1,1 ,w 1,2 ,…,w 1,i ,…,w 1,m ], represents the weight of the i-th sample at the first iteration, and m is the total number of samples in the sample set; the sample set is constructed using the real value data set and the measured value data set;
[0046] S32, train the jth weak learner G according to the weight j (x);
[0047] S33, calculate the maximum error: E j =max|y i -G j (x)|; where E j represents the maximum error at the jth iteration, y i is the true value corresponding to the i-th sample;
[0048] S34. Calculate the relative square error of each sample: Among them, e ji Represents the relative square error of the i-th sample at the j-th iteration;
[0049] S35. Calculate the error rate: Among them, e jrepresents the error rate of the jth iteration;
[0050] S36. Calculate the coefficients of the weak learner:
[0051] S37. Update the weight distribution of samples: Among them, Z j is the normalization factor;
[0052] S38, repeat the above process from S33 to S37 until k weak learners are trained;
[0053] S39. Perform weighted combination on the obtained k weak learners to construct a strong learner.
[0054] Furthermore, the gradient boosting decision tree algorithm includes:
[0055] S41, randomly shuffle the samples in the sample set, and estimate the first-order and second-order gradients of the sample prediction results;
[0056] S42, use gradient estimation to build a tree structure, and finally the threshold of each leaf node is determined by the entire sample;
[0057] S43. During the training process, by integrating weak learners in series, the weights are continuously replaced according to the learning results of the previous round, so as to continuously reduce the deviation caused by noise;
[0058] S44. Finally, the final strong learner is obtained by weighting the regression values of all weak learners trained.
[0059] The weights of the two color correction models corresponding to the three channels R, G, and B are determined as follows: in, That is, it represents the predicted value of the tth correction model and the true value y i The sum of the squares of the differences.
[0060] An optional implementation manner of the present invention is described in detail below.
[0061] S1. Use a spectrophotometer to extract the true values of 1048 color blocks on the color card. The initial extraction is the Lab value. The Lab value is converted to RGB value by using the XYZ color space. The conversion matrix is selected according to the light source and field of view angle of the camera (in this example, the light source is D50 and the field of view angle is 2°). The obtained RGB values are divided into channels to establish the R true value data set, G true value data set, and B true value data set. The XYZ2RGB conversion matrix at D50, 2° is as follows:
[0062]
[0063] S2. Use a camera to photograph the color card, and use a computer to segment the color blocks on the color card and read the average RGB value of each color block, and establish an R measurement value data set, a G measurement value data set, and a B measurement value data set by channel.
[0064] S3. Fit the three-channel true value data set and the measured value data set by an adaptive enhancement algorithm. The adaptive enhancement algorithm uses the idea of the forward step-by-step algorithm, and its loss function is set to the square error loss. It only needs to use a regression tree to fit the residual in each round, and add the linear models finally obtained. The specific method is as follows Figure 2 As shown, the following steps are included:
[0065] Step 301, initialize the weight of the sample set: W1 = [w 1,1 ,w 1,2 ,…,w 1,i ,…,w 1,m ], represents the weight of the i-th sample at the first iteration, and m is the total number of samples in the sample set; the sample set is constructed using the real value data set and the measured value data set;
[0066] Step 302: Train the jth weak learner G according to the weights j (x); Figure 2 As shown, the total number of iterations of the weak learner is k; if it is the first iteration, the initialized weights are used to train the weak learner;
[0067] Step 303: Calculate the maximum error: E j =max|y i -G j (x)|; where E j represents the maximum error at the jth iteration, y i is the true value corresponding to the i-th sample;
[0068] Step 304: Calculate the relative square error of each sample: e ji Represents the relative square error of the i-th sample at the j-th iteration;
[0069] Step 305: Calculate the error rate: e j represents the error rate of the jth iteration;
[0070] Step 306: Calculate the coefficient of the weak learner:
[0071] Step 307: Update the weight distribution of samples: Where Zj is the normalization factor w j+1,i represents the weight of the i-th sample at the j+1-th iteration;
[0072] Step 308: Repeat the process from step 302 to step 307 until k weak learners are trained;
[0073] Step 309: weighted combination of the obtained k weak learners to construct a strong learner. The data of the three channels are processed through the above steps respectively, and finally three strong learners are obtained, that is, the R1 color correction model, the G1 color correction model, and the B1 color correction model are finally established.
[0074] S4, respectively fitting the true value data set and the measured value data set of the three channels by a gradient boosting decision tree algorithm, performing parameter optimization, and obtaining the R2, G2, and B2 color correction models with the best parameters; comprising the following steps:
[0075] S401, randomly shuffle the samples in the sample set, and estimate the first-order and second-order gradients of the sample prediction results;
[0076] S402, constructing a tree structure using gradient estimation, and finally the threshold of each leaf node is determined by the entire sample;
[0077] S403, during the training process, by integrating the weak learners in series, the weights are continuously replaced according to the learning results of the previous round, so as to continuously reduce the deviation caused by noise;
[0078] S404: Finally, the final strong learner is obtained by weighting the regression values of all weak learners in the training. The data of the three channels are processed through the above steps respectively, and finally three strong learners are obtained, namely, R2, G2, and B2 color correction models.
[0079] The gradient boosting decision tree algorithm not only uses greedy combination to effectively improve the prediction accuracy, but also applies the ordered enhancement method to optimize the gradient offset. For internal nodes of the same depth, the feature thresholds selected in the splitting process are completely equal, so it has the advantages of being more balanced and faster in processing than general decision trees.
[0080] S5, respectively assign weights of two color correction models corresponding to the three channels of R, G, and B, and combine them into three combination models of R combination, G combination, and B combination to perform color correction on the image. The weights are determined by the size of the sum of squared errors, and the model with a small sum of squared errors is given a high weight. By combining the models, the advantages of each model are fully utilized to effectively improve the credibility of the predicted value. The method for determining the weights is as follows: (in, That is, it represents the sum of squares of the difference between the predicted value and the true value of the tth correction model.
[0081] Select any ten color blocks to verify the correction effect.
[0082] like Figure 4 As shown, the present invention provides a line graph comparing the color difference values after correction with the other three methods. From the experimental results, it can be observed that, first, the four methods can reduce the color difference generated during the camera image acquisition process. The correction result of polynomial regression is worse than that of the other three methods using machine learning algorithms, and there is still a large color difference. The correction results of the adaptive enhancement algorithm fitting model and the gradient boosting decision tree algorithm fitting model are similar, and the color difference values after correction are all smaller than the color difference values after polynomial regression correction, but the color difference values are still generally greater than 5. The correction result of the combined model is better than the other three methods, and the color difference values after correction are all reduced to within 3.
[0083] like Figure 5 As shown, the present invention provides a comparison chart of the effects after correction with the other three methods, in which the reproduction of the real color is achieved by inputting the real value. It can be observed intuitively that there is a large color difference between the image taken by the camera and the real color, and the correction effect of polynomial regression is unsatisfactory, and there is still a large difference; the correction effect of the two single models is better, and the color presented by the real value is closer; and the combined model proposed by the present invention is relatively closer to the real color, which is difficult to distinguish with the naked eye, and its correction effect is very impressive.
[0084] According to another aspect of an embodiment of the present invention, there is also provided an image color correction system based on a combination model, comprising:
[0085] The first establishment module is used to read the Lab value of each color block on the color card, convert the Lab value into RGB value according to the conversion matrix, separate the three channels of RGB value, and establish a three-channel real value data set;
[0086] The second establishment module is used to use a camera to shoot the color card, and divide each color block by a computer and read the average RGB value of each color block, separate the three channels, and establish a three-channel measurement value data set;
[0087] The first acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through an adaptive enhancement algorithm, perform parameter optimization, and obtain the R1, G1, and B1 color correction models with the best parameters;
[0088] The second acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through a gradient boosting decision tree algorithm, perform parameter optimization, and obtain the R2, G2, and B2 color correction models with the best parameters;
[0089] The correction module is used to respectively assign weights of the two color correction models corresponding to the three channels of R, G, and B, and combine them into three combination models of R combination, G combination, and B combination to perform color correction on the image.
[0090] It should be noted here that the above-mentioned first establishment module, second establishment module, first acquisition module, second acquisition module and correction module correspond to steps S1 to S5 in Example 1, and the examples and application scenarios implemented by the above-mentioned modules are the same as those of the corresponding steps, but are not limited to the contents disclosed in the above-mentioned Example 1.
[0091] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. An image color correction method based on a combination model, characterized in that: include: Read the Lab value of each color block on the color card, convert the Lab value into RGB value according to the conversion matrix, separate the three channels of RGB value, and establish a three-channel real value data set; Use a camera to take a picture of the color card, and use a computer to segment each color block and read the average RGB value of each color block, separate the three channels, and establish a three-channel measurement value data set; An adaptive enhancement algorithm is used to fit the three-channel real value data set and the measured value data set respectively, and the parameters are optimized to obtain the R1, G1, and B1 color correction models with the best parameters. A gradient boosting decision tree algorithm is used to fit the true value data set and the measured value data set of the three channels respectively, and the parameters are optimized to obtain the R2, G2, and B2 color correction models with the best parameters. Assign weights of the two color correction models corresponding to the three channels of R, G, and B respectively, and combine them into three combination models: R combination, G combination, and B combination, to perform color correction on the image; The specific process of the adaptive enhancement algorithm is as follows: S31, initialize the weight of the sample set: W1 = [w 1,1 ,w 1,2 ,…,w 1,i ,…,w 1,m ], represents the weight of the i-th sample at the first iteration, and m is the total number of samples in the sample set; the sample set is constructed using the real value data set and the measured value data set; S32, train the jth weak learner G according to the weight j (x); S33, calculate the maximum error: E j =max|y i -G j (x)|; where E j represents the maximum error at the jth iteration, y i is the true value corresponding to the i-th sample; S34. Calculate the relative square error of each sample: Among them, e ji Represents the relative square error of the i-th sample at the j-th iteration; S35. Calculate the error rate: Among them, e j represents the error rate of the jth iteration; S36. Calculate the coefficients of the weak learner: S37. Update the weight distribution of samples: Among them, Z j is the normalization factor; S38, repeat the above process from S32 to S37 until k weak learners are trained; S39, performing weighted combination on the obtained k weak learners to construct a strong learner; The gradient boosting decision tree algorithm includes: S41, randomly shuffle the samples in the sample set, and estimate the first-order and second-order gradients of the sample prediction results; S42, use gradient estimation to build a tree structure, and finally the threshold of each leaf node is determined by the entire sample; S43. During the training process, by integrating weak learners in series, the weights are continuously replaced according to the learning results of the previous round, so as to continuously reduce the deviation caused by noise; S44. Finally, the final strong learner is obtained by weighting the regression values of all weak learners trained.
2. The image color correction method based on the combined model according to claim 1, characterized in that: The conversion matrix used when converting the L*ab value to the RGB value is selected according to the parameters of the camera.
3. The image color correction method based on the combined model according to claim 1, characterized in that: The weights of the two color correction models corresponding to the three channels R, G, and B are determined as follows: in, That is, it represents the predicted value of the tth correction model and the true value y i The sum of the squares of the differences.
4. An image color correction system based on a combination model, characterized in that: include: The first establishment module is used to read the Lab value of each color block on the color card, convert the Lab value into RGB value according to the conversion matrix, separate the three channels of RGB value, and establish a three-channel real value data set; The second establishment module is used to use a camera to shoot the color card, and divide each color block by a computer and read the average RGB value of each color block, separate the three channels, and establish a three-channel measurement value data set; The first acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through an adaptive enhancement algorithm, perform parameter optimization, and obtain the R1, G1, and B1 color correction models with the best parameters; The second acquisition module is used to fit the real value data set and the measured value data set of the three channels respectively through a gradient boosting decision tree algorithm, perform parameter optimization, and obtain the R2, G2, and B2 color correction models with the best parameters; The correction module is used to respectively assign weights of two color correction models corresponding to the three channels of R, G, and B, and combine them into three combination models of R combination, G combination, and B combination to perform color correction on the image; The specific process of the adaptive enhancement algorithm is as follows: S31, initialize the weight of the sample set: W1 = [w 1,1 ,w 1,2 ,…,w 1,i ,…,w 1,m ], represents the weight of the i-th sample at the first iteration, and m is the total number of samples in the sample set; the sample set is constructed using the real value data set and the measured value data set; S32, train the jth weak learner G according to the weight j (x); S33, calculate the maximum error: E j =max|y i -G j (x)|; where E j represents the maximum error at the jth iteration, y i is the true value corresponding to the i-th sample; S34. Calculate the relative square error of each sample: Among them, e ji Represents the relative square error of the i-th sample at the j-th iteration; S35. Calculate the error rate: Among them, e j represents the error rate of the jth iteration; S36. Calculate the coefficients of the weak learner: S37. Update the weight distribution of samples: Among them, Z j is the normalization factor; S38, repeat the above process from S32 to S37 until k weak learners are trained; S39, performing weighted combination on the obtained k weak learners to construct a strong learner; The gradient boosting decision tree algorithm includes: S41, randomly shuffle the samples in the sample set, and estimate the first-order and second-order gradients of the sample prediction results; S42, use gradient estimation to build a tree structure, and finally the threshold of each leaf node is determined by the entire sample; S43. During the training process, by integrating weak learners in series, the weights are continuously replaced according to the learning results of the previous round, so as to continuously reduce the deviation caused by noise; S44. Finally, the final strong learner is obtained by weighting the regression values of all weak learners trained.