Summary of the invention
The technical issues of embodiment of the present invention solves is how to improve the speed and accuracy of estimation of motion vectors.
To solve the above problems, the embodiment of the invention provides a kind of true motion estimation method, the method, comprising:
The image of present frame is divided into multiple piecemeals;
The candidate motion vector of each piecemeal, the preset scanning sequency will be predicted according to preset scanning sequency
It include: that the image of the present frame is divided into more than one subgraph along horizontal direction;For the same subgraph,
The piecemeal for starting the first row of scanning uses from left to right and uses opposite scanning sequency between the piecemeal of adjacent rows;For phase
Two adjacent subgraphs, using the opposite scanning sequency of row scan sequence;
Optimum prediction motion vector is chosen from the candidate motion vector of each piecemeal;
Search obtains the motion vector of the image of present frame centered on the optimum prediction motion vector.
Optionally, the candidate motion vector, comprising: airspace candidate motion vector, time domain candidate motion vector, global fortune
Dynamic vector and zero motion vector.
It is optionally, described that optimum prediction motion vector is chosen from the candidate motion vector of each piecemeal, comprising:
Calculate the corresponding absolute difference of each candidate motion vector and, and by the fortune of each candidate motion vector and surrounding piecemeal
The product of difference and default weight coefficient between dynamic vector is as penalty term;
Corresponding absolute difference is chosen from the candidate motion vector field and is sweared with the smallest Candidate Motion of the sum of penalty term
Amount is used as the optimum prediction motion vector.
Optionally, the search centered on the optimum prediction motion vector obtains the movement arrow of the image of present frame
Amount, comprising:
Using with the distance between the optimum prediction motion vector for first distance 8 motion vectors as first group of fortune
Dynamic vector, using with the distance between the optimum prediction motion vector for second distance 8 motion vectors as second group of fortune
Dynamic vector;
Respectively to the corresponding absolute difference of each motion vector computation in first group of motion vector and second group of motion vector
With with penalty term;
Chosen from first group of motion vector and second group of motion vector respectively absolute difference and with the sum of penalty term most
Small motion vector is as first optimal motion vector sum the second optimal motion vector;
When determining the first optimal motion vector or the second optimal motion vector and the optimal motion vector
When identical, using the optimum prediction motion vector as the motion vector of the image of the present frame;
When determine the second optimal motion vector described in the first optimal motion vector sum with the optimal motion vector
It is not identical, and the second optimal motion vector described in the first optimal motion vector sum is located at the optimum prediction motion vector
When surface, underface, front-left or front-right, from a distance from the first optimal motion vector be the first distance
8 motion vectors in, in 5 motion vectors in addition to first group of motion vector, choose corresponding absolute difference and with
The smallest motion vector of the sum of penalty term is as third optimal motion vector, from a distance from the second optimal motion vector
In 5 motion vectors in 8 motion vectors of the second distance in addition to second group of motion vector, choose corresponding
Absolute difference and with the smallest motion vector of the sum of penalty term as the 4th optimal motion vector;
When determine the second optimal motion vector described in the first optimal motion vector sum with the optimal motion vector
It is not identical, and the second optimal motion vector described in the first optimal motion vector sum is non-positioned at the optimum prediction motion vector
Surface, underface, front-left or when front-right, from be at a distance from the first optimal motion vector described first away from
From 8 motion vectors in, chosen in 3 motion vectors in addition to first group of motion vector corresponding absolute difference and with
The smallest motion vector of the sum of penalty term as the third optimal motion vector, from the second optimal motion vector away from
From selection pair in 3 motion vectors in 8 motion vectors for the second distance in addition to second group of motion vector
The absolute difference answered and with the smallest motion vector of the sum of penalty term as the 4th optimal motion vector;
Chosen from the 4th optimal motion vector described in the third optimal motion vector sum absolute difference and with punishment
The sum of item motion vector of the lesser motion vector as the image of present frame.
Optionally, the first distance is 1, and the second distance is 3.
The embodiment of the invention also provides a kind of true motion estimation device, described device includes:
Blocking unit, suitable for the image of present frame is divided into multiple piecemeals;
Predicting unit, it is described suitable for will predict the candidate motion vector of each piecemeal according to preset scanning sequency
Preset scanning sequency includes: that the image of the present frame is divided into more than one subgraph along horizontal direction;It is right
In the same subgraph, the piecemeal for starting the first row of scanning is used from left to right and is used on the contrary between the piecemeal of adjacent rows
Scanning sequency;For two adjacent subgraphs, using the opposite scanning sequency of row scan sequence;
Selection unit, suitable for choosing optimum prediction motion vector from the candidate motion vector of each piecemeal;
Search unit, suitable for searching for the movement arrow for obtaining the image of present frame centered on the optimum prediction motion vector
Amount.
Optionally, the candidate motion vector, comprising: airspace candidate motion vector, time domain candidate motion vector, global fortune
Dynamic vector and zero motion vector.
Optionally, the selection unit be suitable for calculating the corresponding absolute difference of each candidate motion vector and, and by each time
Select the product of the difference and default weight coefficient between motion vector and the motion vector of surrounding piecemeal as penalty term;From described
Corresponding absolute difference is chosen in candidate motion vector field and with the smallest candidate motion vector of the sum of penalty term as described optimal
Predicted motion vector.
Optionally, described search unit is suitable for be first distance with the distance between the optimum prediction motion vector
8 motion vectors will be the 8 of second distance with the distance between the optimum prediction motion vector as first group of motion vector
A motion vector is as second group of motion vector;Respectively to each movement in first group of motion vector and second group of motion vector
Vector calculates corresponding absolute difference and and penalty term;It is chosen from first group of motion vector and second group of motion vector respectively
Absolute difference and with the smallest motion vector of the sum of penalty term as first optimal motion vector sum the second optimal motion vector;When true
It, will be described when the fixed first optimal motion vector or the second optimal motion vector identical as the optimal motion vector
Motion vector of the optimum prediction motion vector as the image of the present frame;When determining the first optimal motion vector sum institute
It is not identical as the optimal motion vector to state the second optimal motion vector, and second described in the first optimal motion vector sum
When optimal motion vector is located at surface, underface, front-left or the front-right of the optimum prediction motion vector, from institute
State the first optimal motion vector distance be the first distance 8 motion vectors in addition to first group of motion vector
5 motion vectors in, choose corresponding absolute difference and with the smallest motion vector of the sum of penalty term as third optimal motion
Vector, from a distance from the second optimal motion vector be the second distance 8 motion vectors in remove described second group
In 5 motion vectors except motion vector, choose corresponding absolute difference and with the smallest motion vector conduct of the sum of penalty term
4th optimal motion vector;When determine the second optimal motion vector described in the first optimal motion vector sum with it is described optimal
Motion vector is not identical, and the second optimal motion vector described in the first optimal motion vector sum is non-positioned at the optimum prediction
When the surface of motion vector, underface, front-left or front-right, from being institute at a distance from the first optimal motion vector
It states in 3 motion vectors in 8 motion vectors of first distance in addition to first group of motion vector, chooses corresponding exhausted
To difference and with the smallest motion vector of the sum of penalty term as the third optimal motion vector, from second optimal motion
The distance of vector is 3 motion vectors in 8 motion vectors of the second distance in addition to second group of motion vector
In, choose corresponding absolute difference and with the smallest motion vector of the sum of penalty term as the 4th optimal motion vector;
Chosen from the 4th optimal motion vector described in the third optimal motion vector sum absolute difference and with punishment
The sum of item motion vector of the lesser motion vector as the image of present frame.
Optionally, the first distance is 1, and the second distance is 3.
Compared with prior art, technical solution of the present invention has the advantage that
Above-mentioned scheme, when the piecemeal that the image to present frame divides is scanned, for the same subgraph,
The piecemeal for starting the first row of scanning uses from left to right and uses opposite scanning sequency between the piecemeal of adjacent rows;For phase
Two adjacent subgraphs, using the opposite scanning sequency of row scan sequence, in this way, both having existed under upper in same frame image
Scanning and scanning from left to right, there is also block scan sequences from bottom to up and from right to left, can be from four direction
Motion vector is restrained, therefore, convergent speed can be accelerated, and improve the accuracy of true motion estimation.
Further, when choosing optimum prediction motion vector in the candidate motion vector from each piecemeal of present frame,
Calculate corresponding absolute difference and on the basis of, increase the difference structure of the motion vector by the motion vector Yu surrounding piecemeal
At penalty term, it is ensured that the continuity of motion vector therefore can be with the accuracy of true motion estimation.
Further, in the motion vector for the image for obtaining present frame according to obtained optimum prediction motion-vector search
When, the motion vector of surrounding is scanned for centered on the optimum prediction motion vector, it can be to avoid due to optimal pre-
It surveys plus the problem that convergence rate caused by a random offset is slow on motion vector, it is thus possible to improve movement is convergent
Speed, and then improve the speed of true motion estimation.
Specific embodiment
To solve the above-mentioned problems in the prior art, technical solution used in the embodiment of the present invention passes through to former frame
The corresponding motion vector of mass center for multiple classes that the motion vector of each piecemeal of image is clustered is as present frame figure
The global motion vector of picture and output can save operand, and improve the accuracy for the global motion vector being calculated.
To make the above purposes, features and advantages of the invention more obvious and understandable, with reference to the accompanying drawing to the present invention
Specific embodiment be described in detail.
Fig. 1 shows the flow chart of one of embodiment of the present invention true motion estimation method.As shown in Figure 1 is true
Method for estimating may include:
Step S101: the image of present frame is divided into multiple piecemeals.
In specific implementation, the image of present frame can be divided into N*N nonoverlapping piecemeals.Wherein, N is positive whole
Number, and can be configured according to the actual needs.
Step S102: the candidate motion vector of each piecemeal is predicted according to preset scanning sequency.
In specific implementation, after obtaining each piecemeal, each piecemeal can be matched with reference frame, to measure in advance
To the candidate motion vector of each piecemeal.Wherein, when being matched each piecemeal with reference frame, the scanning of each piecemeal is suitable
Sequence, namely the sequence of the candidate vector of each piecemeal is predicted, the motion vector of each piecemeal is rapidly converged to really
Movement have important influence.
In an embodiment of the present invention, it in order to improve the convergent speed of prediction, can be predicted using following scanning sequencies
Obtain the motion vector of each piecemeal:
It is possible, firstly, to which the image of present frame is divided into several subgraphs along horizontal direction.Wherein, to current
When the image of frame carries out the division of subgraph, the number of the subgraph divided can be configured according to the actual needs, example
It such as, is 1,2,4 etc..When the image of present frame to be divided into 2 or more subgraphs, due to the size of on piece memory capacity
It is directly proportional to the width of subgraph to be processed, therefore, it is possible to reduce the memory capacity of required on piece.
But it is to be herein pointed out the same piecemeal can only belong to a subgraph when carrying out the division of subgraph
Picture, and the different piece of a piecemeal cannot be divided into different subgraphs.
After division obtains corresponding subgraph, for the same subgraph, the piecemeal for starting the first row of scanning is adopted
With using opposite scanning sequency from left to right and between the piecemeal of adjacent rows;For two adjacent subgraphs, swept using row
Retouch the opposite scanning sequency of sequence.Wherein, row scan sequence here refers to, the scanning between row and row in vertical direction
Sequentially.For example, one of subgraph can be suitable using row scanning from top to bottom for two adjacent subgraphs
Sequence, and another subgraph can be using row scan sequence from bottom to up.
For example, shown in Figure 2, for the subgraph 201 on 200 left side of dotted line, using under upper and with a line
Piecemeal is scanned using sequence from left to right, for the subgraph 202 on 200 the right of dotted line, then using from bottom to up and together
The piecemeal of a line is scanned using sequence from right to left.Meanwhile subgraph 201 and subgraph 200 start the first of scanning
The scanning direction of capable piecemeal is identical, i.e., from left to right.Certainly, the scanning between adjacent subgraph 201 and subgraph 202 is suitable
Sequence also can be interchanged, as long as the scanning sequency of the piecemeal of the first row is from left to right when scanning.
Above-mentioned scanning sequency also has so that both there is scanning from top to bottom and from left to right in the image of present frame
Scanning from bottom to up and from right to left can allow motion vector to restrain along four direction up and down in this way, because
This, can be improved the convergence rate of motion vector, and then promote the speed of true motion estimation.
In specific implementation, candidate described in the motion vector of each piecemeal obtained according to above-mentioned scanning sequency prediction transports
Dynamic vector C may include the airspace candidate motion vector C of corresponding sub-blockS, time domain candidate motion vector CT, global motion vector CG
With zero motion vector C0, it may be assumed that
C={ CS, CT, CG, C0} (1)
Wherein, it is expert at current block using from left to right, subgraph where current block is using row scanning from top to bottom
For sequence, zero motion vector C0For detecting static scene;Global motion vector CGFor improving the piecemeal of current block and surrounding
The inconsistent situation of movement;Airspace candidate motion vector CS, completed around estimation using in same image
The motion vector of block, it may be assumed that
Time domain candidate motion vector CT, using the motion vector of the piecemeal around current block in previous frame image, it may be assumed that
Step S103: optimum prediction motion vector is chosen from the candidate motion vector of each piecemeal.
It in specific implementation, can be by the way of certain from each after obtaining the candidate motion vector of each piecemeal
Optimal motion vector is chosen in the candidate motion vector of a piecemeal.
In an embodiment of the present invention, can calculate first the corresponding absolute difference of candidate motion vector of each piecemeal with and
The sum of penalty term, it may be assumed that
Wherein, E indicate the corresponding absolute difference of the candidate motion vector of current piecemeal with and the sum of penalty term, SAD (fc(x),
fr(x+MVp)) indicate the corresponding absolute difference that the reference position being directed toward using the candidate motion vector of current piecemeal is calculated
With λ ∑i∈C||MVi-MVp| | indicate that the corresponding penalty term of the candidate motion vector of current piecemeal (can also be using other names
Claim, such as compensation term, adjustment item), i.e., multiply with the difference of the candidate motion vector of the piecemeal of surrounding and preset weight coefficient
Product.Wherein, the weight coefficient λ that sets can change with each piecemeal, or fixed numerical value, the present invention to this not
It is restricted.
In specific implementation, as the corresponding E of the candidate motion vector that each piecemeal is calculated using formula (4), just
The candidate vector of the smallest piecemeal of E value can therefrom be chosen as the optimum prediction candidate vector, it may be assumed that
Wherein, MVpredIndicate the optimum prediction candidate motion vector.
It is to be herein pointed out can also be transported using others modes from the candidate of each piecemeal of the image of present frame
Optimum prediction motion vector is chosen in dynamic vector, those skilled in the art can select according to the actual needs, herein
With no restrictions.
Step S104: search obtains the motion vector of the image of present frame centered on the optimum prediction motion vector.
In specific implementation, when selection optimum prediction motion vector in the candidate motion vector from each piecemeal of present frame
When, centered on the optimum prediction motion vector, by the motion vector searched for around the optimum prediction motion vector, and
Finally obtain the motion vector of the image of present frame.
Below in conjunction with Fig. 3 to search obtains and works as centered on the optimum prediction motion vector in the embodiment of the present invention
The process of the motion vector of the image of previous frame is further described in detail.
Step S301: the distance between search and the optimum prediction motion vector are 8 motion vectors of first distance
As first group of motion vector.
In specific implementation, it is assumed that first distance d, optimum prediction motion vector are (X, Y), then, with optimum prediction
Motion vector is that 8 motion vectors that the distance of (X, Y) is first distance d can be expressed as (X ± d, Y ± d).
Step S302: the first optimal motion vector is chosen from first group of motion vector.
In specific implementation, it can equally be chosen from first group of motion vector using formula (4) corresponding absolute
Difference and with the smallest motion vector of the sum of penalty term as the first optimal motion vector.
Step S303: judge whether the first optimal motion vector is identical as the optimum prediction motion vector;When sentencing
Disconnected result is when being, step S304 can be executed, conversely, can then execute step S305.
Step S304: it is exported the optimum prediction motion vector as the motion vector of the image of present frame.
In specific implementation, when determining that the first optimal motion vector is identical as the optimum prediction motion vector namely two
When person is overlapped, it can be exported the optimum prediction motion vector as the motion vector of the image of present frame.
Step S305: judge the first optimal motion vector whether be located at the optimum prediction motion vector just on
Side, underface, front-left or front-right;When the judgment result is yes, step S306 can be executed;Conversely, can then execute
Step S307.
In specific implementation, when judging that the first optimal motion vector is not overlapped with the optimum prediction motion vector
When, it can be determined that whether the first optimal motion vector is located at the surface of the optimum prediction motion vector, underface, just
Left or front-right.
Step S306: from the distance between the first optimal motion vector in 8 motion vectors of first distance,
In 5 motion vectors in addition to the motion vector in first motion vector set, third optimal motion vector is chosen.
In specific implementation, when determine the first optimal motion vector be located at the optimum prediction motion vector just on
It, can be from being first distance and non-at a distance from the first optimal motion vector when side, underface, front-left or front-right
In 5 motion vectors in first motion vector set, choose corresponding absolute difference and with the smallest movement of the sum of penalty term
Vector, as the second optimal motion vector.
Step S307: from the distance between the first optimal motion vector in 8 motion vectors of first distance,
In 3 motion vectors in addition to the motion vector in first motion vector set, the third optimal motion vector is chosen.
In specific implementation, when determining that the first optimal motion vector is not located at the optimum prediction motion vector
When surface, underface, front-left or front-right, can from a distance from the first optimal motion vector be first distance
And in 3 motion vectors of non-first motion vector set, choose corresponding absolute difference and with the smallest fortune of the sum of penalty term
Dynamic vector, as the second optimal motion vector.
While executing above-mentioned step S301~step S307, following step S308~step S315 is executed:
Step S308: the distance between search and the optimum prediction motion vector are 8 motion vectors of second distance
As second group of motion vector.
Step S309: the second optimal motion vector is chosen from second group of motion vector.
Step S310: judge whether the second optimal motion vector is identical as the optimum prediction motion vector;When sentencing
Disconnected result is when being, step S304 can be executed, conversely, can then execute step S305.
Step S311: it is exported the optimum prediction motion vector as the motion vector of the image of present frame.
Step S312: judge the second optimal motion vector whether be located at the optimum prediction motion vector just on
Side, underface, front-left or front-right;When the judgment result is yes, step S313 can be executed;Conversely, can then execute
Step S314.
Step S313: from the distance between the second optimal motion vector in 8 motion vectors of second distance,
In 5 motion vectors in addition to the motion vector in second motion vector set, the 4th optimal motion vector is chosen.
Step S314: from the distance between the second optimal motion vector in 8 motion vectors of second distance,
In 3 motion vectors in addition to the motion vector in second motion vector set, the 4th optimal motion vector is chosen.
It is to be herein pointed out step S308~step S314 and step S301~step S307 execute one-to-one correspondence,
And the treatment process of corresponding step is similar, this will not be repeated here.
Step S315: the absolute difference is chosen from the 4th candidate motion vector described in the third optimal motion vector sum
With the motion vector with the lesser motion vector of the sum of penalty term as the image of present frame.
It in specific implementation, can be from the two when obtaining third optimal motion the 4th optimal motion vector of vector sum
Choosing matching degree is higher used as the motion vector of the image of present frame to be exported.
In an embodiment of the present invention, the movement arrow of third optimal motion vector the 4th can be equally calculated using formula (4)
Corresponding E is measured, and therefrom chooses the corresponding third optimal motion vector of smaller E value or the 4th optimal motion vector as current
The motion vector memory of the image of frame exports.
In an embodiment of the present invention, the first distance is 1, and the second distance is 3.
Fig. 4 shows the structural schematic diagram of one of embodiment of the present invention true motion estimation device.As shown in Figure 4
True motion estimation device 400, may include blocking unit 401, predicting unit 402, selection unit 403 and search unit 404,
Wherein:
Blocking unit 401, suitable for the image of present frame is divided into multiple piecemeals.
Predicting unit 402, suitable for will predict the candidate motion vector of each piecemeal, institute according to preset scanning sequency
Stating preset scanning sequency includes: that the image of the present frame is divided into more than one subgraph along horizontal direction;
For the same subgraph, the piecemeal for starting the first row of scanning is opposite using using from left to right and between the piecemeal of adjacent rows
Scanning sequency;For two adjacent subgraphs, using the opposite scanning sequency of row scan sequence.
In specific implementation, the candidate motion vector may include: airspace candidate motion vector, time domain Candidate Motion arrow
Amount, global motion vector and zero motion vector.
Selection unit 403, suitable for choosing optimum prediction motion vector from the candidate motion vector of each piecemeal.
In specific implementation, the selection unit 403 be suitable for calculating the corresponding absolute difference of each candidate motion vector and, and
Using the product of difference and default weight coefficient between each candidate motion vector and the motion vector of surrounding piecemeal as punishment
?;Chosen from the candidate motion vector field corresponding absolute difference and with the smallest candidate motion vector conduct of the sum of penalty term
The optimum prediction motion vector.
Search unit 404, suitable for searching for the fortune for obtaining the image of present frame centered on the optimum prediction motion vector
Dynamic vector.
In specific implementation, described search unit 404 be suitable for will be with the distance between the optimum prediction motion vector
8 motion vectors of first distance will be with the distance between the optimum prediction motion vector as first group of motion vector
8 motion vectors of second distance are as second group of motion vector;Respectively to first group of motion vector and second group of motion vector
In the corresponding absolute difference of each motion vector computation and and penalty term;Respectively from first group of motion vector and second group of fortune
Absolute difference and optimal as the first optimal motion vector sum second with the smallest motion vector of the sum of penalty term is chosen in dynamic vector
Motion vector;When determining the first optimal motion vector or the second optimal motion vector and the optimal motion vector
When identical, using the optimum prediction motion vector as the motion vector of the image of the present frame;When determining described first most
Excellent motion vector and the second optimal motion vector be not identical as the optimal motion vector, and first optimal motion
Second optimal motion vector described in vector sum be located at the surface of the optimum prediction motion vector, underface, front-left or
When front-right, from be at a distance from the first optimal motion vector the first distance 8 motion vectors in except described the
In 5 motion vectors except one group of motion vector, choose corresponding absolute difference and with the smallest motion vector of the sum of penalty term
As third optimal motion vector, sweared from 8 movements at a distance from the second optimal motion vector being the second distance
In 5 motion vectors in amount in addition to second group of motion vector, choose corresponding absolute difference and with the sum of penalty term most
Small motion vector is as the 4th optimal motion vector;When determining the second optimal motion described in the first optimal motion vector sum
Vector is not identical as the optimal motion vector, and the second optimal motion vector described in the first optimal motion vector sum is non-
When positioned at the surface of the optimum prediction motion vector, underface, front-left or front-right, from the described first optimal fortune
The distance of dynamic vector is 3 movements arrow in 8 motion vectors of the first distance in addition to first group of motion vector
In amount, corresponding absolute difference is chosen and with the smallest motion vector of the sum of penalty term as the third optimal motion vector, from
With at a distance from the second optimal motion vector be the second distance 8 motion vectors in remove second group of motion vector
Except 3 motion vectors in, choose corresponding absolute difference and optimal as the 4th with the smallest motion vector of the sum of penalty term
Motion vector;Chosen from the 4th optimal motion vector described in the third optimal motion vector sum absolute difference and with punishment
The sum of item motion vector of the lesser motion vector as the image of present frame.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of above-described embodiment is can
It is completed with instructing relevant hardware by program, which can store in computer readable storage medium, and storage is situated between
Matter may include: ROM, RAM, disk or CD etc..
The method and system of the embodiment of the present invention are had been described in detail above, the present invention is not limited thereto.Any
Field technical staff can make various changes or modifications without departing from the spirit and scope of the present invention, therefore guarantor of the invention
Shield range should be defined by the scope defined by the claims..