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, refer to especially a kind of method of image sequence color space conversion.
Background technology
2005, digital camera propulsive mechanism (the DCI that is formed by several large 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 relatively backward, the post-production company quantity that can carry out at home at present the making of digital movie coding is few, and the digital film that most of company makes not yet reaches the requirement that must be Motion JPEG200 standard to digital film distributor bag in the DCI standard.This mainly is because existing digital movie encoding device in the market, when the film film source (or being called digital movie distribution master (DCDM)) that meets the DCI code requirement being encoded processing, 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 encoded processing, projector is to the requirement of film color space in order to reach digital film projector the time, need to carry out to the image sequence in the digital film distributor mother matrix processing of color space conversion, soon (RGB is namely red by RGB for the color of image sequence, green, primary colors, each pixel is comprised 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 turns in the XYZ standardising process, the consumption of computing process time is quite large when carrying out gamma correction, causes the conversion process elapsed time of color space quite large, thereby so that the digital movie coding when processing efficient extremely slow.
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 coding processing speed.
The method of image sequence color space conversion provided by the invention comprises: extract successively each image 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 extracts;
R, the G of b, the R that judges described current pixel, G, B value and a upper pixel, the difference of B value whether in setting range, if, then with X ', the Y ' of a upper 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;
Wherein, the pixel of whole image different piece adopt many treatment facilities process respectively and/or whole image sequence in different section sequences adopt multiple devices to process respectively.
Optionally, the described setting range of step b is zero.
Better, the described setting range capable of regulating of step b.
Optionally, step b takes a step forward and comprises: determine that human eye is to the height of current pixel institute corresponding color susceptibility; Described setting range capable of regulating comprises: according to the height of susceptibility, reduce or increase described setting range.
Optionally, step b takes a step forward and comprises: determine that human eye is to the size of current pixel attention rate; Described setting range capable of regulating comprises: 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.
As seen from the above, the difference of the method that provides of the present invention by judging current pixel value and a upper pixel value is in setting range the time, directly get X ', Y ', the Z ' value of a pixel as X ', Y ', the Z ' value of this pixel, omit the processing procedure of complicated gamma correction computing, Effective Raise to the processing speed of image sequence, shortened the digital movie coding processing time.
Wherein, the described setting range of step b can be zero, namely 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 is capable of regulating also, increase or reduce with the needs according to the user, so that use comparatively flexible, for example be applied to the higher situation of definition (such 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 slightly low situation of definition, such as MP4, so the definition of the lower requirement of resolution is relatively low), then the setting range debugging is for larger, and the processing speed of corresponding image sequence is also very fast.
Better; can just reduce or increase described setting range to the susceptibility of the represented color of current pixel according to human eye; thereby realize the dynamic adjustment to the processing speed of image sequence; can realize that the high color color of corresponding susceptibility keeps dividing details, divides relatively thick for the color particle that susceptibility is low.To realize being that the guarantor observes the effect of seeing, can realize processing faster again the processing speed of image sequence.
Better; can reduce or increase described setting range to the attention rate of current described pixel size according to human eye; thereby realize the dynamic adjustment to the processing speed of image sequence; can realize that the high pixel of corresponding attention rate keeps dividing details, divides relatively thick for the pixel particle that attention rate is low.To realize being that the guarantor observes the effect of seeing, can realize processing faster again the processing speed of image sequence.
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, and then the eyes attention rate is maximum, and pixel is the closer to image limit or angle, and the eyes attention rate is less.To reduce the impact that the user is watched.
In addition, can change correction according to lookup table mode, can further shorten the processing time of image sequence.
And, can use simultaneously many treatment facilities to process respectively the pixel of whole image different piece, perhaps the different section sequences in the whole image sequence are processed respectively, thereby reached the purpose of parallel processing, the treatment cycle of whole like this image sequence will shorten more.
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 successively each image file, for 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.
Namely from image sequence, choose an image file, then from this image file, read R, G, the B value of each pixel, 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 upper 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 upper pixel are assigned to X ', Y ', the Z ' value of 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 the 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 upper pixel, the X ', the Y ' that directly get a upper pixel when B value is identical, Z ' value X ', Y ', the Z ' value as this pixel, omit the processing procedure of step 103~107, Effective Raise to the processing speed of image sequence.
Step 104: described R, G, B value are advanced conversion proofread and correct processing, generate three values R ', G ', B ' after proofreading and correct.
Wherein, it is as follows that the conversion formula that is adopted is proofreaied and correct in conversion:
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 to carry out rounding operation.
Be understood that, also can calculate in advance the corrected value of each value according to following formula (1), and exist in the data group in the buffer memory, as RGB conversation correction table, this step is finished conversion by the mode of tabling look-up and is proofreaied and correct processing, namely search the RGB conversation correction for the R that extracts, G, B respectively, from this RGB conversation correction, search respectively three value R ', G ', B ' after each self-corresponding conversion of current R, G, B is proofreaied and correct.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 to for step 105 respectively, Y, Z change correction, generate three values X ', Y ', Z ' after proofreading and correct.
It is as follows wherein to change the conversion formula that correction calculation adopts:
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 to round.
Be understood that, also can calculate in advance the corrected value of each value according to following formula (3), and exist in the data group in the buffer memory, as the XYZ conversation correction, this step is finished conversion by the mode of tabling look-up and is proofreaied and correct processing, namely search the XYZ conversation correction for the X that extracts, Y, Z respectively, from this XYZ conversation correction, search respectively three value X ', Y ', Z ' after each self-corresponding conversion of current X, Y, Z is proofreaied and correct.Can save like this time that conversion is proofreaied and correct.
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 the processing procedure to a pixel.Then further judge whether to have processed last pixel, if, then finish, otherwise return step 101, carry out the processing of next pixel.
In the manner described above, process successively each pixel of an image, continue afterwards to process the next image file in the image sequence, until whole image sequence all is disposed.
Through experiment, the modular converter that adopts said method two to make is integrated in the digital movie encoding device, and the efficient that the digital movie encoding device is processed image improves more than 10~20 times.
In addition, for above-mentioned steps 102, when to color less demanding, the difference of judging current pixel value and a upper pixel value is in setting range when (being that change color is very not obvious), same execution in step 103, also can not affecting under the effect that the people watches, further improve processing speed.
Setting range for the difference of above-mentioned pixel value, further, because human eye is different to the susceptibility of different colours, can also set up different weights according to different susceptibilitys, pixel value weights corresponding to the color that susceptibility is large are little, and pixel value weights corresponding to the color that sensitivity is little are large, adjust the setting range of above-mentioned margin of image element by weights, for example can exist in the mode of addend, go and the addition of described setting range value.Thereby realize that current pixel is human eye sensitive colors zone so that with the setting range of the difference of a upper pixel value in little; And current pixel is when being the non-sensitive color region of human eye, then with the setting range of the difference of a upper pixel value in large.Can realize like this going dynamically to judge whether execution in step 103, can realize having improved again processing speed 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 processed, also can set up according to pixel the size of weights 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, then the eyes attention rate is maximum, and weights are less, and pixel is the closer to image limit or angle, the eyes attention rate is less, and weights are larger.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 so that with the setting range of the difference of a upper pixel value in 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 upper pixel value in large.Can realize like this going dynamically to judge whether execution in step 103, can realize again having improved processing speed under the effect that the people watches.Wherein weights can be negative, and the definite of its size can obtain by experiment.
Although the mode that above-mentioned weights have been sued for peace is 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 combined with.
In addition, for method provided by the invention, can use simultaneously many treatment facilities to process respectively the pixel of whole image different piece, or/and the different section sequences in the whole image sequence are processed respectively, thereby reach the purpose of parallel processing, the treatment cycle of whole like this image sequence will shorten more.
The above is preferred embodiment of the present invention only, is not for limiting protection scope of the present invention, all any modifications of doing 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.