The content of the invention
In view of this, this application provides a kind of image processing method and device, for solving since camera rocks institute
Caused by video mosaic effect, the problem of influencing user experience.
To achieve these goals, it is proposed that scheme it is as follows:
A kind of image processing method, for the image for being sent to encoder, performs following processes:
It is poor to calculate the luminance mean value of current frame image and previous frame image, and compared to previous frame image, present frame figure
The pixel that brightness change is produced as in accounts for the ratio of all pixels point in current frame image;
Judge whether the luminance mean value difference more than first rocks threshold value;And
Judge whether the ratio more than second rocks threshold value;
If luminance mean value difference rocks threshold value more than first, and the ratio rocks threshold value more than second, then according to the
One preset adjustment mode, the coding bit rate that encoder is calculated raise.
Preferably, further include:
Judge whether the luminance mean value difference is less than the first static threshold;And
Judge whether the ratio is less than the second static threshold;
If luminance mean value difference is less than the first static threshold, and the ratio is less than the second static threshold, then according to the
Two preset adjustment modes, the coding bit rate that encoder is calculated are lowered.
Preferably, described according to the first preset adjustment mode, the coding bit rate that encoder is calculated raises, including:
The coding bit rate that encoder is calculated raises the first preset value;
Alternatively,
Determine the preset numerical intervals belonging to the luminance mean value difference;
According to preset adjusted value corresponding with the numerical intervals, on the coding bit rate calculated to encoder carries out
Adjust.
Preferably, described according to the second preset adjustment mode, the coding bit rate that encoder is calculated is lowered, including:
The coding bit rate that encoder is calculated lowers the second preset value;
Alternatively,
Determine the preset numerical intervals belonging to the luminance mean value difference;
According to preset adjusted value corresponding with the numerical intervals, the coding bit rate that encoder calculates is carried out down
Adjust.
A kind of image processing apparatus, is handled for the image for being sent to encoder, which includes:
Computing unit, the luminance mean value for calculating current frame image and previous frame image is poor, and compared to previous frame
Image, the pixel that brightness change is produced in current frame image account for the ratio of all pixels point in current frame image;
First judging unit, for judging whether the luminance mean value difference more than first rocks threshold value;
Second judging unit, for judging whether the ratio more than second rocks threshold value;
Bit rate raises unit, and for rocking threshold value more than first in the definite luminance mean value difference, and the ratio is big
When second rocks threshold value, according to the first preset adjustment mode, the coding bit rate that encoder is calculated raises.
Preferably, further include:
3rd judging unit, for judging whether the luminance mean value difference is less than the first static threshold;
4th judging unit, for judging whether the ratio is less than the second static threshold;
Bit rate lowers unit, and for being less than the first static threshold in the definite luminance mean value difference, and the ratio is small
When the second static threshold, according to the second preset adjustment mode, the coding bit rate that encoder is calculated is lowered.
Preferably, the bit rate up-regulation unit includes:
First bit rate raises subelement, and the coding bit rate for encoder to be calculated raises the first preset value;
Second bit rate raises subelement, for determining the preset numerical intervals belonging to the luminance mean value difference;According to
Preset adjusted value corresponding with the numerical intervals, raises the coding bit rate that encoder calculates.
Preferably, the bit rate is lowered unit and is included:
First bit rate lowers subelement, and the coding bit rate for encoder to be calculated lowers the second preset value;
Second bit rate lowers subelement, for determining the preset numerical intervals belonging to the luminance mean value difference;According to
Preset adjusted value corresponding with the numerical intervals, lowers the coding bit rate that encoder calculates.
It can be seen from the above technical scheme that image processing method provided by the embodiments of the present application, is compiled for being sent to
The image of code device performs following processes:It is poor to calculate the luminance mean value of current frame image and previous frame image, and compared to upper one
Two field picture, the pixel that brightness change is produced in current frame image account for the ratio of all pixels point in current frame image, judge institute
State whether luminance mean value difference more than first rocks threshold value, and, judge whether the ratio more than second rocks threshold value, if described
Luminance mean value difference rocks threshold value more than first, and the ratio rocks threshold value more than second, then according to the first preset adjustment mode,
The coding bit rate that encoder is calculated raises.The application is poor by the luminance mean value of two field pictures before and after contrast, is finding
When luminance mean value difference is excessive, further determine that the pixel that brightness change occurs in current frame image accounts for all pixels point in image
Ratio it is whether excessive, if it is, determine that camera is rocked when shooting current frame image, thus in order to avoid
There is mosaic effect in video, and the coding bit rate that encoder is calculated raises, and to ensure the quality of output video, improves
The Experience Degree of user.
Embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, the technical solution in the embodiment of the present application is carried out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, those of ordinary skill in the art are obtained every other without making creative work
Embodiment, shall fall in the protection scope of this application.
The embodiment of the present application provides a kind of image processing method, and this method is directed to be sent in the image of encoder and carries out
Processing, concrete processing procedure is referring to Fig. 1.
As shown in Figure 1, this method includes:
Step S100, it is poor to calculate the luminance mean value of current frame image and previous frame image, and compared to previous frame image,
The pixel that brightness change is produced in current frame image accounts for the ratio of all pixels point in current frame image;
Specifically, for current frame image, its luminance mean value is calculated first, and then it is bright with previous frame image to calculate it
The difference of average is spent, obtains the equal difference of brightness.When calculating the luminance mean value of current frame image, current frame image is specially calculated
In each pixel brightness value average.
In addition it is also necessary to calculate compared to previous frame image, the pixel that brightness change is produced in current frame image is accounted for and worked as
The ratio value of all pixels point in prior image frame.
Step S110, judge whether the luminance mean value difference more than first rocks threshold value;
Step S120, judge whether the ratio more than second rocks threshold value;
If the luminance mean value difference rocks threshold value more than first, and the ratio rocks threshold value more than second, then performs step
Rapid S130;
Specifically, above-mentioned first threshold value is rocked and second to rock threshold value be value set in advance.If it is determined that present frame
The luminance mean value difference of image and previous frame image rocks threshold value more than first, then meaning front and rear two field pictures, there occurs very big
Change.Determine whether in current frame image, produce whether the ratio shared by the pixel of brightness change more than second rocks threshold
Value, if it is, determining that camera is significantly rocked really when gathering current frame image.
Step S130, according to the first preset adjustment mode, the coding bit rate that encoder is calculated raises.
Specifically, the first preset adjustment mode includes various ways, calculates encoder according to the first preset adjustment mode
The coding bit rate up-regulation gone out so that the quality for exporting video gets a promotion, and avoids mosaic effect.
Image processing method provided by the embodiments of the present application, following processes are performed for the image for being sent to encoder:Meter
It is poor to calculate the luminance mean value of current frame image and previous frame image, and compared to previous frame image, is produced in current frame image bright
The pixel of degree change accounts for the ratio of all pixels point in current frame image, judges whether the luminance mean value difference is more than first and shakes
Dynamic threshold value, and, judge whether the ratio more than second rocks threshold value, if the luminance mean value is poor to rock threshold more than first
Value, and the ratio rocks threshold value more than second, then according to the first preset adjustment mode, the coded-bit that encoder is calculated
Rate raises.The application is poor by the luminance mean value of two field pictures before and after contrast, when finding that luminance mean value difference is excessive, further really
In settled prior image frame occur brightness change pixel account for all pixels point in image ratio it is whether excessive, if it is,
Determine that camera is rocked when shooting current frame image, thus in order to avoid mosaic effect occurs in video, will compile
The coding bit rate up-regulation that code device calculates, to ensure the quality of output video, improves the Experience Degree of user.
For the ease of understanding the scheme of the application, we are explained with a concrete scene.
Under scene provided in this embodiment, camera is directed at the teacher to give lessons, to gather teacher's teaching video.It is false
Such as a certain moment, classmate's imprudence has touched lower camera, has caused camera significantly to rock, it is to be understood that right
In this two field picture of current time collection, if without any processing, occurring that mosaic is imitated after encoded display
Should.And the processing mode of the application is:
For current frame image, its luminance mean value difference Δ AVG with previous frame image is calculated, and compared to previous frame figure
Picture, the pixel that brightness change is produced in current frame image account for the ratio Δ RATIO of all pixels point in current frame image.Judge
Whether meet:AndWherein,WithRespectively first rocks threshold value
Threshold value is rocked with second.When determining to meet above-mentioned condition, determine that camera is rocked when gathering current frame image.Cause
And the coding bit rate calculated for encoder raises, to ensure the quality of output video.
In another embodiment of the application, we introduce the several first preset adjustment modes, namely are determining currently
After mosaic effect occurs in two field picture, the coding bit rate that encoder calculates how is adjusted.
The first regulative mode:
The first preset value is preset, rocks threshold value more than first judging that the luminance mean value is poor, and the ratio is big
When second shakes big threshold value, the coding bit rate that encoder is calculated raises the first preset value.
Obviously, the first regulative mode is a kind of fairly simple, convenient regulative mode, but its Adjusting accuracy is not
It is very accurate.It is some be not too high scene to output video quality demands under, can directly use this regulative mode.
Second of regulative mode:
Preset the numerical intervals of luminance mean value difference and the correspondence of adjusted value.Judging that the luminance mean value difference is big
Threshold value is rocked in first, and when the ratio is more than second and shakes big threshold value, determine the bright of current frame image and previous frame image
The numerical intervals belonging to equal value difference are spent, according to the corresponding adjusted value of the numerical intervals, the coding bit rate calculated to encoder
Raised.
Citing is such as:Preset following correspondence:
Table 1
When definite luminance mean value difference is 7, it is determined that go out adjusted value for 30.The coding that encoder can be thus calculated
Bit rate raises 30QP.
Obviously, second of regulative mode is more accurate compared to the first regulative mode, can be suitable for exporting video
In the higher scene of quality.
Further, it is also possible to preset compared to previous frame image, the pixel of brightness change is produced in current frame image
Account for the ratio of all pixels point in current frame image, the correspondence between adjusted value.And refer to above-mentioned second of adjusting side
Formula carries out the adjusting of coding bit rate, this is no longer described in detail.
In addition, during camera gathers video, the prior art is also faced with such a problem:Work as cam lens
When content is opposing stationary, user can generally reduce the content detail quality requirement in camera lens, and be more heavily weighted toward audio content, because
It is a kind of waste of resource in insignificant background detail that this, which spends most of bandwidth,.Based on this, this application provides another
Kind image processing method.According to Fig. 1 and Fig. 2, image processing method can further include:
Step S140, judge whether the luminance mean value difference is less than the first static threshold;
Step S150, judge whether the ratio is less than the second static threshold;
If the luminance mean value difference is less than the first static threshold, and the ratio is less than the second static threshold, then performs step
Rapid S160;
Specifically, above-mentioned first static threshold and the second static threshold are value set in advance.If it is determined that present frame
The luminance mean value difference of image and previous frame image is less than the first static threshold, then means the variation of front and rear two field pictures generation not
Greatly.Determine whether in current frame image, produce whether the ratio shared by the pixel of brightness change is less than the second static threshold,
If it is, determine that current frame image and previous frame picture material are opposing stationary.
Step S160, then according to the second preset adjustment mode, the coding bit rate that encoder is calculated is lowered.
Specifically, the second preset adjustment mode includes various ways, calculates encoder according to the second preset adjustment mode
The coding bit rate gone out is lowered so that output video content quality somewhat reduces, and bandwidth is reduced in the case where not influencing viewing
The use of resource.
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 perform, to this application without limiting.
For the ease of understanding the scheme of the application, we are explained with a concrete scene.
Under scene provided in this embodiment, the blackboard on camera alignment dais, to gather teacher's teaching video.If
A certain moment teacher goes somewhere temporarily, thus never changes on the blackboard of camera alignment.In this regard, the application
Processing mode is:
For current frame image, its luminance mean value difference Δ AVG with previous frame image is calculated, and compared to previous frame figure
Picture, the pixel that brightness change is produced in current frame image account for the ratio Δ RATIO of all pixels point in current frame image.Judge
Whether meet:AndWherein,WithRespectively first static threshold
Value and the second static threshold.When determining to meet above-mentioned condition, the current frame image of collection is determined compared to previous frame image, it is interior
Hold almost unchanged.Thus, in order to reduce the use of bandwidth resources, lowered for the coding bit rate that encoder calculates.
In another embodiment of the application, we introduce the several second preset adjustment modes, namely are determining currently
When two field picture and opposing stationary previous frame picture material, the coding bit rate that encoder calculates how is adjusted.
The first regulative mode:
The second preset value is preset, is less than the first static threshold judging that the luminance mean value is poor, and the ratio is small
When the second static threshold, the coding bit rate that encoder is calculated lowers the second preset value.
Obviously, the first regulative mode is a kind of fairly simple, convenient regulative mode, but its Adjusting accuracy is not
It is very accurate.Under some scenes less high to bandwidth resources requirement, this regulative mode can be directly used.
Second of regulative mode:
The numerical intervals of luminance mean value difference and the correspondence of adjusted value are preset, are judging that the luminance mean value difference is small
In the first static threshold, and when the ratio is less than the second static threshold, the bright of current frame image and previous frame image is determined
The numerical intervals belonging to equal value difference are spent, according to the corresponding adjusted value of the numerical intervals, the coding bit rate calculated to encoder
Lowered.
Citing is such as:Preset following correspondence:
Table 2
When definite luminance mean value difference is 7, it is determined that go out adjusted value for 35.The coding that encoder can be thus calculated
Bit rate lowers 35QP.
Obviously, second of regulative mode is more accurate compared to the first regulative mode, can be suitable for bandwidth requirement
In higher scene.
Further, it is also possible to preset compared to previous frame image, the pixel of brightness change is produced in current frame image
Account for the ratio of all pixels point in current frame image, the correspondence between adjusted value.And refer to above-mentioned second of adjusting side
Formula carries out the adjusting of coding bit rate, this is no longer described in detail.
Image processing apparatus provided by the embodiments of the present application is described below, image processing apparatus described below with
Above-described image processing apparatus can correspond reference.
Referring to Fig. 3, Fig. 3 is a kind of structure diagram of image processing apparatus disclosed in the embodiment of the present application.
The device is handled for the image for being sent to encoder.As shown in figure 3, the device includes:
Computing unit 31, the luminance mean value for calculating current frame image and previous frame image is poor, and compared to upper one
Two field picture, the pixel that brightness change is produced in current frame image account for the ratio of all pixels point in current frame image;
Specifically, for current frame image, its luminance mean value is calculated first, and then it is bright with previous frame image to calculate it
The difference of average is spent, obtains the equal difference of brightness.When calculating the luminance mean value of current frame image, current frame image is specially calculated
In each pixel brightness value average.
In addition it is also necessary to calculate compared to previous frame image, the pixel that brightness change is produced in current frame image is accounted for and worked as
The ratio value of all pixels point in prior image frame.
First judging unit 32, for judging whether the luminance mean value difference more than first rocks threshold value;
Second judging unit 33, for judging whether the ratio more than second rocks threshold value;
Specifically, above-mentioned first threshold value is rocked and second to rock threshold value be value set in advance.If it is determined that present frame
The luminance mean value difference of image and previous frame image rocks threshold value more than first, then meaning front and rear two field pictures, there occurs very big
Change.Determine whether in current frame image, produce whether the ratio shared by the pixel of brightness change more than second rocks threshold
Value, if it is, determining that camera is significantly rocked really when gathering current frame image.
Bit rate raises unit 34, for rocking threshold value, and the ratio more than first in the definite luminance mean value difference
When rocking threshold value more than second, according to the first preset adjustment mode, the coding bit rate that encoder is calculated raises.
Specifically, the first preset adjustment mode includes various ways, calculates encoder according to the first preset adjustment mode
The coding bit rate up-regulation gone out so that the quality for exporting video gets a promotion, and avoids mosaic effect.
Image processing apparatus provided by the embodiments of the present application, following processes are performed for the image for being sent to encoder:Meter
It is poor to calculate the luminance mean value of current frame image and previous frame image, and compared to previous frame image, is produced in current frame image bright
The pixel of degree change accounts for the ratio of all pixels point in current frame image, judges whether the luminance mean value difference is more than first and shakes
Dynamic threshold value, and, judge whether the ratio more than second rocks threshold value, if the luminance mean value is poor to rock threshold more than first
Value, and the ratio rocks threshold value more than second, then according to the first preset adjustment mode, the coded-bit that encoder is calculated
Rate raises.The application is poor by the luminance mean value of two field pictures before and after contrast, when finding that luminance mean value difference is excessive, further really
In settled prior image frame occur brightness change pixel account for all pixels point in image ratio it is whether excessive, if it is,
Determine that camera is rocked when shooting current frame image, thus in order to avoid mosaic effect occurs in video, will compile
The coding bit rate up-regulation that code device calculates, to ensure the quality of output video, improves the Experience Degree of user.
Optionally, the embodiment of the present application discloses a kind of alternative construction of bit rate up-regulation unit, as shown in figure 4, bit
Rate up-regulation unit 34 can include:
First bit rate raises subelement 341, and the coding bit rate for encoder to be calculated raises the first preset value;
Second bit rate raises subelement 342, for determining the preset numerical intervals belonging to the luminance mean value difference;Press
According to preset adjusted value corresponding with the numerical intervals, the coding bit rate that encoder calculates is raised.
Obviously, the regulative mode of the first bit rate up-regulation subelement is a kind of fairly simple, convenient regulative mode, still
Its Adjusting accuracy is not very accurate.It is some be not too high scene to output video quality demands under, can be direct
Use this regulative mode.And the regulative mode of the second bit rate up-regulation subelement is more smart compared to the first regulative mode
Really, can be suitable for the scene higher to output video quality.
In addition, during camera gathers video, the prior art is also faced with such a problem:Work as cam lens
When content is opposing stationary, user can generally reduce the content detail quality requirement in camera lens, and be more heavily weighted toward audio content, because
It is a kind of waste of resource in insignificant background detail that this, which spends most of bandwidth,.Based on this, the embodiment of the present application also carries
Another image processing apparatus is supplied, according to Fig. 3 and Fig. 5, which can also include:
3rd judging unit 35, for judging whether the luminance mean value difference is less than the first static threshold;
4th judging unit 36, for judging whether the ratio is less than the second static threshold;
Specifically, above-mentioned first static threshold and the second static threshold are value set in advance.If it is determined that present frame
The luminance mean value difference of image and previous frame image is less than the first static threshold, then means the variation of front and rear two field pictures generation not
Greatly.Determine whether in current frame image, produce whether the ratio shared by the pixel of brightness change is less than the second static threshold,
If it is, determine that current frame image and previous frame picture material are opposing stationary.
Bit rate lowers unit 37, for being less than the first static threshold, and the ratio in the definite luminance mean value difference
During less than the second static threshold, according to the second preset adjustment mode, the coding bit rate that encoder is calculated is lowered.
Specifically, the second preset adjustment mode includes various ways, calculates encoder according to the second preset adjustment mode
The coding bit rate gone out is lowered so that output video content quality somewhat reduces, and bandwidth is reduced in the case where not influencing viewing
The use of resource.
Optionally, the embodiment of the present application discloses a kind of alternative construction of bit rate up-regulation unit, as shown in fig. 6, bit
Rate up-regulation unit 37 can include:
First bit rate lowers subelement 371, and the coding bit rate for encoder to be calculated lowers the second preset value;
Second bit rate lowers subelement 372, for determining the preset numerical intervals belonging to the luminance mean value difference;Press
According to preset adjusted value corresponding with the numerical intervals, the coding bit rate that encoder calculates is lowered.
Obviously, the regulative mode that the first bit rate lowers subelement is a kind of fairly simple, convenient regulative mode, still
Its Adjusting accuracy is not very accurate.Under some scenes less high to bandwidth resources requirement, this can be directly used
Kind regulative mode., can and the regulative mode that the second bit rate lowers subelement is more accurate compared to the first regulative mode
Suitable for the scene higher to bandwidth requirement.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or order.Moreover, term " comprising ", "comprising" or its any other variant meaning
Covering non-exclusive inclusion, so that process, method, article or equipment including a series of elements not only include that
A little key elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", is not arranged
Except also there are other identical element in the process, method, article or apparatus that includes the element.
Each embodiment is described by the way of progressive in this specification, what each embodiment stressed be and other
The difference of embodiment, between each embodiment identical similar portion mutually referring to.
The foregoing description of the disclosed embodiments, enables professional and technical personnel in the field to realize or using the application.
A variety of modifications to these embodiments will be apparent for those skilled in the art, as defined herein
General Principle can be realized in other embodiments in the case where not departing from spirit herein or scope.Therefore, the application
The embodiments shown herein is not intended to be limited to, and is to fit to and the principles and novel features disclosed herein phase one
The most wide scope caused.