Background technology
Image restoration is a pith of image procossing, and its main purpose improves picture quality.When a given width degenerate or be subject to noise pollution image time, utilize certain priori of degradation phenomena to rebuild new image or to recover the main process that original image is image restoration process.
In the prior art, due to CMOS(Complementary Metal Oxide Semiconductor, complementary metal oxide semiconductors (CMOS)) impact of colored filter characteristic in sensing device, often pure not with the image color of CMOS sensing device shooting, namely from cmos sensor, color of image out has colour cast, need certain method to correct, make image manifest pure color.
Usual bearing calibration is as follows, take the picture of color verification sheet (color checker)-Standard colour board, calculate the color mean value of each color lump in captured image and compare to the standard value of corresponding color lump in color check card, estimate direction and scope that in color correction matrix (color matrix), each correction coefficient (color coefficient) should regulate, until reach the object of colour correction.Color correction formula is as follows:
In formula: R, G, B are respectively the standard value of red color component value in Standard colour board, green component values, blue color component value, r, g, b are respectively image that camera is filmed corresponding red color component value, green component values, blue color component value value.Color matrix is color matrix.The good realization of known color matrix (color matrix) is the key in color correction.
F light (colour temperature 2700K) red component is more, and under F light during pictures taken, captured picture is after the white balance process in image processing apparatus, although background has been adjusted to white, and body color is thin out, and particularly yellow body color tune is very light; And main body can retain good color finish white balance under the light source that other colour temperature is higher after.To these two kinds of scenes, if use same group of color correction matrix, when meeting the adjustment of body color under F light, under other light, body color just has colour cast; When meeting the adjustment of body color under other light, under F light, body color just has colour cast.Existing color correction algorithm is difficult to adapt to photoenvironment complicated and changeable as can be seen here.
Embodiment
In order to make technical problem solved by the invention, technical scheme and beneficial effect clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
Color correction matrix in conventional images correcting algorithm meets the timing to the image taken under low colour temperature environment, just can not meet the correction to the image taken under high color temperature environment; Otherwise, meet the timing to the image taken under high color temperature environment, just can not meet the correction to the image taken under low colour temperature environment.Given this, the invention provides a kind of image rectification algorithm, the picture taken well can be corrected, solve the difficult problem in conventional images bearing calibration 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 obtaining a certain lighting environment hypograph, green component values, blue color component value, red gain value, blue gain value;
S2, judge whether described red gain value and described blue gain value meet: described red gain value is less than or equal to the first preset value and described blue gain value is more than or equal to the second preset value, if met, jump to step S3; If do not met, jump to step S4;
S3, judge that lighting environment is as the first light source, setpoint color correction matrix is the first color correction matrix, jumps to step S5;
S4, judge that lighting environment is as secondary light source, setpoint color correction matrix is the second color correction matrix;
S5, described first color correction matrix or described second color correction matrix is utilized to correct described red color component value, green component values, blue color component value.
Color correcting method of the present invention, according to the difference of light source kind, sets different color correction matrix to correct image, solves the technical problem that existing color correcting method adopts single color correction matrix to run into.
Red color component value in described step S1, green component values, blue color component value are carry out red color component value, green component values, blue color component value after white balance process to view data, and described red gain value and blue gain value are red gain value when carrying out white balance process to image and blue gain value.
Because the image taken under low colour temperature environment is partially red, when carrying out white balance colour correction to it, red gain value is less far away than blue yield value; The image taken under high color temperature environment is partially blue, and when carrying out white balance colour correction to it, red gain value is larger far away than blue yield value; Then judge whether described red gain value and described blue gain value meet: described red gain value is less than or equal to the first preset value and described blue gain value is more than or equal to the second preset value; If met, then judge that lighting environment is as the first light source, setpoint color correction matrix is the first color correction matrix; If do not met, then judge that lighting environment is as secondary light source, setpoint color correction matrix is the second color correction matrix.
Preferably, choosing F light source is the boundary judging low color temperature light sources and high color temperature light source, the value of red gain value and blue gain value when regulating image white balance under described first preset value and the second preset value are respectively F light source color temperature.
Described first light source comprises: candle light, F light source etc.; Candle light colour temperature is 1930K; F light source color temperature is 2700K; Described secondary light source comprises: U30 light source (Warm White Fluorescent, the U.S. warms up 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.; U30 light source color temperature is 3000K; TL84 light source color temperature is 4000K; CWF light source color temperature is 4150K; D65 light source color temperature is 6500K.
Known as those skilled in the art, light source of demarcating between high color temperature light source and low color temperature light sources is not limited to F light source, and other light source is applicable equally, such as U30 light source, CWF light source etc.
If light source is the first light source, the color of image taken under this kind of light source is partially warm, sets the first corresponding color correction matrix when carrying out colour correction to it; If light source secondary light source, the color of image clapping look under this kind of light source is colder, sets the second color correction matrix when carrying out colour correction to it.First color correction matrix and the second color correction matrix are independent of each other, and the first color correction matrix only plays regulatory role the image taken under the first light source, and the second color correction matrix only plays regulatory role the image taken under secondary light source.
Described first color correction matrix computational methods are as follows: under the first light source, take color check card image, calculate the color mean value of each color lump in described color check card image and compare to the standard value of corresponding color lump in color check card, calculate each correction coefficient in the first color correction matrix, obtain the first color correction matrix.
Described second color correction matrix computational methods are as follows: under secondary light source, take color check card image, calculate the color mean value of each color lump in described color check card image and compare to the standard value of corresponding color lump in color check card, calculate each correction coefficient in the second color correction matrix, obtain the second color correction matrix.
When shooting environmental changes from low color temperature light sources to high color temperature light source, when color correction is carried out to image, color correction matrix, as directly converted the second color correction matrix to from the first color correction matrix, the phenomenon that image/video picture can be caused to suddenly change, makes picture smooth not.
In like manner, when shooting environmental changes from high color temperature light source to low color temperature light sources, when carrying out color correction to image, color correction matrix is as directly converted the first color correction matrix to from the second color correction matrix, the phenomenon that video image picture can be caused equally to suddenly change, makes picture smooth not.
For solving this ill effect, when shooting environmental is changed from the first light source to secondary light source, 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 ..., 2/N* first color correction matrix+(N-2)/N* second color correction matrix, 1/N* first color correction matrix+(N-1)/N* second color correction matrix, the second color correction matrix; Described N is more than or equal to the integer that 2 are less than or equal to 15.Like this, video image color slowly changes, and make image change smooth, user feels good.The value of N is less, and video image color velocity variations is fast; The value of N is comparatively large, and video image color velocity variations is comparatively slow, but video image color change is smooth, and user feels good; But the value of N also needs restriction, if too little, may occur the situation of color change; If too large, need color for a long time just can adjust, thus cause regulated efficiency not high.
Preferably, as shown in Figure 2, the value of described N gets 4, and described color correction matrix is followed successively by: the first color correction matrix, the 3/4* the first color correction matrix+1/4* second color correction matrix, the 2/4* the first color correction matrix+2/4* second color correction matrix, the 1/4* the first color correction matrix+3/4* second color correction matrix, the second color correction matrix.
When shooting environmental from secondary light source to first light source conversion time, color correction matrix is followed successively by: the second color correction matrix, (M-1)/M * second color correction matrix+1/ M * first color correction matrix, (M-2)/M * second color correction matrix+2/ M * first color correction matrix ..., 2/ M * second color correction matrix+(M-2)/M * first color correction matrix, 1/ M * second color correction matrix+(M-1)/M * first color correction matrix, the first color correction matrix; Described M is more than or equal to the integer that 2 are less than or equal to 15.Like this, video image color slowly changes, and make image change smooth, user feels good.The value of M is less, and video image color velocity variations is fast; The value of M is comparatively large, and video image color velocity variations is comparatively slow, but video image color change is smooth, and user feels good; But the value of M also needs restriction, if too little, may occur the situation of color change; If too large, need color for a long time just can adjust, thus cause regulated efficiency not high.
Preferably, as shown in Figure 3, the value of described M gets 4, and color correction matrix is followed successively by: the second color correction matrix, the 3/4* the second color correction matrix+1/4* first color correction matrix, the 2/4* the second color correction matrix+2/4* first color correction matrix, the 1/4* the second color correction matrix+3/4* second color correction matrix, the first color correction matrix.
During light source color temperature change, the change frequency of color correction matrix also has corresponding restriction, and the conversion of each two field picture, two two field pictures or multiple image once.Once, color change is than very fast, and once, color change is more smooth in multiple image change for the change of each two field picture.Preferably, when video image frame per second is 15 FPS(Frames per Second, display frame number per second) time, color correction matrix selects every 2 frame transforms once.When the frame per second change of video, smooth for making video image convert, need the speed adjusting color correction matrix change.
Color correcting method of the present invention, according to the difference of light source kind, sets different color correction matrix to correct image, solves the technical problem that existing color correcting method adopts single color correction matrix to run into.At the picture of any colour temperature photoenvironment shooting, after adopting this method to carry out colour correction to it, good visual effect can be reached.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.