Summary of the invention
The embodiment of the invention provides a kind of method and apparatus of regulating image attributes, and is excessive to avoid when regulating the image attributes of YUV image amount of calculation, the problem that consumes resources is many.
The embodiment of the invention provides a kind of method of regulating image attributes, comprising:
Obtain the image attributes parameter of YUV image;
Described image attributes parameter is regulated the image attributes after obtaining to regulate according to predetermined strategy.
Wherein, described image attributes parameter comprises following one of them or combination in any:
Brightness, contrast, saturation and colourity.
Wherein, when the image attributes parameter is brightness, the Y component in the YUV image is regulated; Then the step that described image attributes parameter is regulated according to predetermined strategy comprises:
When brightness Y when the direction that increases is regulated,
Y′=Y+B
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and B is the value of brightness regulation;
When brightness Y when the direction that reduces is regulated,
Y′=min(Y,Y″)
Wherein, Y is the brightness value before image is adjusted, and Y is the adjusted brightness value of brightness, Y " is the maximum after the brightness regulation.
Wherein, when the image attributes parameter is contrast, the Y component in the YUV image is regulated; Then the step that described image attributes parameter is regulated according to predetermined strategy comprises:
When contrast when the direction that increases is regulated,
Y′=Y*C
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and C is the contrast adjustment value;
When contrast when the direction that reduces is regulated,
Y′=A+(Y-A)*C
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and C is the contrast adjustment value, and A is a radix value.
Wherein, when the image attributes parameter is saturation, U in the YUV image and V component are regulated; Then the step that described image attributes parameter is regulated according to predetermined strategy comprises:
U′=((U-128)*S)+128
V′=((V-128)*S)+128
Wherein, U is the blue difference signal value before image is adjusted, and U ' is adjusted blue difference signal value, and V is the red color difference signal value before image is adjusted, and V ' is adjusted red color difference signal value, and S is the saturation regulated value.
Wherein, when the image attributes parameter is colourity, U in the YUV image and V component are regulated; Then the step that described image attributes parameter is transferred according to predetermined strategy comprises:
U′=(U-128)*cosθ+(V-128)*sinθ+128
V′=(V-128)*cosθ-(U-128)*sinθ+128
Wherein, U is the blue difference signal value before image is adjusted, and U ' is adjusted blue difference signal value, and V is the red color difference signal value before image is adjusted, and V ' is adjusted red color difference signal value, and θ is the colourity regulated quantity.
Wherein, described method further comprises: practical adjustments amount and slide block regulated quantity are the non-linear increasing relation, and the variation of B value increases with the regulated quantity of brightness, reduces thereupon reducing.
Wherein, brightness regulation to image is carried out self adaptation to the mean picture brightness before regulating, if the integral body of image before regulating is brighter, then the odds ratio of practical adjustments amount and slide block regulated quantity is bigger, if image overall brightness before regulating is less, then the ratio of practical adjustments amount and slide block regulated quantity is also smaller.
Wherein, described method further comprises:
The regulated quantity of described saturation is carried out adaptive change to image brightness, and the practical adjustments amount of saturation reduces along with the increase of brightness, increases along with the increase of contrast, reduces when the brightness and contrast reduces simultaneously thereupon.
The embodiment of the invention also provides a kind of device of regulating image attributes, comprising:
Parameter acquisition module is used to obtain the image attributes parameter of YUV image;
Adjustment module is used for described image attributes parameter is regulated according to predetermined strategy, the image attributes after obtaining to regulate.
Wherein, described image attributes parameter comprises following one of them or combination in any:
Brightness, contrast, saturation and colourity.
Wherein, further comprise:
The brightness adaptation module, when being used for the brightness regulation to image, if the integral body of image is brighter, then regulated quantity is bigger, if integral image brightness is less, then regulated quantity is also less.
Wherein, further comprise:
The comprehensive adjustment module, the regulated quantity that is used to control described saturation reduces along with the increase of brightness, increases along with the increase of contrast, and when reducing simultaneously along with the brightness and contrast and reduce.
Use the adjusting image attributes method and apparatus that the embodiment of the invention provides, saved twice module converts of YUV~RGB and RGB~HSV, avoid when regulating the image attributes of YUV image amount of calculation excessive, the problem that consumes resources is many, because can directly carry out attribute at the YUV view data regulates, accent makes resource that adjustment process takies seldom, has improved the efficient of regulating greatly.
Have, the embodiment of the present application has increased the method for the brightness of image self being carried out dynamic adjustments again, has improved the video effect of image adjustment, and through test comparison, regulating effect of the present invention is better than through carrying out the control method of color attribute after the color model conversion.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Referring to Fig. 1, it is a kind of flow chart of regulating the image attributes method according to the embodiment of the invention.Specifically comprise:
Step 101 is obtained the image attributes parameter of YUV image;
Concrete, the image attributes parameter comprises following one of them or combination in any: brightness, contrast, saturation and colourity;
Step 102 is regulated according to predetermined strategy described image attributes parameter, the image attributes after obtaining to regulate.
Use the adjusting image attributes method that the embodiment of the invention provides, saved twice module converts of YUV~RGB and RGB~HSV, avoid when regulating the image attributes of YUV image amount of calculation excessive, the problem that consumes resources is many, because can directly carry out attribute at the YUV view data regulates, accent makes resource that adjustment process takies seldom, has improved the efficient of regulating greatly.
Have, the embodiment of the present application has increased the method for the brightness of image self being carried out dynamic adjustments again, has improved the video effect of image adjustment, and through test comparison, regulating effect of the present invention is better than through carrying out the control method of color attribute after the color model conversion.
The mode that a kind of possible image attributes to the YUV image is regulated can adopt the regulative mode of slide block, as shown in Figure 2, can design a slider bar respectively at brightness, contrast, saturation and colourity, when slide block is in the centre position of slider bar, show and regulate, when slide block is moved to the left, show that this component is to the direction adjusting that reduces, when slide block is wanted to move right, show that this component is to the direction adjusting that increases.Among Fig. 2, regulated quantity is divided into 100 grades, the centre position is 50, and this position shows to be regulated this moment.Regulating maximum magnitude left is 0, and regulating maximum magnitude to the right is 100, about the adjusting grade all be 50.Reset button is used for after brightness, contrast, saturation and colourity are regulated four sliding shoes being returned to the centre position.
Respectively brightness regulation, contrast adjustment, saturation adjusting and colourity are regulated below and be elaborated.
Actual to the adjusting of brightness is that the Y component in the YUV image is regulated.At this moment, the step of in the step 102 described image attributes parameter being regulated according to predetermined strategy comprises:
When brightness Y when the direction that increases is regulated,
Y′=Y+B (1)
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and B is the value of brightness regulation;
When brightness Y when the direction that reduces is regulated,
Y′=min(Y,Y″) (2)
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, Y " is the maximum after the brightness regulation.
For the situation that brightness Y regulates to the direction that reduces, the tonal range of default image is 0~255 before regulating, and regulating the back tonal range is 0~Y ", the value B=|255-Y of brightness regulation ".
When brightness was regulated to the direction that increases, the variation of B value increased with the regulated quantity of brightness, reducing and reduce with regulated quantity.When brightness was regulated to the direction that reduces, the variation of B value increased with the regulated quantity of brightness, reducing and reduce with regulated quantity.The relation of regulated quantity and B value is non-linear monotonically increasing.The B value is relevant with the attribute of image own in addition, be designed in the embodiment of the present application the mean flow rate of image is carried out self adaptation, earlier the mean picture brightness before regulating is carried out self adaptation during also promptly to the brightness regulation of image, if the integral body brighter (just mean flow rate bigger) of image before regulating, then practical adjustments amount and slide block regulated quantity is bigger frequently, if image overall brightness before regulating is less, then the ratio of practical adjustments amount and slide block regulated quantity is also smaller.Just the brightness regulation curve carries out self adaptation to the original brightness value of image.
Referring to Fig. 3, it is according to the schematic diagram that concerns between the B value of the embodiment of the invention and the brightness adjustment.Among Fig. 3, abscissa is the regulated quantity of brightness slide block, and scope is 0-100, and ordinate is the practical adjustments amount, and scope is 0-255, i.e. B in the corresponding adjusting of the value of the ordinate formula, and abscissa is actual regulated quantity.Dotted line is the regulating effect of integral image brightness when big among the figure, and solid line is the overall brightness regulating effect hour of image.
Adjusting reality to contrast also is that the Y component in the YUV image is regulated.At this moment, the step of in the step 102 described image attributes parameter being regulated according to predetermined strategy comprises:
When contrast when the direction that increases is regulated,
Y′=Y*C (3)
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and C is the contrast adjustment value;
When contrast when the direction that reduces is regulated,
Y′=A+(Y-A)*C (4)
Wherein, Y is the brightness value before image is adjusted, and Y ' is the adjusted brightness value of brightness, and C is the contrast adjustment value, and A is a radix value.In actual applications, A can get arbitrary value, and A can get 30 in a preferred embodiment.
The variation of above-mentioned C value increases with the regulated quantity of contrast, reduce thereupon reducing, but discord contrast adjustment amount is proportional, but more hour in the contrast adjustment amount, gray scale (also being brightness Y) increases soon more, and when the contrast adjustment amount was big more, it is slow more that gray scale increases.The C value is influenced by brightness adjustment, and when brightness adjustment was big, the C value reduced thereupon.Equally, the C value has been carried out self adaptation to the overall brightness of image, at the difference of image averaging gray scale, and C value big or small different.
Referring to Fig. 4, it is according to the schematic diagram that concerns between the C value of the embodiment of the invention and the contrast adjustment amount.Among Fig. 4, abscissa is represented the regulated quantity of contrast slide block, and scope is 0-100, ordinate is represented the practical adjustments effect of contrast, and scope is 0-2, and solid line a is that integral image brightness is less, when brightness is regulated to the direction that reduces, the relation of contrast slide block regulated quantity and actual contrast regulated value.Dotted line b is that integral image brightness is bigger, when brightness is regulated to the direction that reduces, and the relation of contrast slide block regulated quantity and actual contrast regulated value.
Need to prove that the embodiment of the present application combines brightness and contrast's adjusting, brightness regulation and contrast adjustment are combined, interact, to reach better regulating effect.
When preventing that the integral image gray scale is big, the brightness and contrast regulates the excessive phenomenon of adjusting that causes to the direction that increases simultaneously, and the safeguard measure when being provided with this kind situation suppresses excessively to regulate phenomenon.Braking measure is, regulates and regulated quantity when all bigger to the direction that increases simultaneously the brightness and contrast, reduces brightness and contrast's practical adjustments amount.
The adjusting of saturation is a mould of regulating the vector of carrier chrominance signal U, V component composition, and the big more saturation of mould is big more, otherwise more little.
The relation of color harmony saturation as shown in Figure 5, among Fig. 5, U is a blue difference signal, V is a red color difference signal, the value of angle θ is the regulated quantity of tone, the mould of vectorial b is the regulated quantity of saturation.Adjustment process to saturation and colourity elaborates again below.
Actual to the adjusting of saturation is that U in the YUV image and V component are regulated.At this moment, the step of in the step 102 described image attributes parameter being regulated according to predetermined strategy comprises:
U′=((U-128)*S)+128 (5)
V′=((V-128)*S)+128 (6)
Wherein, U is the blue difference signal value before image is adjusted, and U ' is adjusted blue difference signal value, and V is the red color difference signal value before image is adjusted, and V ' is adjusted red color difference signal value, and S is the saturation regulated value.Wherein, 128 is central value.
In the YUV image space, the change of Y component can cause the change of colourity, and in order to obtain better effect, the regulated quantity of the saturation of image is influenced by brightness and contrast's regulated quantity, the regulated quantity of saturation reduces along with the increase of brightness, increases along with the increase of contrast; And reduce along with reducing of brightness and contrast.That is to say that the regulated quantity of saturation is carried out adaptive change to image brightness, the practical adjustments amount of saturation reduces along with the increase of brightness, increases along with the increase of contrast, reduces when the brightness and contrast reduces simultaneously thereupon.
Referring to Fig. 6, it is the schematic diagram that concerns according to the regulated quantity S of the saturation of the embodiment of the invention and saturation slide block adjusting position and brightness, contrast.Among Fig. 6, abscissa is represented the position of saturation adjusting slider, and ordinate is represented the practical adjustments amount of saturation.The adjustable range of abscissa is 0~100,50 centers when regulating for slide block, and this moment, saturation was not regulated.The adjustable range of ordinate is 0~2.0 for to be adjusted to minimum with saturation, and this moment, saturation was 0, and promptly image does not have colouring information.Among Fig. 6, solid line a is in initial position for brightness and contrast's adjusting slider, when being unadjusted state, regulate the position of saturation slide block and the relation of actual saturation separately, dotted line b is that the brightness and contrast is when the direction that reduces is regulated, regulate the position of saturation slide block and the relation of actual saturation, dotted line c be brightness or contrast when the direction that increases is regulated, regulate the position of saturation slide block and the relation of actual saturation.
In the adjusting of tone, adopt the regulative mode of colour circle in the embodiment of the invention.
Adjusting reality to colourity also is that U in the YUV image and V component are regulated.At this moment, the step of in the step 102 described image attributes parameter being regulated according to predetermined strategy comprises:
U′=(U-128)*cosθ+(V-128)*sinθ+128 (7)
V′=(V-128)*cosθ-(U-128)*sinθ+128 (8)
Wherein, U is the blue difference signal value before image is adjusted, and U ' is adjusted blue difference signal value, and V is the red color difference signal value before image is adjusted, and V ' is adjusted red color difference signal value, and θ is the colourity regulated quantity.Wherein, 128 is central value.
Use the method that the embodiment of the invention provides, each width of cloth picture is handled, also just can be handled, therefore be not subjected to the restriction of the scope of application of picture and video each two field picture of video, both be applicable to picture adjusting pattern, also be applicable to video adjusting pattern.
The embodiment of the invention also provides a kind of device of regulating image attributes, referring to Fig. 7, specifically comprises:
Parameter acquisition module 701 is used to obtain the image attributes parameter of YUV image;
Adjustment module 702 is used for described image attributes parameter is regulated according to predetermined strategy, the image attributes after obtaining to regulate.
Above-mentioned image attributes parameter comprises following one of them or combination in any: brightness, contrast, saturation and colourity.
Said apparatus may further include:
The brightness adaptation module, when being used for the brightness regulation to image, if the integral body of image is brighter, then regulated quantity is bigger, if integral image brightness is less, then regulated quantity is also less.
Said apparatus can further include:
The comprehensive adjustment module, the regulated quantity that is used to control described saturation reduces along with the increase of brightness, increases along with the increase of contrast, and when reducing simultaneously along with the brightness and contrast and reduce.
Use the adjusting image attributes device that the embodiment of the invention provides, saved twice module converts of YUV~RGB and RGB~HSV, avoid when regulating the image attributes of YUV image amount of calculation excessive, the problem that consumes resources is many, because can directly carry out attribute at the YUV view data regulates, make resource that adjustment process takies seldom, improved the efficient of regulating greatly.
Have, the embodiment of the present application has increased the method for the brightness of image self being carried out dynamic adjustments again, has improved the video effect of image adjustment, and through test comparison, regulating effect of the present invention is better than through carrying out the control method of color attribute after the color model conversion.
For device embodiment, because it is substantially similar in appearance to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Need to prove, in this article, such as term " comprise ", " comprising " or its any other variant be intended to contain comprising of nonexcludability, thereby make and comprise that process, method, article or the equipment of a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or also be included as this process, method, article or equipment intrinsic key element.Do not having under the situation of more restrictions, the key element that limits by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
One of ordinary skill in the art will appreciate that all or part of step that realizes in the said method execution mode is to instruct relevant hardware to finish by program, described program can be stored in the computer read/write memory medium, here the alleged storage medium that gets, as: ROM/RAM, magnetic disc, CD etc.
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, be equal to replacement, improvement etc., all be included in protection scope of the present invention.