The present invention relates to image processing, more particularly, to a motion estimation method for rapidly and accurately calculating motion vectors.
Motion estimation (ME) is a technique used in image compression, image recognition or the like to improve the frame rate of video. By using ME, a motion vector (MV) for a specific block between two frames can be estimated, so as to eliminate temporal redundancy between frames of a moving image and thereby improving image quality.
For image encoding using ME, it is not necessary that the motion vectors of the respective blocks of a frame are all correct. However, for frame rate up-conversion (FRC), the MV of each block of a frame must be correct so that the moving image can be smoothly displayed.
In the recent years, as liquid crystal screens have been widely used, FRC technique becomes important. FRC technique is to increase the frame rate of video so as to eliminate motion blur and movie film judder. By using FRC, the frame rate of the original video of film can be raised from 60 Hz to 120 Hz or even to 240 Hz, for example. To achieve the high frame rate, additional frames must be calculated. As mentioned, correct motion vectors between the original frames can be calculated by using motion estimation. The additional frames are interpolated between the original frames by using the motion vectors.
In order to rapidly and correctly estimate the motion vectors between the original frames, dynamic search range is applied in motion estimation so that the high resolution video encoding can be done in real time. Dynamic search range can also be applied in FRC to save calculation time and cost.
BlockMVE→BlockMVA,BlockMVB,BlockMVC,BlockMVD (1)
MVmX=max{abs(MVAX),abs(MVBX),abs(MVCX),abs(MVDX)} (2)
MVmY=max{abs(MVAY),abs(MVBY),abs(MVCY),abs(MVDY)} (3)
Sometimes the search range is slightly extended by δ:
Search range of MVEX=MVmX+δ (4); and
Search range of MVEY=MVmY+δ (5).
When the motion vector of the current block is quite different from those of the periphery blocks, an error may occur in the motion estimation.
An objective of the present invention is to provide a hierarchical motion estimation method. The motion estimation is implemented in a plurality of levels. By using such a method, the motion vectors of a frame can be rapidly and accurately estimated.
In accordance with the present invention, the hierarchical motion estimation method is used for estimating motion vectors of a frame. The frame being partitioned into blocks at a first level, and each block of the first level is partitioned into a plurality of blocks at a second level. The method includes selecting reference blocks at the first level for a specific block at the second level; and determining a search range for the specific block at the second level by referring to motion vectors of the reference blocks at the first level. Before these steps, motion vectors of the reference blocks at the first level have been estimated with a first resolution.
If the first level is the lowest level in this method, that is, no previous level having with known motion vectors can be referred to, the motion vectors of the blocks of the first level are estimated by using a full search range with the first resolution.
After the search range for the specific block at the second level is determined, a motion vector of the specific block is estimated by using the determined search range with a second resolution. The second resolution is higher than the first resolution. In an embodiment of the present invention, the first resolution is one-quarter of the second resolution.
The present invention will be described in detail in conjunction with the appending drawings, in which:
The present invention provides a hierarchical motion estimating method.
According to this method, the motion estimation is executed by a plurality of levels. At the lowest level, a whole frame is coarsely partitioned into big blocks. For a block of the lowest level, a motion vector thereof is calculated by a full search range with a low resolution. Therefore, the actual search range of the lowest level is limited since the resolution is very low.
For a case in which the motion estimation is executed by three levels as shown in
For example, for a 1366×768 frame, a search range denoted in X-direction and Y-direction (±32, ±18) for the conventional full search is required. If the motion estimation is executed by three levels as shown in
The motion estimation for the second level (i.e. Level1) is executed with a higher resolution 683×384 with the maximum search range (±16, ±9). At the second level Level1, each block of the first level is further partitioned into four blocks. A dynamic search range of the second level Level1 for every block is determined based on the motion vectors estimated at the lowest level (i.e. Level2). It is noted that the dynamic search range should not exceed the maximum search range determined in the beginning as mentioned above. At the highest level (i.e. the third level Level0), the dynamic search range of each block is determined based on the motion vectors estimated at Level1, and the maximum search range is set as (±32, ±18), which is the normal resolution.
At Levelk-1, each block of the frame 10 is further partitioned into four blocks. That is, the whole frame 10 is partitioned into 36 blocks at Levelk-1. For example, the block E is partitioned into four blocks a to d. For the current block a (i.e. the block at the third row and the third column), the motion vector MVk-1(3, 3) is estimated by searching, and the dynamic search range is determined by referring to the motion vectors of the relevant blocks at the previous level, Levelk. In the present application, the search range (SR) for estimating the motion vector of block a at Levelk-1 can be determined by referring to the motion vectors of the closest four blocks at Levelk, including the corresponding block (i.e. the block E at coordinate (2, 2)), the adjacent blocks (i.e. the blocks D and B at coordinates (2, 1) and (1, 2)) and the diagonal block (i.e. the block A at coordinate (1, 1)) at Levelk. This can be expressed as:
SRk-1(x,y)→MVk(x1,y1),MVk(x2,y2),MVk(x3,y3),MVk(x4,y4) (6)
wherein a coordinate of the specific block of the current level is (x, y); the four reference blocks respectively have coordinates (x1, y1), (x2, y2), (x3, y3) and (x4, y4) at the previous level, x1 to x4 and y1 to y4 are determined according to expressions of:
Δx=−2*(x MOD 2)+1 and Δy=−2*(y MOD 2)+1 (7)
x
1
=[x/2],y1=[y/2] (8),
wherein “[ ]” means a ceiling function, and “MOD” means a modulo operation.
x
2
=[x/2]+Δx,y2=[y/2] (9).
x
3
=[x/2],y3=[y/2]+Δy (10).
x
4
=[x/2]+Δx,y4=[y/2]+Δy (11).
As can be derived from the above expressions, for the block a at Levelk-1, x=3 and y=3, the search range SRk-1(3, 3) of the block a can be determined by referring to the motion vectors of the blocks A, B, D, E, which can be expressed as:
SRk-1(3,3)→MVk(2,2),MVk(1,2),MVk(2,1),MVk(1,1) (12)
According to the present invention, the search range SRa (i.e. SRk-1(3, 3)) of the block a is determined by the maximum X-direction MV component MVmX and the maximum Y-direction MV component MVmY.
MVmX=max{abs(3),abs(1),abs(1),abs(1)}=3 (13)
MVmY=max{abs(1),abs(0),abs(0),abs(−1)}=1 (14)
In the present embodiment, the resolution of Levelk is ¼ of that of Levelk-1. That is, a sampling rate for Levelk is ¼ of that for Levelk-1. Therefore, to calculate the dynamic search range SR, each maximum MV component should be multiplied by two. Furthermore, the search range can be slightly extended by δ, which can be zero or positive integer, in each dimension. In the present embodiment, δ is chosen as 1, therefore, the search range in X-direction SRaX and the search range in Y-direction SRaY for the block a are:
SRaX=3×2+δ=3×2+1=7 (15)
SRaY=1×2+δ=1×2+1=3 (16)
That is, for the block a, the dynamic search range is ±7 in X-direction, and is ±3 in Y-direction. Therefore, there will be 105 blocks to be compared ((14+1)×(6+1)=105). The full search range SRaf for the block a is (±16, ±9), resulting in 627 blocks to be compared. By using the method of the present invention in this case, 83.2% comparing time can be saved.
Since correct motion vectors of the blocks A to I of Levelk can be obtained, the search range with a correct trend for each block of Levelk-1 can be effectively determined based on the motion vectors of Levelk. As described, the dynamic search range SRa of the block a at Levelk-1 is determined by referring to the motion vectors of the blocks A, B, D and E at Levelk. Similarly, a dynamic search range SRb of the block b at Levelk-1 is determined by referring to the motion vectors of the blocks B, C, E and F at Levelk. A dynamic search range SRc of the block c at Levelk-1 is determined by referring to the motion vectors of the blocks D, E, G and H at Levelk. A dynamic search range SRd of the block d at Levelk-1 is determined by referring to the motion vectors of the blocks E, F, H and I at Levelk. For obtaining a more accurate motion vector, the dynamic search range can be slightly extended by a factor δ, which is zero or a positive integer, in each dimension. When δ equals to zero, it means that the search range is not extended outward.
The method described above will be summed up with reference to
The motion estimation implemented with the dynamic search range will be further described with reference to
At step S108, the maximum motion vector components in X-direction and Y-direction among the reference blocks that are from step S106 are determined as:
MVmX=max{abs(4_block_MVX)} (17)
MVmY=max{abs(4_block_MVY)} (18)
At step S110, the dynamic search range for the selected block to be estimated is determined by using the maximum MV components of the reference blocks. The dynamic search range SR thereof is determined as magnitudes in X-direction and Y-direction, which can be indicated by SRX and SRY as follows:
SRX=MVmX×2+δ (19)
SRY=MVmY×2+δ (20)
As mentioned, the maximum MV components of the reference blocks of the previous level should be respectively multiplied by two when calculating the dynamic search range since the resolution of the previous level is ¼ of that of the current level.
At step S112 and step S116, it is checked if the dynamic search range magnitudes in X-direction and Y-direction SRX and SRY exceed thresholds max_SRX and max_SRY, respectively. The thresholds max_SRX and max_SRY are derived from the maximum search range determined in the beginning as described above. If the dynamic search range value SRX exceeds the threshold max_SRX, then the dynamic search value SRX is set as the threshold max_SRX (step S114). If the dynamic search range value SRY exceeds the threshold max_SRY, then the dynamic search value SRY is set as the threshold max_SRY (step S118). That is, the dynamic search range (±SRX, ±SRY) is forced to be equal to a maximum search range (±max_SRX, ±max_SRY), which is determined based on the resolution of the current level, when the determined dynamic search range exceeds the maximum search range. If the dynamic search range values do not exceed the thresholds, at step S120, then block matching is executed in the determined dynamic search range for the selected current block. That is, the motion vector of the selected current block is estimated by using a cost function, which can be an MSE (mean square error), SAD (sum of absolute difference) function or the like, within the determined dynamic search range. At step S122, the best estimated motion vector of the current block is stored, and the process returns to step S104 to estimate the motion vector of a next block.
While the preferred embodiments of the present invention have been illustrated and described in detail, various modifications and alterations can be made by persons skilled in this art. The embodiment of the present invention is therefore described in an illustrative but not restrictive sense. It is intended that the present invention should not be limited to the particular forms as illustrated, and that all modifications and alterations which maintain the spirit and realm of the present invention are within the scope as defined in the appended claims.