Embodiment
Clearer for technical problem, technical scheme and beneficial effect that the present invention is solved, below in conjunction with accompanying drawing and embodiment, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Color correction matrix in the conventional images correcting algorithm satisfies the timing of the image that low colour temperature environment is taken down, just can not satisfy the correction of the image that high colour temperature environment is taken down; Otherwise, satisfy timing to the image of taking under the high colour temperature environment, just can not satisfy the correction of the image that low colour temperature environment is taken down.Given this, the invention provides a kind of image rectification algorithm, can well proofread and correct, solved the difficult problem in the conventional images bearing calibration picture shot under all colour temperature environment.
A kind of color correcting method, as shown in Figure 1, this algorithm comprises the steps:
S1, the red color component value of obtaining a certain lighting environment hypograph, green component values, blue sub value, red gain value, blue gain value;
S2, judge whether said red gain value and said blue gain value satisfy: said red gain value more than or equal to second preset value, if satisfy, jumps to step S3 smaller or equal to first preset value and said blue gain value; If do not satisfy, jump to step S4;
S3, judgement lighting environment are first light source, and the setpoint color correction matrix is the first color correction matrix, jumps to step S5;
S4, judgement lighting environment are secondary light source, and the setpoint color correction matrix is the second color correction matrix;
S5, utilize said first color correction matrix or the said second color correction matrix that said red color component value, green component values, blue sub value are proofreaied and correct.
Color correcting method of the present invention is set the various colors correction matrix image is proofreaied and correct according to the difference of light source kind, has solved the technical problem that existing color correcting method adopts the single color correction matrix to be run into.
Red color component value among the said step S1, green component values, blue sub value are for carrying out red color component value, green component values, the blue sub value after white balance is handled, red gain value and blue gain value when said red gain value and blue gain value are handled for image being carried out white balance to view data.
Because the figure kine bias that low colour temperature environment is taken down is red, the red gain value was far away littler than blue yield value when it was carried out the white balance colour correction; The figure kine bias that high colour temperature environment is taken down is blue, and the red gain value was bigger far away than blue yield value when it was carried out the white balance colour correction; Judge that then whether said red gain value and said blue gain value satisfy: said red gain value smaller or equal to first preset value and said blue gain value more than or equal to second preset value; If satisfy, judge that then lighting environment is first light source, the setpoint color correction matrix is the first color correction matrix; If do not satisfy, judge that then lighting environment is a secondary light source, the setpoint color correction matrix is the second color correction matrix.
As preferred version, choose the F light source for judging the boundary of low color temperature light sources and high color temperature light source, the value of red gain value and blue gain value when said first preset value and second preset value are respectively adjusting image white balance under the F light source color temperature.
Said first light source comprises: candle light, F light source etc.; The candle light colour temperature is 1930K; The F light source color temperature is 2700K; Said secondary light source comprises: U30 light source (Warm White Fluorescent; The U.S.'s warm white shop light source), TL84 light source (Europe, Japan, Chinese shop light source), CWF light source (Cool White Fluorescent; The U.S.'s cold white shop light source), D65 light source (Artificial Daylight, international standard alpine light) etc.; The U30 light source color temperature is 3000K; The TL84 light source color temperature is 4000K; The CWF light source color temperature is 4150K; The D65 light source color temperature is 6500K.
Known as those skilled in the art, the boundary light source is not limited to the F light source between high color temperature light source and the low color temperature light sources, and other light source is suitable equally, for example U30 light source, CWF light source etc.
If light source is first light source, the color of image of under this kind light source, taking is warm partially, sets the first corresponding color correction matrix when it is carried out colour correction; If the light source secondary light source, the color of image of under this kind light source, clapping look is colder, sets the second color correction matrix when it is carried out colour correction.The first color correction matrix and the second color correction matrix are independent of each other, and the first color correction matrix only plays regulating action to the image that first light source is taken down, and the second color correction matrix only plays regulating action to the image that secondary light source is taken down.
The said first color correction matrix computations method is following: under first light source, take color check card image; Calculate each color lump in the said color check card image color mean value and with the color check card in the standard value of corresponding color lump do comparison; Calculate each correction coefficient in the first color correction matrix, obtain the first color correction matrix.
The said second color correction matrix computations method is following: under secondary light source, take color check card image; Calculate each color lump in the said color check card image color mean value and with the color check card in the standard value of corresponding color lump do comparison; Calculate each correction coefficient in the second color correction matrix, obtain the second color correction matrix.
When shooting environmental from low color temperature light sources when high color temperature light source changes; When image is carried out color correction; The color correction matrix can cause the phenomenon of image/video picture sudden change as directly becoming the second color correction matrix from the first color correction matrix conversion, makes picture smooth inadequately.
In like manner; When shooting environmental from high color temperature light source when low color temperature light sources changes, when image was carried out color correction, the color correction matrix was as directly becoming the first color correction matrix from the second color correction matrix conversion; Can cause the phenomenon of video image picture sudden change equally, make picture smooth inadequately.
For solving this ill effect; When shooting environmental from first light source when secondary light source is changed, the color correction matrix is followed successively by: the first color correction matrix, (N-1)/N* first color correction matrix+1/N* second color correction matrix, (N-2)/N* first color correction matrix+2/N* second color correction matrix ..., the 2/N* first color correction matrix+(the N-2)/N* second color correction matrix, the 1/N* first color correction matrix+(N-1)/N* second color correction matrix, the second color correction matrix; Said N is smaller or equal to 15 integer more than or equal to 2.Like this, video image color slowly changes, and makes image change smooth, and the user feels good.The value of N is less, and the video image color velocity variations is fast; The value of N is bigger, and the video image color velocity variations is slower, but video image color changes smoothness, and the user feels good; But the value of N also needs restriction, if too little, the situation of color change possibly occur; If too big, color just can adjust for a long time, thereby causes adjustment efficient not high.
As preferred version; As shown in Figure 2; The value of said N gets 4, and said color correction matrix is followed successively by: the first color correction matrix, 3/4* first color correction matrix+1/4* second color correction matrix, 2/4* first color correction matrix+2/4* second color correction matrix, 1/4* first color correction matrix+3/4* second color correction matrix, the second color correction matrix.
When shooting environmental from secondary light source when first light source is changed, the color correction matrix is followed successively by: the second color correction matrix, (M-1)/M * second color correction matrix+1/ M *, the first color correction matrix, (M-2)/M * second color correction matrix+2/ M *, the first color correction matrix ..., 2/ M *, the second color correction matrix+(M-2)/M * first color correction matrix, 1/ M *, the second color correction matrix+(M-1)/M * first color correction matrix, the first color correction matrix; Said M is smaller or equal to 15 integer more than or equal to 2.Like this, video image color slowly changes, and makes image change smooth, and the user feels good.The value of M is less, and the video image color velocity variations is fast; The value of M is bigger, and the video image color velocity variations is slower, but video image color changes smoothness, and the user feels good; But the value of M also needs restriction, if too little, the situation of color change possibly occur; If too big, color just can adjust for a long time, thereby causes adjustment efficient not high.
As preferred version; As shown in Figure 3; The value of said M gets 4, and the color correction matrix is followed successively by: the second color correction matrix, 3/4* second color correction matrix+1/4* first color correction matrix, 2/4* second color correction matrix+2/4* first color correction matrix, 1/4* second color correction matrix+3/4* second color correction matrix, the first color correction matrix.
When light source color temperature changed, the change frequency of color correction matrix also had corresponding restriction, and each two field picture, two two field pictures or multiple image conversion are once.Each two field picture changes once, and change color is than very fast, and multiple image changes once, and change color is relatively more smooth.As preferred version, when the video image frame per second was 15 FPS (Frames per Second, per second shows frame number), the color correction matrix was selected per 2 frame transforms once.When the frame per second of video changes, smooth for making the video image conversion, the speed that needs adjustment color correction matrix to change.
Color correcting method of the present invention is set the various colors correction matrix image is proofreaied and correct according to the difference of light source kind, has solved the technical problem that existing color correcting method adopts the single color correction matrix to be run into.In any colour temperature photoenvironment picture shot, after employing this method is carried out colour correction to it, can both reach good visual effect.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.