Several methods of image color correction

Various teaching videos or documents +QQ: 635992897

Note: This article mainly refers to the master's thesis of "color correction of color face image and its application in the diagnosis of liver disease"

       The color of the collected picture has a great relationship with the collection environment. The color of the picture obtained by the same sample in different collection environments is different, which affects the comparison between samples, so it is necessary to
perform color correction on the collected samples . Color correction algorithm we use is based on the idea of supervision, namely the color correction of images through standard color, the color correction in the current direction, already had many ways, that
the main idea of polynomial regression algorithm based supervision, artificial neural networks, SVR method, which several algorithms have advantages and disadvantages, questions need to be based on the actual parameter settings, which polynomial regression calculation
emphasis method is to set the number of items and polynomial form, artificial neural network algorithms need to set up neurons The SVR algorithm needs to set the error penalty weight, kernel function form and parameters, allowable error range
and other parameters. The different parameter settings will directly affect the correction result. Therefore, the parameter setting is the focus of various algorithms and is also discussed in this chapter. Focus. In addition, this chapter also proposes a new color correction criterion.
Under this criterion, the correction algorithm can be terminated early to obtain an optimal correction result, and the pros and cons of various correction algorithms are evaluated according to the criterion, and the color correction algorithm is selected. Optimal algorithm. These
algorithms are described in detail below , and they are used in the color correction of facial images, and the optimal correction algorithm is selected according to the evaluation criteria.

        1. Polynomial regression

Polynomial regression algorithms are mostly used for printer color correction, requiring less storage space, fast calculation speed, and easy implementation. The key technology of the polynomial regression algorithm is about the selection of combinations in the polynomial. It is not that
the more items there are, the better the regression effect, but a reasonable choice based on your actual situation.

Let’s briefly describe the principle of color correction based on multiple linear regression
. Suppose there are N color patches on the colorimetric plate. The color tristimulus values ​​of the i-th color patch are Roi, G0i, B0i in the standard space, and in
natural light environment The tristimulus values ​​of the i-th color patch on the colorimetric plate to be corrected collected below are Ri, Gi, Bi, where i= 1,2,3.......N, then:

 

Among them, Vji (j=1,...,J) is made up of polynomials, and there are various polynomial forms, for example, V=[R, G, B, 1], V=[R, G, B, RG, RB, GB, 1], V=[R, G, B, RGB,
1], etc. The form of V can be combined into different forms as required. 
The matrix form of Equation 2-1 is:

Among them: X is the color scale standard tristimulus value matrix with dimension 3×I

A is the conversion coefficient matrix with dimension J×3

V is a polynomial regression matrix with dimension J×I

The matrix A can be optimized by the least square method, and A is the model parameter to be sought.

Therefore, by bringing A into equation 2-4, the R, G, and B values ​​of each pixel of the corrected image can be calculated, and online color correction can be realized. Among them, Xout is the R, G, and B tristimulus value matrix of the corrected image, with a dimension
of 3×M; is a matrix composed of polynomial terms corresponding to the R, G, and B values ​​of all pixels in the original image, and the dimension is It is J×M; M is the total number of pixels of the original image.

The key to the polynomial regression algorithm is to design a reasonable number of polynomial terms. In the color correction experiment, we designed two sets of AB terms for comparison experiments. Group A has only various combinations of R, G, and B values, and
group B is Add a constant term "1" on the basis of group A, the purpose is to see what effect the constant term "1" has on the result, select the group with better results, and finally combine all the values ​​of the two sets of experiments to find the calibration

The item that works best. The items of Group A are designed as follows:

The items in group B are a constant item "1" after the items in group A. The experiment in section 2.4.2 shows that the effect of group A is higher than that of group B, and the optimal number of correction terms is the 9-term polynomial of group A.

2. Backward propagation network

     Neural networks are physically realizable system employed to describe and simulate the structure and function of human brain cells, is structured into feedforward artificial neural network, the artificial neural network feedback, self-organizing competitive human
neural networks and neural networks random Among them, the most widely used is the feedback type artificial neural network, which is the backward propagation network, or BP network for short.

     The basic idea is that the process of BP algorithm learning process by the forward propagation and back propagation of the error signal, starting from the forward propagation of the input samples, passes through the input layer, each of the hidden layer to the output layer, if obtained
the desired output and If the output does not meet the requirements or does not meet the requirements, the error back propagation process begins. Back propagation is to pass the output error from the output layer through the hidden layers, and finally to the input layer. The error is distributed to
all units in each layer, so as to obtain the but The desired error signal is to correct the weight of each unit.
     The structure of the BP network is shown in Figure 2-1. This is the simplest BP network structure. One input layer, one hidden layer, and one output layer. Each layer has 3 neurons, a total of 9 neurons. The
error is propagated to the opposite direction.
      The following briefly introduces the functions that need to be used in the experiment. First look at the three most commonly used excitation functions
, step function hardlim(x), linear transfer function purelin(x), logarithmic sigmoid function logsig(x) and
tangent The sigmoid function tansig(x) is shown in Figure 2-2.

The BP network uses Widrow-Hoff learning algorithm and a multilayer network of nonlinear differentiable transfer functions. A typical BP network uses a gradient descent algorithm.
The specific process of color correction algorithm based on BP network is divided into training phase and testing phase:

1) In the training stage,
use the color block value of the color card for training, extract the RGB value from the color card picture to be corrected as input, and the standard value of the color card is known (the color card production company will provide the standard color block value) , The standard
value of the color card is used as the supervision value. There are 24 color blocks on each color card picture, that is to say, the total number of input samples of the BP network is 24, and each sample has R, G, B, and 3 input values. After the hidden layer, the final output is also 3
values , As the result of BP correction, compare with the standard value of the color block, calculate the error, then backpropagate, correct the weight of each layer, and then input data from the input layer, pass through the hidden layer to the output layer, and calculate the error
until it reaches the end Standard, the training phase is over, the trained BP network is the weight of each layer connection line and each neuron excitation function.

2) Testing phase
Using the BP network trained in the training phase, each pixel value of the face image to be corrected is brought into the network for calculation. The R, G, and B value of each pixel is an input, and the output is the corrected image of the pixel
After all the pixel values ​​of the face picture are calculated by the BP network, the corrected face picture is a new image composed of the output values ​​of the BP network.
The BP algorithm uses the neural network toolbox of matlab7.5. There are many parameters that need to be set, such as the initial value, the excitation function, the number of neurons in each layer, the error propagation criterion, the weight learning criterion, and the termination criterion.
These will affect the results. The parameter settings are as follows:

(1) The network structure
because the amount of input data is small, there are only 24 samples, the input is simple, each sample has only 3 dimensions, so the required network structure is also very simple, otherwise there will be overfitting. In this laboratory, select the single Hidden layer
network structure, input neurons 3, output neurons 3, the number of hidden layer neurons try 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, according to the correction results Which one is the most suitable.
(2) Activation function The
hidden layer uses the tangent sigmoid function tan-sigmoid; the output layer uses the linear transfer function purelin.
(3) Data processing The
input data adopts the default processing method of matlab neural network toolbox function newff, namely: fixunkonwns, removeconstractrows, mapminmax; output data processing method:
removeconstractrows, mapminmax; the grouping is random grouping during data training.
(4)
The selection of the initialization method of weights and biases depends on the activation function. initnw is usually used for the activation function as a curve function. It generates initial weights and bias values ​​for the layer according to Nguyen and Widrow[NgWi90], so that every
The active area of layer neurons can be roughly flat distributed in the input space. The activation function used by initwb is a linear function, usually set to rands, with a random value between -1 and 1. According to the activation functions are tansig and
purelin, so the initialization method is: the first layer initnw, the second layer intwb, rands.
(5) Training method
Batch processing method, update weights and biases according to Levenberg-Marquardt optimal criterion.
(6) Learning rate
Using the momentum-driven gradient descent method learngdm, it can provide a faster convergence rate. The momentum gradient descent method comprehensively considers the current gradient and the recent trend response of the error surface, and adds the weight
to the network learning by making the weight the same as the sum of the last weight change part and the new change obtained by the algorithm rule.
(7) Termination conditions

The maximum number of cycles is 200, and the maximum error is 0.01.

3. Support vector regression

SVM algorithm has many advantages in solving small sample, nonlinear and high dimensional pattern recognition problems in recent years, are increasingly being used in various fields, Zhang Hongzhi, who first used the idea of SVM Tongue Yan
color correction On the above, very good results have been achieved. Compared with polynomial regression, it has great advantages.

Support vector machines are based on the VC dimension theory and the principle of structural risk minimization to minimize the expected error and achieve the best classification results. The SVM method is proposed from the optimal classification surface in the case of linear separability
. The idea of ​​support vector machine: first transform the input space to a high-dimensional space through nonlinear transformation, and then find the optimal linear classification surface in this new space, as shown in Figure 2-3. Support vector regression is
a regression model of support vector machine, which fits the data distribution according to statistical data.

The solution process of the support vector machine is briefly introduced as follows:
Use the inner product K(x,x) to replace the dot product in the optimal classification surface, and the optimization function is: 2-5

The corresponding discriminant function is: 2-6

The regression parameter becomes: 2-7

It has the following restrictions:

Under the above restrictions, Eq. (2-7) can be used to obtain Lagrange multipliers. Only when it is non-zero, it corresponds to the support vector SVM, and then the regression function of the following form is obtained, that is, the tongue image color
correction function f(x):

among them:

There are currently three main inner product functions:
1. The inner product function in polynomial form, namely  

2. Use kernel function type inner product
3. Use sigmoid function as inner product

The color correction algorithm based on SVR uses epsilon-insensitive loss function, and the inner product function is Gaussian kernel function. First, three models need to be established. The input data of each model is the same, which is
the R of the 24 color patches in the color palette to be corrected . , G and B values, the output is R value, G value and B value respectively. To build the model, you must first select the parameters C and g, p value, C value is the error penalty weight of SVR, g
value is the gamma in the parameters of the kernel function , p is the allowable error epsilon, here we think that the parameters of the three-channel model are the same. For the selection of the three parameters, the method
is as follows: only one parameter is changed at a time, and the other two parameters are fixed. The choice is made according to the Lab space before and after the calibration  . The smaller the parameter, the better the result under this parameter.

Calibration algorithm evaluation

      After using various methods to perform color correction on tongue or face images, there must be a unified criterion to evaluate the pros and cons of various methods. The evaluation of color reproduction involves the
fields of colorimetry, physiology, psychology, etc. A very complex problem, the commonly used evaluation methods are divided into subjective evaluation and objective evaluation.
Subjective evaluation is to allow some observers to visually evaluate and score the quality of color correction, and judge the quality of color reproduction based on the scores. This method is intuitive and reliable, but it cannot
quantitatively analyze color reproduction. The objective evaluation is to use a set of specific color scales under certain conditions to judge by calculating the difference of the tristimulus values, generally using CIELab and CIELUV space. Passenger
shortcomings concept evaluation is minimal correction tristimulus difference in subjective effect is often not the best.
      This article adopts the method of combining objective evaluation and subjective evaluation. First, objective evaluation is carried out, the better result is selected, and then the actual effect of the corrected picture is observed, and finally a judgment is made. The objective evaluation
mainly uses Lab space, with RGB space as auxiliary. In Lab space, use

To measure, where avg (X) is the mean value of X, max(X) is the maximum value of X, min(X) is the minimum value of X, assuming that there are K reference color patches,
respectively, the i-th color patch corresponds to The standard value is the lab value to be corrected corresponding to the i-th color block. The calculation formula for the value used in the objective evaluation above is as follows:

Guess you like

Origin blog.csdn.net/a8039974/article/details/109132496