Summary of the invention
In view of this, this application provides a kind of image processing method and device, for solving because camera rocks caused video mosaic effect, affecting the problem of Consumer's Experience.
To achieve these goals, the existing scheme proposed is as follows:
A kind of image processing method, for the image sending to encoder, performs following process:
Calculate the equal value difference of brightness of current frame image and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image;
Judge whether the equal value difference of described brightness is greater than first and rocks threshold value; And,
Judge whether described ratio is greater than second and rocks threshold value;
If the equal value difference of described brightness is greater than first rock threshold value, and described ratio is greater than second rocks threshold value, then according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.
Preferably, also comprise:
Judge whether the equal value difference of described brightness is less than the first static threshold; And,
Judge whether described ratio is less than the second static threshold;
If the equal value difference of described brightness is less than the first static threshold, and described ratio is less than the second static threshold, then according to the second preset adjustment mode, the coding bit rate calculated by encoder is lowered.
Preferably, described according to the first preset adjustment mode, the coding bit rate calculated by encoder raises, and comprising:
The coding bit rate calculated by encoder raises the first preset value;
Or,
Determine the preset numerical intervals belonging to the equal value difference of described brightness;
According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is raised.
Preferably, described according to the second preset adjustment mode, the coding bit rate calculated by encoder is lowered, and comprising:
The coding bit rate calculated by encoder lowers the second preset value;
Or,
Determine the preset numerical intervals belonging to the equal value difference of described brightness;
According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is lowered.
A kind of image processing apparatus, for sending to the image of encoder to process, this device comprises:
Computing unit, the equal value difference of the brightness for calculating current frame image and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image;
First judging unit, for judging whether the equal value difference of described brightness is greater than first and rocks threshold value;
Second judging unit, for judging whether described ratio is greater than second and rocks threshold value;
Bit rate raises unit, and for determining that the equal value difference of described brightness is greater than first and rocks threshold value, and described ratio is greater than second when rocking threshold value, and according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.
Preferably, also comprise:
3rd judging unit, for judging whether the equal value difference of described brightness is less than the first static threshold;
4th judging unit, for judging whether described ratio is less than the second static threshold;
Bit rate lowers unit, and for determining that the equal value difference of described brightness is less than the first static threshold, and when described ratio is less than the second static threshold, according to the second preset adjustment mode, the coding bit rate calculated by encoder is lowered.
Preferably, described bit rate rise unit comprises:
First bit rate raises subelement, and the coding bit rate for being calculated by encoder raises the first preset value;
Second bit rate raises subelement, for determining the preset numerical intervals belonging to the equal value difference of described brightness; According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is raised.
Preferably, described bit rate downward unit comprises:
First bit rate lowers subelement, and the coding bit rate for being calculated by encoder lowers the second preset value;
Second bit rate lowers subelement, for determining the preset numerical intervals belonging to the equal value difference of described brightness; According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is lowered.
As can be seen from above-mentioned technical scheme, the image processing method that the embodiment of the present application provides, following process is performed: the equal value difference of brightness calculating current frame image and previous frame image for sending to the image of encoder, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image, judge whether the equal value difference of described brightness is greater than first and rocks threshold value, and, judge whether described ratio is greater than second and rocks threshold value, if the equal value difference of described brightness is greater than first rock threshold value, and described ratio is greater than second rocks threshold value, then according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.The application is by the equal value difference of brightness of two two field pictures before and after contrast, when finding that the equal value difference of brightness is excessive, whether the ratio that the pixel determining to occur in current frame image brightness change further accounts for all pixels in image is excessive, if, then determine that camera there occurs and rocks when taking current frame image, thus in order to avoid mosaic effect appears in video, the coding bit rate calculated by encoder raises, to ensure the quality of output video, improve the Experience Degree of user.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, be clearly and completely described the technical scheme in the embodiment of the present application, obviously, described embodiment is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all belong to the scope of the application's protection.
The embodiment of the present application provides a kind of image processing method, and the method processes for sending in the image of encoder, and concrete processing procedure is see Fig. 1.
As shown in Figure 1, the method comprises:
The equal value difference of brightness of step S100, calculating current frame image and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image;
Particularly, for current frame image, first calculate its brightness average, and then calculate the difference of brightness average of itself and previous frame image, obtain the equal difference of brightness.When calculating the brightness average of current frame image, be specially the average of the brightness value calculating each pixel in current frame image.
In addition, also need to calculate compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio value of all pixels in current frame image.
Step S110, judge whether the equal value difference of described brightness is greater than first and rocks threshold value;
Step S120, judge whether described ratio is greater than second and rocks threshold value;
If the equal value difference of described brightness is greater than first rock threshold value, and described ratio is greater than second rocks threshold value, then perform step S130;
Particularly, above-mentioned first rock threshold value and second and rock threshold value and be the value preset.If determine that the equal value difference of the brightness of current frame image and previous frame image rocks threshold value more than first, then mean that front and back two two field picture there occurs very large variation.In further judgement current frame image, whether the ratio shared by pixel producing brightness change rocks threshold value more than second, if so, then determines that camera really there occurs and significantly rocks when gathering current frame image.
Step S130, according to the first preset adjustment mode, the coding bit rate that encoder is calculated raise.
Particularly, the first preset adjustment mode comprises various ways, and the coding bit rate calculated by encoder according to the first preset adjustment mode raises, and the quality of output video is got a promotion, avoids mosaic effect.
The image processing method that the embodiment of the present application provides, following process is performed: the equal value difference of brightness calculating current frame image and previous frame image for sending to the image of encoder, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image, judge whether the equal value difference of described brightness is greater than first and rocks threshold value, and, judge whether described ratio is greater than second and rocks threshold value, if the equal value difference of described brightness is greater than first rock threshold value, and described ratio is greater than second rocks threshold value, then according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.The application is by the equal value difference of brightness of two two field pictures before and after contrast, when finding that the equal value difference of brightness is excessive, whether the ratio that the pixel determining to occur in current frame image brightness change further accounts for all pixels in image is excessive, if, then determine that camera there occurs and rocks when taking current frame image, thus in order to avoid mosaic effect appears in video, the coding bit rate calculated by encoder raises, to ensure the quality of output video, improve the Experience Degree of user.
For the ease of understanding the scheme of the application, we make an explanation with a concrete scene.
Under the scene that the present embodiment provides, camera aims at the teacher given lessons, and to teach video to gather teacher.If a certain moment, classmate has touched time camera because of carelessness, has caused camera significantly to rock, has been understandable that, for this two field picture that current time gathers, if do not carry out any process, there will be mosaic effect after encoded display.And the processing mode of the application is:
For current frame image, calculate the brightness equal value difference Δ AVG of itself and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio Δ RATIO of all pixels in current frame image.Judge whether to meet:
and,
wherein,
with
be respectively first to rock threshold value and second and rock threshold value.When determining to meet above-mentioned condition, determine that camera there occurs and rocks when gathering current frame image.Thus, the coding bit rate calculated for encoder raises, to ensure the quality of output video.
In another embodiment of the application, we introduce several first preset adjustment mode, also namely after determining that current frame image there will be mosaic effect, how to adjust the coding bit rate that encoder calculates.
The first regulative mode:
Preset the first preset value, judging that the equal value difference of described brightness is greater than first and rocks threshold value, and when described ratio is greater than the second rolling large threshold value, the coding bit rate calculated by encoder raises the first preset value.
Obviously, the first regulative mode is a kind of fairly simple, regulative mode easily, but its Adjusting accuracy is not very accurate.Under some is not too high scene to output video quality requirement, can directly use this regulative mode.
The second regulative mode:
Preset the numerical intervals of the equal value difference of brightness and the corresponding relation of adjusted value.Judging that the equal value difference of described brightness is greater than first and rocks threshold value, and described ratio is when being greater than the second large threshold value of rolling, determine the numerical intervals belonging to the equal value difference of the brightness of current frame image and previous frame image, according to the adjusted value that this numerical intervals is corresponding, the coding bit rate that encoder calculates is raised.
Citing as: preset following corresponding relation:
Table 1
When determining that the equal value difference of brightness is 7, then determine that adjusted value is 30.The coding bit rate that thus can calculate encoder raises 30QP.
Obviously, the second regulative mode is more accurate compared to the first regulative mode, can be applicable in the higher scene of output video quality.
In addition, can also preset compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image and the corresponding relation between adjusted value.And the adjustment of coding bit rate is carried out with reference to above-mentioned the second regulative mode, this is no longer described in detail.
In addition, in the process of camera collection video, prior art also faces so a kind of problem: when cam lens content geo-stationary, user generally can reduce the content detail quality requirement in camera lens, and more bias toward audio content, therefore spending most of bandwidth in insignificant background detail, is a kind of waste of resource.Based on this, this application provides another kind of image processing method.Composition graphs 1 and Fig. 2 known, image processing method can further include:
Step S140, judge whether the equal value difference of described brightness is less than the first static threshold;
Step S150, judge whether described ratio is less than the second static threshold;
If the equal value difference of described brightness is less than the first static threshold, and described ratio is less than the second static threshold, then perform step S160;
Particularly, above-mentioned first static threshold and the second static threshold are the value preset.If determine that the equal value difference of the brightness of current frame image and previous frame image is less than the first static threshold, then mean that the variation that front and back two two field picture occurs is little.In further judgement current frame image, whether the ratio shared by pixel producing brightness change is less than the second static threshold, if so, then determines current frame image and previous frame picture material geo-stationary.
Step S160, then according to the second preset adjustment mode, the coding bit rate that encoder is calculated lower.
Particularly, the second preset adjustment mode comprises various ways, and the coding bit rate that calculated by encoder according to the second preset adjustment mode is lowered, and output video content quality is reduced a little, is not affecting the use of situation decline low bandwidth resource of viewing.
It should be noted that, the execution sequence of above-mentioned steps S140-S160 can perform side by side with step S110-S130, or successively performs, and does not limit this application.
For the ease of understanding the scheme of the application, we make an explanation with a concrete scene.
Under the scene that the present embodiment provides, camera aims at the blackboard on dais, to teach video to gather teacher.If a certain moment teacher goes somewhere temporarily, the blackboard that thus camera is aimed at never changes.To this, the processing mode of the application is:
For current frame image, calculate the brightness equal value difference Δ AVG of itself and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio Δ RATIO of all pixels in current frame image.Judge whether to meet:
and,
wherein,
with
be respectively the first static threshold and the second static threshold.When determining to meet above-mentioned condition, determine that the current frame image gathered is compared to previous frame image, content is almost constant.Thus, in order to reduce the use of bandwidth resources, the coding bit rate calculated for encoder is lowered.
In another embodiment of the application, we introduce several second preset adjustment mode, also namely when determining current frame image and previous frame picture material geo-stationary, how to adjust the coding bit rate that encoder calculates.
The first regulative mode:
Preset the second preset value, judging that the equal value difference of described brightness is less than the first static threshold, and when described ratio is less than the second static threshold, the coding bit rate calculated by encoder lowers the second preset value.
Obviously, the first regulative mode is a kind of fairly simple, regulative mode easily, but its Adjusting accuracy is not very accurate.Under some requires not too high scene to bandwidth resources, can directly use this regulative mode.
The second regulative mode:
Preset the numerical intervals of the equal value difference of brightness and the corresponding relation of adjusted value, judging that the equal value difference of described brightness is less than the first static threshold, and described ratio is when being less than the second static threshold, determine the numerical intervals belonging to the equal value difference of the brightness of current frame image and previous frame image, according to the adjusted value that this numerical intervals is corresponding, the coding bit rate that encoder calculates is lowered.
Citing as: preset following corresponding relation:
Table 2
When determining that the equal value difference of brightness is 7, then determine that adjusted value is 35.The coding bit rate that thus can calculate encoder lowers 35QP.
Obviously, the second regulative mode is more accurate compared to the first regulative mode, can be applicable in the higher scene of bandwidth requirement.
In addition, can also preset compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image and the corresponding relation between adjusted value.And the adjustment of coding bit rate is carried out with reference to above-mentioned the second regulative mode, this is no longer described in detail.
Be described the image processing apparatus that the embodiment of the present application provides below, image processing apparatus described below can mutual corresponding reference with above-described image processing apparatus.
See the structural representation of Fig. 3, Fig. 3 a kind of image processing apparatus disclosed in the embodiment of the present application.
This device processes for sending to the image of encoder.As shown in Figure 3, this device comprises:
Computing unit 31, the equal value difference of the brightness for calculating current frame image and previous frame image, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image;
Particularly, for current frame image, first calculate its brightness average, and then calculate the difference of brightness average of itself and previous frame image, obtain the equal difference of brightness.When calculating the brightness average of current frame image, be specially the average of the brightness value calculating each pixel in current frame image.
In addition, also need to calculate compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio value of all pixels in current frame image.
First judging unit 32, for judging whether the equal value difference of described brightness is greater than first and rocks threshold value;
Second judging unit 33, for judging whether described ratio is greater than second and rocks threshold value;
Particularly, above-mentioned first rock threshold value and second and rock threshold value and be the value preset.If determine that the equal value difference of the brightness of current frame image and previous frame image rocks threshold value more than first, then mean that front and back two two field picture there occurs very large variation.In further judgement current frame image, whether the ratio shared by pixel producing brightness change rocks threshold value more than second, if so, then determines that camera really there occurs and significantly rocks when gathering current frame image.
Bit rate raises unit 34, and for determining that the equal value difference of described brightness is greater than first and rocks threshold value, and described ratio is greater than second when rocking threshold value, and according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.
Particularly, the first preset adjustment mode comprises various ways, and the coding bit rate calculated by encoder according to the first preset adjustment mode raises, and the quality of output video is got a promotion, avoids mosaic effect.
The image processing apparatus that the embodiment of the present application provides, following process is performed: the equal value difference of brightness calculating current frame image and previous frame image for sending to the image of encoder, and compared to previous frame image, the pixel producing brightness change in current frame image accounts for the ratio of all pixels in current frame image, judge whether the equal value difference of described brightness is greater than first and rocks threshold value, and, judge whether described ratio is greater than second and rocks threshold value, if the equal value difference of described brightness is greater than first rock threshold value, and described ratio is greater than second rocks threshold value, then according to the first preset adjustment mode, the coding bit rate calculated by encoder raises.The application is by the equal value difference of brightness of two two field pictures before and after contrast, when finding that the equal value difference of brightness is excessive, whether the ratio that the pixel determining to occur in current frame image brightness change further accounts for all pixels in image is excessive, if, then determine that camera there occurs and rocks when taking current frame image, thus in order to avoid mosaic effect appears in video, the coding bit rate calculated by encoder raises, to ensure the quality of output video, improve the Experience Degree of user.
Optionally, the embodiment of the present application discloses the alternate configurations that a kind of bit rate raises unit, and as shown in Figure 4, bit rate raises unit 34 and can comprise:
First bit rate raises subelement 341, and the coding bit rate for being calculated by encoder raises the first preset value;
Second bit rate raises subelement 342, for determining the preset numerical intervals belonging to the equal value difference of described brightness; According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is raised.
Obviously, it is a kind of fairly simple, regulative mode easily that the first bit rate raises the regulative mode of subelement, but its Adjusting accuracy is not very accurate.Under some is not too high scene to output video quality requirement, can directly use this regulative mode.And the regulative mode that the second bit rate raises subelement is more accurate compared to the first regulative mode, can be applicable in the higher scene of output video quality.
In addition, in the process of camera collection video, prior art also faces so a kind of problem: when cam lens content geo-stationary, user generally can reduce the content detail quality requirement in camera lens, and more bias toward audio content, therefore spending most of bandwidth in insignificant background detail, is a kind of waste of resource.Based on this, the embodiment of the present application additionally provides another image processing apparatus, composition graphs 3 and Fig. 5 known, this device can also comprise:
3rd judging unit 35, for judging whether the equal value difference of described brightness is less than the first static threshold;
4th judging unit 36, for judging whether described ratio is less than the second static threshold;
Particularly, above-mentioned first static threshold and the second static threshold are the value preset.If determine that the equal value difference of the brightness of current frame image and previous frame image is less than the first static threshold, then mean that the variation that front and back two two field picture occurs is little.In further judgement current frame image, whether the ratio shared by pixel producing brightness change is less than the second static threshold, if so, then determines current frame image and previous frame picture material geo-stationary.
Bit rate lowers unit 37, and for determining that the equal value difference of described brightness is less than the first static threshold, and when described ratio is less than the second static threshold, according to the second preset adjustment mode, the coding bit rate calculated by encoder is lowered.
Particularly, the second preset adjustment mode comprises various ways, and the coding bit rate that calculated by encoder according to the second preset adjustment mode is lowered, and output video content quality is reduced a little, is not affecting the use of situation decline low bandwidth resource of viewing.
Optionally, the embodiment of the present application discloses a kind of alternate configurations that bit rate raises unit, and as shown in Figure 6, bit rate raises unit 37 and can comprise:
First bit rate lowers subelement 371, and the coding bit rate for being calculated by encoder lowers the second preset value;
Second bit rate lowers subelement 372, for determining the preset numerical intervals belonging to the equal value difference of described brightness; According to the preset adjusted value corresponding with this numerical intervals, the coding bit rate that encoder calculates is lowered.
Obviously, it is a kind of fairly simple, regulative mode easily that the first bit rate lowers the regulative mode of subelement, but its Adjusting accuracy is not very accurate.Under some requires not too high scene to bandwidth resources, can directly use this regulative mode.And the regulative mode that the second bit rate lowers subelement is more accurate compared to the first regulative mode, can be applicable in the higher scene of bandwidth requirement.
Finally, also it should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operating space, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical element.
In this specification, each embodiment adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar portion mutually see.
To the above-mentioned explanation of the disclosed embodiments, professional and technical personnel in the field are realized or uses the application.To be apparent for those skilled in the art to the multiple amendment of these embodiments, General Principle as defined herein when not departing from the spirit or scope of the application, can realize in other embodiments.Therefore, the application can not be restricted to these embodiments shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.