Summary of the invention
The invention provides a kind of image-scaling method, when obtaining to be similar to the bicubic interpolation algorithm effect, improved counting yield greatly based on Biquadratic B-spline local interpolation.
A kind of image-scaling method based on Biquadratic B-spline local interpolation comprises the steps:
(1) with resolution be the source images of M * N by the RGB color space conversion to the YUV color space, the monochrome information of the Y representative image in the yuv space, U, V represent chrominance information.Since human eye to the susceptibility of monochrome information much larger than susceptibility to chrominance information, then when handling coloured image, only need the Y component is adopted the algorithm of more complicated, and adopt fairly simple algorithm between the U, V component, can improve the processing speed and the efficient of entire image like this;
(2) source images that will be transformed into behind the YUV color space amplifies, obtain the target image that resolution is nM * nN, n represents that source images needs amplification multiple, combination of pixels matrix with n * n travels through this target image as a processing unit, each processing unit is carried out following three operations, until the Y component brightness value that obtains scaled images:
A. this processing unit is mapped to forward in the source images, generates a mapping point;
The matrix area of b. getting 4 * 4 pixels around this mapping point in source images is as a sampled point space, make mapping point become the 2nd row the 2nd column element of sampled point space quadravalence matrix for this reason, with a Biquadratic B-spline function Y component brightness value of 16 pixels in this sampled point space is carried out interpolation, obtain the control vertex matrix matrix P of this Biquadratic B-spline function;
C. the sampled point space is amplified the resampling space that n doubly obtains 4n * 4n, will apply to the resampling space by the control vertex matrix P that operation b obtains and obtain 4n * 4n matrix, and n+1 in this 4n * 4n matrix walked to 2n is capable, n+1 be listed as to the common n of 2n row
2Individual element assignment is given the respective pixel when pretreatment unit, as the Y component brightness value of these pixels;
(3) U, the V component of the target image that obtains afterwards finishing dealing with through step (2) carry out the bilinear interpolation computing, obtain U, the V component brightness value of scaled images;
(4) according to Y, U and the V component of scaled images, scaled images is transformed into the RGB color space.
As follows to the conversion method of YUV color space in the described step (1) by the RGB color space conversion:
The red, green, blue color value of R, G, B difference remarked pixel in the formula, Y is the luminance channel value of pixel, U and V are two color channel values of pixel, the expression aberration.
Interpolation process among the operation b of described step (2) is as follows:
For the pixel of 16 interpolations in this sampled point space, with (x
c, y
d) the expression sampled point (c, position coordinates d), 1≤c≤4,1≤d≤4 wherein, D be the brightness value matrix in this sampled point space, it is a quadravalence matrix, the brightness value of each element correspondence relevant position pixel:
To these 16 element interpolation, (u v) makes promptly to be to locate a Biquadratic B-spline function S
P is the control vertex matrix of Biquadratic B-spline function, and u, v are two parameter axles of Biquadratic B-spline function, and valid interval is 2≤u≤4,2≤v≤4, and Nu, Nv are respectively two spline base functions on the parameter axle, with the position coordinates (x of pixel
c, y
d) parametrization to the valid interval of u, v parameter axle, form evenly cutting apart on this valid interval, promptly get x
1=2, x
2=8/3, x
3=10/3, x
4=4; y
1=2, y
2=8/3, y
3=10/3, y
4=4, calculation control summit matrix
Wherein
Obtain thus a Biquadratic B-spline function S (u, v)=N
uP (N
v)
T, to realize interpolation to each sampled point.
Among described step (2) the operation c, for the resampling space, with (x
e, y
f) the new pixel of expression (e, f) position coordinates, 1≤e≤4n wherein, 1≤f≤4n to u, v parameter axle, forms evenly cutting apart on the valid interval with this position coordinate parametersization, gets
Accounting equation:
Wherein P is the control vertex matrix of being asked, and N ' u, N ' v are the spline base functions that this branch is cut off:
Obtain a 4n * 4n matrix S thus '
4n * 4n, and with this matrix n+1 walk to that 2n is capable, n+1 is listed as to 2n row n altogether
2Individual element assignment is given the respective pixel when pretreatment unit in the target image, as the Y component brightness value of these pixels.
The bilinear interpolation calculating process is in the described step (3):
With f (x, y) certain pixel (x, U y), V component value in the expression source images (5), 1≤x≤M, 1≤y≤N is with T (s, t) pixel (s, U t), V component value, 1≤s≤nM in the expression target image (6), 1≤t≤nN, n are enlargement factor, note s1=int (s/n), s2=s/n-s1, t1=int (t/n), t2=t/n-t1, int is a bracket function, and then the corresponding relation formula of target image (6) U, V component value and source images (5) U, V component value is:
T(s,t)=(1-s2)·(1-t2)·f(s1,t1)+(1-s2)·t2·f(s1,t1+1)+s2·(1-t2)·f(s1+1,t1)+s2·t2·f(s1+1,t1+1)。
As follows to the conversion method of RGB color space in the described step (4) by the YUV color space conversion:
The present invention proposes a kind of image-scaling method based on Biquadratic B-spline local interpolation, adopted four sampled points to be different from traditional quadratic interpolation function, has good locality, be easy to Parallel Implementation, can quicken at GPU, thereby can obtain to be similar to the bicubic interpolation algorithm effects, improve efficient simultaneously.
Embodiment
Referring to Fig. 1,2, the present invention is based on the image-scaling method of Biquadratic B-spline local interpolation, be example to amplify twice, may further comprise the steps:
(1) with pixel resolution be 5 * 5 source images 5 by the RGB color space conversion to the YUV color space, conversion method is as follows:
The red, green, blue color value of R, G, B difference remarked pixel in the formula, Y is the luminance channel value of pixel, U and V are two color channel values of pixel, the expression aberration;
(2) source images 5 being mapped to resolution is 10 * 10 target image 6, and the combination of pixels matrix with 2 * 2 is divided into 25 processing units as a processing unit 1 with this target image 6, and each processing unit 1 is carried out following three operations:
A. this processing unit 1 is mapped to forward in the source images 5, generates a mapping point 2;
B. in source images 5, get around this mapping point 24 * 4 matrix area as a sampled point space 3, make 2 one-tenth of mapping points, the second row secondary series element of sampled point space 3 quadravalence matrixes for this reason, (u v) carries out interpolation to 16 sampled points in this sampled point space 3 with a Biquadratic B-spline function S.Interpolation process is as follows:
For the pixel of 16 interpolations in this sampled point space (3), with (x
c, y
d) the expression sampled point (c, position coordinates d), 1≤c≤4,1≤d≤4 wherein, D be the brightness value matrix in this sampled point space (3), it is a quadravalence matrix, the brightness value of each element correspondence relevant position pixel:
To these 16 element interpolation, (u v) makes promptly to be to locate a Biquadratic B-spline function S
P is the control vertex matrix of Biquadratic B-spline function, and u, v are two parameter axles of Biquadratic B-spline function, and valid interval is 2≤u≤4,2≤v≤4, and Nu, Nv are respectively two spline base functions on the parameter axle, with the position coordinates (x of pixel
c, y
d) parametrization to the valid interval of u, v parameter axle, form evenly cutting apart on this valid interval, promptly get x
1=2, x
2=8/3, x
3=10/3, x
4=4; y
1=2, y
2=8/3, y
3=10/3, y
4=4, calculation control summit matrix
Wherein
Obtain thus a Biquadratic B-spline function S (u, v)=N
uP (N
v)
T, to realize interpolation to each sampled point.
C. will finish sampled point space after the interpolation and amplify 2 times and obtain 8 * 8
resampling space 4, will apply to
resampling space 4 by the control vertex matrix P that operation b obtains, the
space 4 that resamples hereto is with (x
e, y
f) (wherein 1≤e≤8,1≤f≤8 to u, v parameter axle, form evenly cutting apart on the valid interval with this position coordinate parametersization to the new pixel of expression, get for e, f) position coordinates
Accounting equation:
The control vertex matrix asked of matrix P wherein, N ' u, N ' v are the spline base functions that this branch is cut off:
As shown in Figure 1,4 * 4 sampled point space 3 is amplified to 8 * 8 resampling space S '
8 * 8After, can find S ' through observing
8 * 8In what use only is the part in the upper left corner 4 * 4, so in calculating in order to reduce calculated amount, can only calculate this part, promptly for 8 * 4 matrix N '
uAnd N '
v, the part that only need get its first half 4 * 4 gets final product, and then has:
Obtain one 8 * 8 matrix S thus '
8 * 8, and with this matrix the 3rd walk to the 4th row, the 3rd row to the 4th row totally 4 element assignment give respective pixel in the target image when pretreatment unit 1, as the Y component brightness value of these pixels.
(3) U, the V component of the target image that obtains afterwards finishing dealing with through step (2) carry out the bilinear interpolation computing, obtain new images, and the bilinear interpolation calculating process is:
With f (x, y) certain pixel (x, U y), V component value in the expression source images (5), 1≤x≤M, 1≤y≤N is with T (s, t) pixel (s, U t), V component value, 1≤s≤nM in the expression target image (6), 1≤t≤nN, n are enlargement factor, note s1=int (s/n), s2=s/n-s1, t1=int (t/n), t2=t/n-t1, int is a bracket function, and then the corresponding relation formula of target image (6) U, V component value and source images (5) U, V component value is:
T(s,t)=(1-s2)·(1-t2)·f(s1,t1)+(1-s2)·t2·f(s1,t1+1)+s2·(1-t2)·f(s1+1,t1)+s2·t2·f(s1+1,t1+1);
(4) with new images by the YUV color space conversion to the RGB color space, obtain final processing result image, conversion method is as follows:
The red, green, blue color value of R, G, B difference remarked pixel in the formula, Y is the luminance channel value of pixel, U and V are two color channel values of pixel, the expression aberration.