Summary of the invention
Embodiment of the invention technical matters to be solved is, a kind of image-scaling method and system are provided.Mix reasonable interpolation method through center of gravity newton's binary of rectangular node convergent-divergent is carried out in the edge of image zone; Use 3 lagrange-interpolations of binary that the flat site of image is carried out convergent-divergent; Both guarantee whole scaling speed, can obtain image behind the high convergent-divergent of sharpness again.
In order to solve the problems of the technologies described above, the embodiment of the invention provides a kind of image-scaling method, comprising:
Based on three Color Channels of red, green, blue, confirm in red component intensity, green component intensity and the blue component intensity of source images image-region under each pixel respectively, said image-region comprises fringe region and flat site;
If confirm that said pixel belongs to flat site; Then corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image based on 3 Lagrange's interpolation algorithms of binary; If confirm that said pixel belongs to fringe region; Then mix reasonable interpolation algorithm corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image based on center of gravity newton binary;
Generate target image according to the pixel value that calculates.
Wherein, the step of the affiliated image-region of each pixel specifically comprises in red component intensity, green component intensity and the blue component intensity of said definite source images respectively:
The first sampling rule according to preset is chosen each pixel at least one pixel on every side respectively as first sample space in red component intensity, green component intensity and the blue component intensity of source images;
Whether the variance of judging the pixel value of pixel in said first sample space is to confirm that then this pixel belongs to flat site if be judged as less than predetermined threshold value; If be judged as not, confirm that then this pixel belongs to fringe region.
Wherein, saidly mix the step that reasonable interpolation algorithm carries out interpolation calculation to the pixel that belongs to fringe region corresponding red component intensity, green component intensity and blue component intensity according to center of gravity newton binary and specifically comprise:
The second sampling rule according to preset is chosen this pixel at least one pixel on every side as second sample space, and the size of said second sample space is (n+1) * (m+1);
According to preset center of gravity newton's binary mix reasonable interpolation calculation formula calculate the corresponding pixel cell of this pixel in the target image (x, pixel value R y) (x, y), said center of gravity newton's binary is mixed reasonable interpolation calculation formula and is:
Wherein, A
i(y)=a
I0+ a
I1(y-y
0)+... + a
In(y-y
0) (y-y
1) ... (y-y
N-1),
M, n are respectively positive integer, x
i, y
jBe interpolation knot, ω
iBe interpolation weight.
Wherein, calculate ω according to the numerical value approach method
i
Correspondingly, the present invention also provides a kind of image scaling system, comprising:
The zone determination module based on three Color Channels of red, green, blue, is confirmed in red component intensity, green component intensity and the blue component intensity of source images image-region under each pixel respectively, and said image-region comprises fringe region and flat site;
The flat pixels computing module; Be used for when said image-region determination module confirms that said pixel belongs to flat site; According to 3 Lagrange's interpolation algorithms of binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image;
The edge pixel computing module; Be used for when said image-region determination module confirms that said pixel belongs to fringe region; Mix reasonable interpolation algorithm according to center of gravity newton binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image;
The image generation module, the pixel value of each color component that is used for calculating according to said flat pixels computing module and edge pixel computing module generates target image.
Wherein, said image-region determination module specifically comprises:
Module is divided in first sample space, is used for according to regular at least one pixel around red component intensity, green component intensity and the blue component intensity of source images are chosen each pixel respectively of the first preset sampling as first sample space;
Whether judge module, the variance of pixel value that is used for judging the said first sample space pixel less than predetermined threshold value, if the judged result of said judge module is for being to represent that then this pixel belongs to flat site; If the judged result of said judge module representes then that for not this pixel belongs to fringe region.
Wherein, said edge pixel computing module specifically comprises:
Division module in second sample space is used for choosing this pixel at least one pixel on every side as second sample space according to the second preset sampling rule, and the size of said second sample space is (n+1) * (m+1);
Center of gravity newton's binary is mixed reasonable interpolation calculation module; Be used for mixing reasonable interpolation calculation formula and calculate the corresponding pixel cell (x of this pixel of target image according to preset center of gravity newton's binary; Pixel value R y) (x, y), said center of gravity newton's binary is mixed reasonable interpolation calculation formula and is:
Wherein, A
i(y)=a
I0+ a
I1(y-y
0)+... + a
In(y-y
0) (y-y
1) ... (y-y
N-1),
M, n are respectively positive integer, x
i, y
jBe interpolation knot, ω
iBe interpolation weight.
Wherein, said center of gravity newton's binary is mixed reasonable interpolation calculation module according to numerical value approach method calculating ω
i
Embodiment of the present invention embodiment; Has following beneficial effect: mix reasonable interpolation method through center of gravity newton's binary of rectangular node convergent-divergent is carried out in the edge of image zone; Use 3 lagrange-interpolations of binary that the flat site of image is carried out convergent-divergent; Particularly, it is to be x change in coordinate axis direction interpolation scheme with center of gravity rational interpolation polynomial expression that the rectangular node center of gravity newton binary of present embodiment is mixed rational interpolation, and Newton interpolation is the interpolation scheme of y change in coordinate axis direction; Construct a kind of better numerical value stability, approached effective interpolation algorithm; Both guaranteed whole scaling speed, and can obtain image behind the high convergent-divergent of sharpness again, comparing prior art picture quality has had tangible improvement.
Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Referring to Fig. 1, be the first embodiment process flow diagram of image-scaling method provided by the invention, this method comprises:
At step S100, based on three Color Channels of red, green, blue, confirm in red component intensity, green component intensity and the blue component intensity of source images image-region under each pixel respectively, said image-region comprises fringe region and flat site.
If confirm that pixel belongs to flat site, then execution in step S101.At step S101, according to 3 Lagrange's interpolation algorithms of binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image.
If confirm that pixel belongs to fringe region, then execution in step S102.At step S102, mix reasonable interpolation algorithm according to center of gravity newton binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image.
At step S103, generate target image according to the pixel value that calculates.
The image-scaling method that the embodiment of the invention provides; Through different processing is carried out in regional peace smooth zone in edge; Utilize center of gravity newton binary to mix reasonable interpolation algorithm and calculate the pixel value in the target image; Can increase the sharpness of the target image after convergent-divergent is handled, obviously improve the quality of the target image after convergent-divergent is handled.
Referring to Fig. 2, be the second embodiment process flow diagram of image-scaling method provided by the invention, this method comprises:
At step S200; Based on three Color Channels of red, green, blue, in red component intensity, green component intensity and the blue component intensity of source images, choose each pixel at least one pixel on every side respectively as first sample space according to the first preset sampling rule.First the sampling rule can for: for the pixel I in the red component intensity
r(i j), chooses the I in the red component intensity
r(i-1, j-1), I
r(i-1, j), I
r(i-1, j+1), I
r(i, j-1), I
r(i, j), I
r(i, j+1), I
r(i+1, j-1), I
r(i+1, j), I
r(i+1, j+1) these 9 pixels are as first sample space; For the pixel I in the green component intensity
g(i j), chooses the I in the green component intensity
g(i-1, j-1), I
g(i-1, j), I
g(i-1, j+1), I
g(i, j-1), I
g(i, j), I
g(i, j+1), I
g(i+1, j-1), I
g(i+1, j), I
g(i+1, j+1) these 9 pixels are as first sample space; For the pixel I in the blue component intensity
b(i j), chooses the I in the blue component intensity
b(i-1, j-1), I
b(i-1, j), I
b(i-1, j+1), I
b(i, j-1), I
b(i, j), I
b(i, j+1), I
b(i+1, j-1), I
b(i+1, j), I
b(i+1, j+1) these 9 pixels that is to say as first sample space, the size of first sample space is the 3*3 block of pixels.Certainly, the present invention is not limited to this, and the first sampling rule can be the various method of sampling well known to those skilled in the art, and for example first sample space can be 6*6 block of pixels, 8*8 block of pixels etc., and the 3*3 block of pixels is preferred embodiment.
At step S201, whether the variance of judging the pixel value of pixel in first sample space is less than predetermined threshold value.Particularly, to be that the block of pixels of 3*3 is an example with image division, suppose R
k, G
kAnd B
kBe respectively red component intensity, green component intensity and the blue component intensity of k pixel in this first sample space, judge whether to satisfy
And
Wherein
And
ε is a predetermined threshold value, can get 1 to 5.
If the judged result of step S201 is for being then to represent to belong to flat site corresponding to the pixel of this first sample space, execution in step S202.In step S202, according to 3 Lagrange's interpolation algorithms of binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image.Wherein 3 Lagrange's interpolation formulas of binary are following:
If the judged result of step S201 then representes to belong to fringe region corresponding to the pixel of this first sample space execution in step S203 for not.In step S203, mix reasonable interpolation algorithm according to center of gravity newton binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image.Can in advance pixel cell in the target image and the pixel in the source images be shone upon, source images amplified or dwindles any multiple (comprising integral multiple and non-integral multiple) so that realize.
Particularly, step S203 can comprise: the second sampling rule according to preset is chosen this pixel at least one pixel on every side as second sample space, and the size of second sample space is (n+1) * (m+1); According to preset center of gravity newton's binary mix reasonable interpolation calculation formula calculate the corresponding pixel cell of this pixel in the target image (x, pixel value R y) (x, y), wherein center of gravity newton binary is mixed reasonable interpolation calculation formula and is:
Wherein, A
i(y)=a
I0+ a
I1(y-y
0)+... + a
In(y-y
0) (y-y
1) ... (y-y
N-1), (i=0,1 ..., n) m, n are respectively positive integer, x
i, y
jBe interpolation knot, ω
iBe interpolation weight, ω
i(i=0,1 ..., n).
(i=0; 1 ..., m; J=0; 1 ..., n), define the partial difference quotient of following form
The second sampling rule can be identical with the first sampling rule, also can be different with the first sampling rule.
Preferably, first sample space of describing among the step S200 as second sample space among the step S203, that is to say that the size of second sample space is 3*3, this moment n=2, m=2, in above-mentioned formula, when being divided into 3 * 3 block of pixels to image, n=2.And ω
iBe called the interpolation weight that calculates interpolation, can be approached by numerical value, optimization method tries to achieve, especially, interpolation weight can utilize following numerical value approach method to calculate:
Power ω with each interpolation knot place
i(i=0,1,2) is decision variable, and is minimum with the interpolation square error, promptly
(at this moment, objective function is merely power ω for objective function
iThe function of (i=0,1,2)), simultaneously for guaranteeing that center of gravity newton binary mixing rational interpolating function satisfies interpolation condition, no limit, ω
iConstraint condition also must be satisfied in (i=0,1,2)
ω
i≠0,sign(ω
i)=-sign(ω
i+1)
At last; For guaranteeing that optimized Algorithm solves uniqueness, the Optimization Model that to sum up can find the solution optimum power to power additional specifications constraint
is following.
ω
i≠0,
sign(ω
i)=-sign(ω
i+1)
Find the solution this Optimization Model with LINGO software and promptly get one group of best interpolation power.
Preferably,, accelerate image processing speed, can calculate w according to the numerical value approach method in order to reduce calculated amount
lFor example, can get
At step S204, generate target image according to the pixel value of the pixel cell of each color component that calculates.
Embodiment shown in Figure 2 has enumerated a kind of method that definite pixel belongs to flat site or belongs to fringe region, but the present invention is not limited to this.In other embodiments of the invention; Can also adopt other modes; The absolute value of the difference of the pixel value of two relatively more adjacent pixels for example with this pixel; If this absolute value is less than predetermined threshold value (for example 25), then this pixel belongs to flat site (being non-fringe region), otherwise this pixel belongs to fringe region.
Referring to Fig. 3, be the first example structure synoptic diagram of image scaling system provided by the invention, this system comprises:
Zone determination module 310; Be used for based on three Color Channels of red, green, blue; Confirm in red component intensity, green component intensity and the blue component intensity of source images image-region under each pixel respectively, said image-region comprises fringe region and flat site.
Flat pixels computing module 320; Be used for when image-region determination module 310 confirms that said pixel belongs to flat site; According to 3 Lagrange's interpolation algorithms of binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image.
Edge pixel computing module 330; Be used for when image-region determination module 310 confirms that said pixel belongs to fringe region; Mix reasonable interpolation algorithm according to center of gravity newton binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image.
Image generation module 340, the pixel value that is used for calculating according to flat pixels computing module 320 and edge pixel computing module 330 generates target image.
The image scaling system that the embodiment of the invention provides; Through different processing is carried out in regional peace smooth zone in edge; Utilize center of gravity newton binary to mix reasonable interpolation algorithm and calculate the pixel value in the target image; Can increase the sharpness of the target image after convergent-divergent is handled, obviously improve the quality of the target image after convergent-divergent is handled.
Referring to Fig. 4; It is the second example structure synoptic diagram of image scaling system provided by the invention; This system comprises regional determination module 410, flat pixels computing module 420, edge pixel computing module 430 and image generation module 440, and wherein regional determination module 410 can comprise that again first sample space divides module 411 and judge module 412.
Module 411 is divided in first sample space, is used for according to regular at least one pixel around red component intensity, green component intensity and the blue component intensity of source images are chosen each pixel respectively of the first preset sampling as first sample space.First the sampling rule can for: for the pixel I in the red component intensity
r(i j), chooses the I in the red component intensity
r(i-1, j-1), I
r(i-1, j),
I
r(i-1, j+1), I
r(i, j-1), I
r(i, j), I
r(i, j+1), I
r(i+1, j-1), I
r(i+1, j), I
r(i+1, j+1) these 9 pixels are as first sample space; For the pixel I in the green component intensity
g(i j), chooses the I in the green component intensity
g(i-1, j-1), I
g(i-1, j), I
g(i-1, j+1), I
g(i, j-1), I
g(i, j), I
g(i, j+1), I
g(i+1, j-1), I
g(i+1, j), I
g(i+1, j+1) these 9 pixels are as first sample space; For the pixel I in the blue component intensity
b(i j), chooses the I in the blue component intensity
b(i-1, j-1), I
b(i-1, j), I
b(i-1, j+1), I
b(i, j-1), I
b(i, j), I
b(i, j+1), I
b(i+1, j-1), I
b(i+1, j), I
b(i+1, j+1) these 9 pixels that is to say as first sample space, the size of first sample space is the 3*3 block of pixels.Certainly, the present invention is not limited to this, and the first sampling rule can be the various method of sampling well known to those skilled in the art, and for example first sample space can be 6*6 block of pixels, 8*8 block of pixels etc., and the 3*3 block of pixels is preferred embodiment.
Judge module 412, whether the variance of pixel value that is used for judging the first sample space pixel is less than predetermined threshold value.Particularly, to be that the block of pixels of 3*3 is an example with image division, suppose R
k, G
kAnd B
kBe respectively red component intensity, green component intensity and the blue component intensity of k pixel in this first sample space, judge whether to satisfy
And
Wherein
And
ε is a predetermined threshold value, can get 1 to 5.If the judged result of
judge module 412 is for being then to represent to belong to flat site corresponding to the pixel of this first sample space; If the judged result of
judge module 412 is then represented to belong to fringe region corresponding to the pixel of this first sample space for not.
Flat pixels computing module 420; Be used in the judged result of judge module 412 when being; According to 3 Lagrange's interpolation algorithms of binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to flat site is carried out interpolation calculation, calculate the pixel value of target image.Wherein 3 Lagrange's interpolation formulas of binary are following:
Edge pixel computing module 430; Be used in the judged result of judge module 412 for not the time; Mix reasonable interpolation algorithm according to center of gravity newton binary corresponding red component intensity, green component intensity and the blue component intensity of pixel that belongs to fringe region is carried out interpolation calculation, calculate the pixel value of target image.In this image scaling system, can in advance pixel cell in the target image and the pixel in the source images be shone upon, so that realize source images is amplified or dwindles any multiple (comprising integral multiple and non-integral multiple).
Particularly; Edge pixel computing module 430 can comprise: module is divided in second sample space; Be used for choosing this pixel at least one pixel on every side as second sample space according to the second preset sampling rule, the size of second sample space is (n+1) * (m+1); Center of gravity newton's binary is mixed reasonable interpolation calculation module; Be used for mixing reasonable interpolation calculation formula and calculate the corresponding pixel cell (x of this pixel of target image according to preset center of gravity newton's binary; Pixel value r y) (x, y), wherein center of gravity newton binary is mixed reasonable interpolation calculation formula and is:
Wherein, A
i(y)=a
I0+ a
I1(y-y
0)+... + a
In(y-y
0) (y-y
1) ... (y-y
N-1), (i=0,1 ..., n) m, n are respectively positive integer, x
i, y
jBe interpolation knot, w
iBe interpolation weight, ω
i(i=0,1 ..., n).
(i=0; 1 ..., m; J=0; 1 ..., n), define the partial difference quotient of following form
The second sampling rule can be identical with the first sampling rule, also can be different with the first sampling rule.
Preferably, module 411 is divided in first sample space divide module, that is to say as second sample space; Adopt the above sampling rule of describing to sample, the size of second sample space is 3*3, at this moment n=2; In above-mentioned formula, when being divided into 3 * 3 block of pixels to image, n=2.And w
iBe called the interpolation weight that calculates interpolation, can be approached by numerical value, optimization method tries to achieve, especially, interpolation weight can utilize following numerical value approach method to calculate:
Power ω with each interpolation knot place
i(i=0,1,2) is decision variable, and is minimum with the interpolation square error, promptly
(at this moment, objective function is merely power ω for objective function
iThe function of (i=0,1,2)), simultaneously for guaranteeing that center of gravity newton binary mixing rational interpolating function satisfies interpolation condition, no limit, ω
iConstraint condition also must be satisfied in (i=0,1,2)
ω
i≠0,sign(ω
i)=-sign(ω
i+1)
At last; For guaranteeing that optimized Algorithm solves uniqueness, the Optimization Model that to sum up can find the solution optimum power to power additional specifications constraint
is following.
ω
i≠0,
sign(ω
i)=-sign(ω
i+1)
Find the solution this Optimization Model with LINGO software and promptly get one group of best interpolation power.
Preferably,, accelerate image processing speed, can calculate ω according to the numerical value approach method in order to reduce calculated amount
lFor example, can get
Image generation module 440, the pixel value of each pixel cell of each color component that is used for calculating according to flat pixels computing module 420 and edge pixel computing module 430 generates target image.
Embodiment shown in Figure 4 has enumerated a kind of method that definite pixel belongs to flat site or belongs to fringe region, but the present invention is not limited to this.In other embodiments of the invention; The zone determination module can also adopt other modes to confirm the affiliated image-region of pixel; For example regional determination module can be relatively more adjacent with this pixel the absolute value of difference of pixel value of two pixels; If this absolute value is less than predetermined threshold value (for example 25), then this pixel belongs to flat site (being non-fringe region), otherwise this pixel belongs to fringe region.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method; Be to instruct relevant hardware to accomplish through computer program; Described program can be stored in the computer read/write memory medium; This program can comprise the flow process like the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-Only Memory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
Above disclosedly be merely a kind of preferred embodiment of the present invention; Certainly can not limit the present invention's interest field with this; One of ordinary skill in the art will appreciate that all or part of flow process that realizes the foregoing description; And, still belong to the scope that invention is contained according to the equivalent variations that claim of the present invention is done.