The method of image sequence color space conversion
Technical field
The present invention relates to the image processing method technical field in the digital movie, be meant a kind of method of image sequence color space conversion especially.
Background technology
2005, digital camera propulsive mechanism (the DCI that forms by several big studios such as Disney, Fox, Paramount, Warner Brothers, Digital Cinema Initiatives) announced a technical standard (being called for short the DCI standard) that is called " digital movie system technical specification (V1.0) ", standard the relevant technologies requirement of digital movie, make the link such as making, projection of digital movie that unified international standard arranged.The video image format of DCI standard has been specified 4K resolution, adopts 12 tonal gradations of XYZ color space, and uses Motion JPEG200 standard to carry out video compression, and its message transmission rate reaches 250Mbps.
Abroad compare, the digital movie manufacturing development of China is backward relatively, the post-production company quantity that can carry out at present the making of digital movie coding at home is few, and the digital film that most of company makes does not reach the requirement that must be Motion JPEG200 standard to digital film distributor bag in the DCI standard as yet.This mainly is because existing digital encoder film equipment in the market, to the film film source (or being called digital movie distribution master (DCDM)) that meets the DCI code requirement when carrying out encoding process, efficient is extremely slow, often can't satisfy the requirement in Moviemaking cycle, so post-production company can only have to take the second best and selects the MPEG2 standard to make the digital movie distribution package.
Its reason is specially: the video image that meets in the film film source of DCI code requirement partly is one group of well-regulated image sequence, when this group image sequence is carried out encoding process, projector is to the requirement of film color space in order to reach digital film projector the time, need carry out the processing of color space conversion to the image sequence in the digital film distributor mother matrix, soon (RGB is promptly red by RGB for the color of image sequence, green, primary colors, each pixel is made up of these three values) (XYZ mates the tristimulus values of equal-energy spectrum to be converted to XYZ, " the CIE1931 standard colorimetric observer " who sets up referring to the CIE of Commission Internationale De L'Eclairage) standard, and then compress according to the standard of Motion JPEG200.And when image sequence carried out the conversion process of color space, be that RGB changes in the XYZ standardising process, the consumption of computing process time is quite big when carrying out gamma correction, causes the conversion process elapsed time of color space quite big, thereby efficient is extremely slow when making the digital movie encoding process.
Summary of the invention
In view of this, main purpose of the present invention has been to provide the method for a kind of image sequence color space conversion, to shorten image sequence color space change-over time, accelerates digital movie encoding process speed.
The method of image sequence color space conversion provided by the invention comprises: extract each image successively from image sequence, extract each pixel of each image again and carry out following step:
R, G, the B value of a, definite current pixel that is extracted;
R, the G of b, the R that judges described current pixel, G, B value and a last pixel, the difference of B value whether in setting range, if, then with X ', the Y ' of a last pixel, R, G, the B value that Z ' value is replaced current pixel; Otherwise carry out next step;
C, the R with described current pixel, G, the conversion of B value are proofreaied and correct and are R ', G ', B ' value; Again R ', G ', B ' value are carried out color space and be converted to X, Y, Z value; Again X, Y, the conversion of Z value are proofreaied and correct and be X ', Y ', Z '; R, G, B value with X ', Y ', Z ' replacement current pixel.
Optionally, the described setting range of step b is zero.
Preferable, the described setting range of step b can be adjusted.
Optionally, step b takes a step forward and comprises: determine the height of human eye to current pixel institute corresponding color susceptibility; Described setting range can be adjusted and comprise: according to the height of susceptibility, reduce or increase described setting range.
Optionally, step b takes a step forward and comprises: determine the size of human eye to the current pixel attention rate; Described setting range can be adjusted and comprise: according to the attention rate size, reduce or increase described setting range.
Wherein, described definite human eye is to determine according to the near long-range degree of described pixel distance picture centre position to the attention rate size of current pixel.
Optionally, step c proofreaies and correct described current pixel R, G, the conversion of B value and is R ', G ', B ' value, and/or X, Y, Z value conversion correction are changed correction for X ', Y ', Z ' according to lookup table mode.
Optionally, step c is to adopt following conversion formula with described current pixel R, G, B value conversion correction for R ', G ', B ' value:
Described R ', G ', B ' value are carried out color space, and to be converted to X, Y, Z value be to adopt following formula:
It is that X ', Y ', Z ' value are to adopt following formula that X, Y, the conversion of Z value are proofreaied and correct:
Wherein, L represents highest brightness value, and M and N are empirical value, and a, b, c, d, e, f, g, h and i are correction factor.
Preferable, further comprise: the pixel of the different piece that comprises of each image of parallel processing respectively.
Preferable, further comprise: the sequence of different sections in each image sequence of difference parallel processing.
As seen from the above, the difference of the method that provides of the present invention by judging a current pixel value and a last pixel value is in setting range the time, directly get X ', Y ', the Z ' value of a pixel X ', Y ', Z ' value as this pixel, omit the processing procedure of complicated gamma correction computing, effectively improved processing speed, shortened the digital movie encoding process time image sequence.
Wherein, the described setting range of step b can be zero, promptly only R, the G of current pixel, B value with on R, G, the X ', the Y ' that just directly get a pixel when B value is identical, the Z ' value of a pixel as X ', Y ', the Z ' value of this pixel, guaranteed that effectively color-values 0-255 all has the value after corresponding conversion is proofreaied and correct, and the problem that the image sequence color is lost, image file damages therefore can not occur.
In addition, the described setting range of step b also can be adjusted, increase or reduce with needs according to the user, so that use comparatively flexible, for example be applied to the definition condition with higher (as the large-screen HDTV (High-Definition Television), the definition height of resolution high requirement) then setting range is adjusted into less, (as be applied to the small screen display device if be applied to the low slightly situation of definition, as MP4, resolution is low so the definition that requires is relatively low), then the setting range debugging is for bigger, and the processing speed of corresponding image sequence is also very fast.
Preferable; can just reduce or increase described setting range to the susceptibility of the represented color of current pixel according to human eye; thereby realize dynamic adjustment to the processing speed of image sequence; can realize that the high color color of corresponding susceptibility keeps dividing details, divides thicker relatively for the color particle that susceptibility is low.To realize is that the guarantor observes the effect of seeing, can realize handling faster the processing speed of image sequence again.
Preferable; can reduce or increase described setting range to the attention rate of current described pixel size according to human eye; thereby realize dynamic adjustment to the processing speed of image sequence; can realize that the high pixel of corresponding attention rate keeps dividing details, divides thicker relatively for the pixel particle that attention rate is low.To realize is that the guarantor observes the effect of seeing, can realize handling faster the processing speed of image sequence again.
Wherein, can determine human eye to the current attention rate size of extracting pixel according to the near long-range degree of described pixel distance picture centre position, pixel is positioned at picture centre, eyes attention rate maximum then, and pixel is the closer to image limit or angle, and the eyes attention rate is more little.To reduce the influence that the user is watched.
In addition, can change correction, can further shorten the processing time of image sequence according to lookup table mode.
And, can use many treatment facilities to handle the pixel of entire image different piece respectively simultaneously, perhaps the different section sequences in the entire image sequence are handled respectively, thereby reached the purpose of parallel processing, the processing cycle of entire image sequence will shorten more like this.
Description of drawings
Fig. 1 is image sequence color space flow path switch figure of the present invention.
Embodiment
When the image sequence in the digital film distributor mother matrix being carried out the processing of color space conversion, from image sequence, extract each image file successively, at each image file, referring to image sequence color space flow path switch of the present invention shown in Figure 1, successively each pixel of this image file of extracting is carried out following step:
Step 101: determine three values of R, G, B of current institute capture element, the row cache of going forward side by side.
Promptly from image sequence, choose an image file, from this image file, read R, G, the B value of each pixel then, and these three values are kept in three variate-values.
Step 102: whether R, G, the B value of R, G, B value and a last pixel of judging described current pixel be identical, if then execution in step 103, otherwise execution in step 104.
Step 103: three value X ', Y ', Z ' of a last pixel are composed X ', Y ', the Z ' value of giving this pixel, and preserve back in this pixel of image file, cover former R, G, the B value of this pixel; And jump to step 108.
Because image pixel value can be just the same in certain scope in same sub-picture, such as: have in the image of scenes such as blue sky and white cloud, night, large-area image pixel value is duplicate, so when R, the G of the R that judges certain pixel, G, B value and a last pixel, the X ', the Y ' that directly get a last pixel when B value is identical, Z ' value X ', Y ', Z ' value as this pixel, omit the processing procedure of step 103~107, effectively improved processing speed image sequence.
Step 104: described R, G, B value are advanced the conversion treatment for correcting, generate three values R ', G ', B ' after proofreading and correct.
Wherein, conversion proofread and correct the conversion formula that adopted as follows:
In the following formula (1), L represents highest brightness value, and M, N are empirical value, can be self-defined according to user's request, and the INT operator representation returns fractional part need carry out rounding operation.
Be understood that, also can calculate the corrected value of each value in advance according to following formula (1), and exist in the data set in the buffer memory, as RGB conversation correction table, this step is finished the conversion treatment for correcting by the mode of tabling look-up, promptly search the RGB conversation correction at the R that is extracted, G, B respectively, from this RGB conversation correction, search three value R ', G ', B ' after each self-corresponding conversion of current R, G, B is proofreaied and correct respectively.Can save the time that each pixel is changed correction like this.
Step 105: three value R ', G ', the B ' that is obtained by step 104 carried out the color space conversion, obtain X, Y, three values of Z.Wherein, conversion formula is as follows:
In the following formula (2), a, b, c, d, e, f, g, h, i are correction factor, and span can be self-defined according to user's request between 0 to 1.
Step 106, the X that is converted at step 105 respectively, Y, Z change correction, generate three values X ', Y ', Z ' after proofreading and correct.
The conversion formula of wherein changing correction calculation and being adopted is as follows:
In the following formula (3), L represents highest brightness value, and M, N are empirical value, can be self-defined according to user's request, and the INT operator representation returns fractional part and need round.
Be understood that, also can calculate the corrected value of each value in advance according to following formula (3), and exist in the data set in the buffer memory, as the XYZ conversation correction, this step is finished the conversion treatment for correcting by the mode of tabling look-up, promptly search the XYZ conversation correction at the X that is extracted, Y, Z respectively, from this XYZ conversation correction, search three value X ', Y ', Z ' after each self-corresponding conversion of current X, Y, Z is proofreaied and correct respectively.Can save the time that conversion is proofreaied and correct like this.
Step 107: three value X ', Y ', Z ' that step 106 is calculated preserve back in the raw image files, cover R, G, the B value of former pixel.
Step 108: so far, finished processing procedure to a pixel.Then further judge whether to have handled a last pixel, if, then finish, otherwise return step 101, carry out the processing of next pixel.
In the manner described above, handle each pixel of an image successively, continue to handle the next image file in the image sequence afterwards, all dispose up to the entire image sequence.
Through experiment, the modular converter that adopts said method two to make is integrated in the digital movie encoding device, can make the digital movie encoding device improve more than 10~20 times to the efficient of image processing.
In addition, for above-mentioned steps 102, when the time to color less demanding, the difference of judging a current pixel value and a last pixel value is in setting range when (being that change color is very not obvious), same execution in step 103 also can further improve processing speed not influencing under the effect that the people watches.
Setting range for the difference of above-mentioned pixel value, further, because human eye is to the susceptibility difference of different colours, can also set up different weights according to different susceptibilitys, the color corresponding pixel value weights that susceptibility is big are little, and the color corresponding pixel value weights that sensitivity is little are big, adjust the setting range of above-mentioned margin of image element by weights, for example can exist, go and the addition of described setting range value in the mode of addend.Thereby realize that current pixel is human eye sensitive colors zone, make in the setting range with the difference of a last pixel value little; And during current pixel to be human eye non-sensitive color region, then with the setting range of the difference of a last pixel value in big.Can realize like this going to judge whether execution in step 103 dynamically, can realize having improved processing speed again under the effect that the people watches.Wherein weights can be negative, and the definite of its size can obtain by experiment.
Setting range for the difference of above-mentioned pixel value, further, owing to the reason of eye to the different attention rates of diverse location in the visual field, when pixel is handled, also can set up the size of weights according to pixel to the distance of the position of picture centre (being assumed to be the highest position of eye attention rate), the size of described weights is relevant with described location of pixels, and location of pixels is relevant with eyes attention rate size, be that pixel is positioned at picture centre, eyes attention rate maximum then, weights are less, and pixel is the closer to image limit or angle, the eyes attention rate is more little, and weights are big more.Can exist in the mode of addend equally, go and the addition of described setting range value.Thereby when realizing that current pixel is in human eye attention rate high position, make in the setting range with the difference of a last pixel value little; And current pixel is when being in for human eye attention rate lower position, then with the setting range of the difference of a last pixel value in big.Can realize like this going to judge whether execution in step 103 dynamically, can realize having improved processing speed once more under the effect that the people watches.Wherein weights can be negative, and the definite of its size can obtain by experiment.
Though the mode that above-mentioned weights have been sued for peace is an example, be understood that, also can be difference or proportionality coefficient etc.
Two kinds of methods that are understood that the dynamic adjustment in the setting range of above-mentioned difference to pixel value can be used separately, also can be used in combination.
In addition, for method provided by the invention, can use many treatment facilities to handle the pixel of entire image different piece respectively simultaneously, or/and the different section sequences in the entire image sequence are handled respectively, thereby reach the purpose of parallel processing, the processing cycle of entire image sequence will shorten more like this.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.