Background technology
In digital picture and Video processing, the zoom operations of image is the process of computing relative complex, and this is because need image is carried out interpolation operation in the convergent-divergent process of image.The interpolation method that adopts in the existing image zoom mainly contains following several: proximity method, bilinear interpolation and bicubic spline (Bi-Cubic) interpolation, wherein the Bi-Cubic interpolation is extensively paid attention to its good interpolation.
Utilize the process of Bi-Cubic interpolation method zoomed image as follows:
If the original image before the convergent-divergent be f (x, y), size be M * N, pass through scaled images and be f ' (x, y), size is M ' * N ', wherein f (x, y) and f ' (x y) distinguishes presentation video in (x, y) pixel value of position.Then in the image zoom process, f ' (x, y) in (i ', j ') position picture element pixel value can by this picture element original image f (x, y) in corresponding point (x, y) pixel value of picture element is on every side represented.Wherein, original image f (x, y) coordinate in (x, image f ' y) and behind the convergent-divergent (x, y) coordinate in (i ', j ') satisfies:
x=i′M/M′ (1)
y=j′N/N′ (2)
Be that i ', j ' obtain x, y divided by the scaling of horizontal direction and vertical direction respectively.
Suppose
Be i, j is respectively x, and y rounds downwards.Dx=x-i is arranged so, dy=y-j, dx then, dy ∈ [0,1), and be floating number.As shown in Figure 1, in the Bi-Cubic interpolation, relate to (i, the picture element of the original image of 4 * 4 around j) is numbered these 16 picture elements by m and n, and wherein m and n are integer, and m, n ∈ [1,2].
Image f ' behind the convergent-divergent (x, y) in the pixel value of (i ', j ') point just can calculate by the pixel value of these 16 picture elements, computing formula is:
The value of weighting coefficient R (x) is obtained by following formula in the following formula:
Wherein
After calculating the pixel value f ' (i ', j ') of each picture element of image behind the convergent-divergent, just obtained image behind the convergent-divergent, then can output to image behind the convergent-divergent on the display screen or carry out other operation.
From technique scheme as can be seen, (x y) during the pixel value of each picture element, will repeatedly calculate weighting coefficient R (x) to image f ' after using formula (3) is asked convergent-divergent, and calculate weighting coefficient R (x) all needs to carry out repeatedly three cubed calculating at every turn, and computation complexity is very high.And what use in the prior art is floating-point operation, if and embedded system in digital camera and the first-class equipment of shooting and hardware are realized such floating-point operation, be difficult to satisfy the requirement that system handles image in real time, the occasion especially big, that video frame rate is had relatively high expectations in picture size.
Summary of the invention
In view of this, the present invention proposes a kind of method of image zoom, its purpose is to reduce computation complexity, improves the speed of image zoom.
According to above-mentioned purpose, the invention provides a kind of method of image zoom, it is characterized in that this method may further comprise the steps:
A. the point of the adjacent image point on the original image horizontal direction is divided into integer u equal portions, at independent variable calculated level weighted direction coefficient and in, and set up horizontal direction weighting coefficient look-up table according to described independent variable and corresponding horizontal direction weighting coefficient smaller or equal to the scope of u*2 greater than-u*2;
Adjacent image point on original image vertical direction point is divided into integer v equal portions, calculate the vertical direction weighting coefficient more than or equal to-v*2 and at independent variable, and set up vertical direction weighting coefficient look-up table according to described independent variable and corresponding vertical direction weighting coefficient less than the scope of v*2;
B. the corresponding point of each picture element in original image behind definite convergent-divergent in the image, in above-mentioned horizontal direction weighting coefficient look-up table, search corresponding horizontal direction weighting coefficient according to the horizontal direction coordinate figure of described corresponding point, in above-mentioned vertical direction weighting coefficient look-up table, search corresponding vertical direction weighting coefficient according to the vertical direction coordinate figure of described corresponding point;
C. calculate behind the described convergent-divergent pixel value of picture element in the image according to the pixel value of picture element around the described corresponding point and described horizontal direction weighting coefficient and vertical direction weighting coefficient, obtain image behind the convergent-divergent.
Described integer u is 2 index; In step C, comprise: realize in the described calculating division u with the method for shifting function.
Described integer v is 2 index, comprises in step C: realize in the described calculating division to u with the method for shifting function.
The step of determining the corresponding point of each picture element in original image in the image behind the convergent-divergent described in the step B comprises: the horizontal direction coordinate figure that calculates corresponding point in the described original image according to the horizontal direction coordinate figure and the horizontal direction scaling of picture element in the image behind the described convergent-divergent; The vertical direction coordinate figure that calculates corresponding point in the described original image according to the vertical direction coordinate figure and the vertical direction scaling of picture element in the image behind the described convergent-divergent; Horizontal direction coordinate figure and vertical direction coordinate figure according to described corresponding point are determined corresponding point.
Search before the weighting coefficient according to the horizontal direction coordinate of corresponding point and vertical direction coordinate described in the step B, further comprise: the corresponding point in the described original image are navigated on the minimum net point of distance, and with this net point as corresponding point.
The described step that corresponding point in the original image are navigated on the minimum net point of distance comprises: the horizontal direction coordinate figure according to described corresponding point obtains a horizontal direction net point coordinate figure by rounding method; Vertical direction coordinate figure according to described corresponding point obtains a vertical direction net point coordinate figure by rounding method; Determine and the net point of described corresponding point according to described horizontal direction net point coordinate figure and vertical direction net point coordinate figure apart from minimum.
When described integer u equaled integer v, the weighting coefficient of horizontal direction described in step B look-up table was identical with vertical direction weighting coefficient look-up table, and independent variable is in more than or equal to-u*2 and the scope smaller or equal to u*2; Described step C is: determine the corresponding point of each picture element in original image in the image behind the convergent-divergent, in above-mentioned weighting coefficient look-up table, search corresponding horizontal direction weighting coefficient according to the horizontal direction coordinate figure of described corresponding point, in above-mentioned weighting coefficient look-up table, search corresponding vertical direction weighting coefficient according to the vertical direction coordinate figure of described corresponding point.
From such scheme as can be seen, because the present invention is divided into the u equal portions with original image horizontal direction adjacent image point point, vertical direction adjacent image point point is divided into the v equal portions, obtained the grid of segmentation, calculate-(u*2)<x≤(u*2) and-(v*2)≤y<(v*2) horizontal direction weighting coefficient R (x) and vertical direction weighting coefficient R (y), set up horizontal direction weighting coefficient look-up table and vertical direction weighting coefficient look-up table, only need just can obtain when in image zoom, calculating each weighting coefficient R (x) and R (y) by tabling look-up, do not need repeatedly double counting, reduce the complexity of calculating, improved computing velocity.And argument of function can be integer among the present invention, and like this, what adopt in the computation process is integer arithmetic rather than floating-point operation, has also reduced the complexity of calculating, and has improved computing velocity.When the value of u and v is 2 index, can simplify division arithmetic in the computation process with shifting function, further improved computing velocity.To sum up, the present invention has reduced the computation complexity in the image zoom process, has improved computing velocity, thereby has improved the speed of image zoom, has satisfied the requirement that system handles image in real time.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in more detail by the following examples.
If the original image before the convergent-divergent is that (x, y), size is M * N to f, is that (x, y), size is M ' * N ' to f ' through scaled images.In the image zoom process, at f ' (x, y) pixel value of picture element (i ', j ') can be by this picture element at f (x, y) corresponding point (x in, y) pixel value of picture element is on every side represented, and image f ' behind the convergent-divergent (x, y) in picture element (i ', j ') coordinate and it is at original image f (x, y) (x, coordinate y) satisfies corresponding point in: x=i ' M/M ' and y=j ' N/N '.
Suppose
Be i, j is respectively x, and y rounds downwards.Dx=x-i so, dy=y-j, dx then, dy ∈ [0,1), and be floating number.As shown in Figure 1, in the Bi-Cubic interpolation, relate to (i, the original image picture element of 4 * 4 around j) is numbered these 16 picture elements by m and n, and wherein m and n are integer, and m, n ∈ [1,2].
Image f ' behind the convergent-divergent (x, y) in the pixel value of (i ', j ') point just can calculate by the pixel value of these 16 picture elements, computing formula is formula (3).
Know that from formula (3) in interpolation process, weighting coefficient R (x) is respectively m-dx, dy-n with the independent variable of vertical direction in the horizontal direction, and dx, dy ∈ [0,1), m, n ∈ [1,2], according to the data constraint relation as can be known:
-2<m-dx≤2 (5)
-2≤dy-n<2 (6)
As seen, for R (x), its independent variable x ∈ [2,2].
The present invention with between original image horizontal direction adjacent image point and the distance between the vertical direction adjacent image point be divided into u, a v segmentation respectively.As shown in Figure 2 grid configuration is carried out forming after the segmentation to it in the zone that constitutes for adjacent four picture elements in the original image.If corresponding point are the point on the grid then calculate as corresponding point with this net point; If corresponding point not on grid, then navigate to these corresponding point on the minimum net point of distance by rounding method, calculate as corresponding point with this net point.Though can reduce the precision of interpolation calculation so to a certain extent, in the image zoom process, might not need original precision, the present invention has reached a kind of balance between the two in the complexity of precision and calculating.As can be seen, when u and v were big more, the gap of the present invention and prior art precision was just more little.
Suppose with the net point among Fig. 2 (s, t) as corresponding point, obviously s, t here is integer, and 0≤s<u is arranged, 0≤t<v, then dx, the dy in formula (5) and (6) is: dx=s/u, dy=t/v, thereby formula (5) and (6) become:
-(u*2)<u*m-s≤(u*2) (7)
-(v*2)≤t-v*n<(v*2) (8)
Here the independent variable u*m-s of weighting coefficient R (x) and t-v*n can be integer, owing to compare with floating-point operation, integer arithmetic has lower computational complexity, therefore can take integer arithmetic in following computation process.
Compare formula (5), (6) and formula (7), (8), the independent variable interval of the function R among the present invention (x) has enlarged as can be seen, has enlarged u in the horizontal direction doubly, has enlarged v doubly in vertical direction, so formula (4) also will make corresponding changes, weighting coefficient so in the horizontal direction is
Weighting coefficient in vertical direction is
Wherein
After having determined u and v, make up two one dimension look-up tables: horizontal direction weighting coefficient look-up table SearchTableX (x) and vertical direction weighting coefficient look-up table SearchtableY (y).Promptly by formula (9), for whole 4*u points among the variation range of independent variable wherein-(u*2)<u*m-s≤(u*2) respectively values calculate, and the result is saved among the look-up table SearchTableX (x), the length of this look-up table is 4*u, with the independent variable of R (x) as allocation index.Equally, by formula (10), for whole 4*v points among the variation range of independent variable wherein-(v*2)≤t-v*n<(v*2) respectively values calculate, and the result is saved among the look-up table SearchTableY (y), the length of this look-up table is 4*v, with the independent variable of R (y) as allocation index.
In addition because the expression form of R (x), R (y) is basic identical, if u equate with v, then can only generate a look-up table, promptly pass through definite x, the value of y, in this look-up table, search corresponding R (x), R (y).When generating this look-up table, the span of independent variable should comprise the span of horizontal direction independent variable and the span of vertical direction independent variable, this span is-(u*2)≤x≤(u*2), so the length of this look-up table is (4*u+1).
When carrying out interpolation calculation at every turn, with corresponding point (x, y) navigate to the minimum net point of distance (s, t) on, (s t) calculates as corresponding point with net point then.For horizontal direction weighting coefficient R (x), only x need be navigated on the minimum net point horizontal coordinate s of distance by rounding method, promptly get x=u*m-s, the list item of searching the relevant position according to x in look-up table SearchTableX (x) just can obtain the value of R (x) then, makes that horizontal direction weighting coefficient R (x) is R
1(x), then have:
R
1(x)=SearchTableX(x)。
For vertical direction weighting coefficient R (y), equally y is navigated on the minimum net point vertical coordinate t of distance by rounding method, promptly get y=t-v*n, the list item of searching the relevant position according to y in look-up table SearchTableY (y) just can obtain the value of R (y) then, makes that vertical direction weighting coefficient R (y) is R
2(y), then have:
R
2(y)=SearchTableY(y)。
Certainly, also can (x, y) coordinate figure x, y search weighting coefficient in the weighting coefficient look-up table, and corresponding point are not navigated on the minimum net point of distance earlier before tabling look-up according to corresponding point.With x=1.6 is example, it is 1 and 2 o'clock R (1) value and R (2) value that independent variable is arranged in the weighting coefficient look-up table in the horizontal direction, in look-up table, obtain an approximate weighting coefficient according to x=1.6 so, as with the value of R (2) weighting coefficient as x=1.6, the calculating below continuing then.This method is especially suitable, and (x is y) from the situation on net point with corresponding point.
Look-up table among the present invention is a global table, parameters u and the definite back of v in zoom operations just can be set up, all adopt the value of in above-mentioned look-up table, searching weighting coefficient R (x) and R (y) in the image zoom operation of back, thereby significantly reduced the calculated amount in the interpolation calculation.
After calculating the value of weighting coefficient R (x), its substitution formula (3) is calculated the pixel value f ' in the image behind convergent-divergent (i ', j ').Compared with formula (4) in formula (9), (10), formula (9) and (10) have been distinguished than the result of formula (4) and have been enlarged u as can be seen
3Doubly and v
3Doubly, so formula (3) becomes:
After calculating the pixel value f ' (i ', j ') of each picture element of image behind the convergent-divergent, just obtained image behind the convergent-divergent, can output to image behind the convergent-divergent on the display screen or carry out other operation.
In order further to simplify computing, u in the such scheme and v are taken as 2 index, i.e. u=2 respectively
hAnd v=2
k, formula (11) just becomes so:
(12)
Can simplify division arithmetic with the method for shifting function like this.When divisor is 2
nThe time, can realize division with shifting function, for example 15 divided by 4, wherein 4=2
2, 15 usefulness binary forms are shown 1111, can adopt (1111)>>2, promptly move right 2, obtain (11), and changing the decimal system into is 3, that is to say that 15 is 3 divided by 4 result.Adopt shifting function to realize division equally for formula (12) so, that is:
Thereby greatly reduce the complexity of division arithmetic in the zoom operations.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.