Summary of the invention
The technical problem to be solved in the present invention is, at method complexity, the inefficient defective of the above-mentioned generation drawing with colored pencil of prior art, provides the generation method of the drawing with colored pencil that a kind of method is simple, efficient is high.
The technical solution adopted for the present invention to solve the technical problems is: construct a kind of generation method of drawing with colored pencil, be used for coloured image is handled to generate drawing with colored pencil, comprising:
S1. opening one at the current color passage of coloured image is the N*N window at center with the current pixel point, and wherein, N is the odd number greater than 1;
S2. the size of the pixel value of other pixel is determined operator in pixel value by current pixel point relatively and the window;
S3. strengthen the factor according to the calculated for pixel values profile of operator and described current pixel point;
S4. handle according to the pixel value of the described current pixel point of described profile reinforcement factor pair, to generate the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil.
In the generation method of drawing with colored pencil of the present invention, described step S2 comprises:
Whether the pixel value of S21. judging current pixel point greater than the pixel value of other any pixel in the window, if, execution in step S22 then; If not, execution in step S23 then;
S22. imputing son is zero, execution in step S3;
S23. with the pixel value of current pixel point respectively with window in the pixel value of other pixel subtract each other again one by one and take absolute value, imputation is the maximal value in the resulting absolute value, execution in step S3 then.
In the generation method of drawing with colored pencil of the present invention, in described step S3, calculate profile according to following formula and strengthen the factor:
Figure(i,j)=1/?(CRYSTAL(i,j)/sqrt(PSrc(i,j)+c)/a+b)
Wherein, (i j) strengthens the factor, CRYSTAL (i for profile to Figure, j) be operator, sqrt () is extraction of square root, and (i j) is the pixel value of the current pixel point of working as prepass of coloured image to PSrc, a, b, c are respectively coefficient, and satisfy 1≤a≤100,1≤b≤10,1≤c≤500.
In the generation method of drawing with colored pencil of the present invention, in described step S4, calculate pairing pixel value of working as the current pixel point of prepass in the drawing with colored pencil according to following formula:
PDst(i,j)=PSrc(i,j)+?Scale*[(255-?PSrc(i,j))*Figure(i,j)]
Wherein, (i is the pixel value of the current pixel point of working as prepass of drawing with colored pencil j) to PDst, and Scale is a coefficient, and satisfies 0<Scale≤1.
In the generation method of drawing with colored pencil of the present invention, N=3.
The present invention also constructs a kind of generation system of drawing with colored pencil, is used for coloured image is handled to generate drawing with colored pencil, comprising:
Window is chosen the unit, and being used for opening one at the current color passage of coloured image is the N*N window at center with the current pixel point, and wherein, N is the odd number greater than 1;
The operator computing unit, the size that is used for the pixel value of other pixel in pixel value by current pixel point relatively and the window is determined operator;
Strengthen factor calculating unit, be used for strengthening the factor according to the calculated for pixel values profile of operator and described current pixel point;
Pixel value calculating unit is used for handling according to the pixel value of the described current pixel point of described profile reinforcement factor pair, to generate the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil.
In the generation system of drawing with colored pencil of the present invention, described operator computing unit comprises:
Whether judgment sub-unit, the pixel value that is used to judge current pixel point be greater than the pixel value of other any pixel in the window;
First computation subunit, be used for pixel value in current pixel point greater than window in during the pixel value of other any pixel, imputation is zero;
Second computation subunit, be used for when the pixel value of current pixel point is not more than the pixel value of other any pixel in the window, with the pixel value of current pixel point respectively with window in the pixel value of other pixel subtract each other again one by one and take absolute value, imputation is the maximal value in the resulting absolute value.
In the generation system of drawing with colored pencil of the present invention, described reinforcement factor calculating unit is calculated profile according to following formula and is strengthened the factor:
Figure(i,j)=1/?(CRYSTAL(i,j)/sqrt(PSrc(i,j)+c)/a+b)
Wherein, (i j) strengthens the factor, CRYSTAL (i for profile to Figure, j) be operator, sqrt () is extraction of square root, and (i j) is the pixel value of the current pixel point of working as prepass of coloured image to PSrc, a, b, c are respectively coefficient, and satisfy 1≤a≤100,1≤b≤10,1≤c≤500.
In the generation system of drawing with colored pencil of the present invention, described pixel value calculating unit is calculated the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil according to following formula:
PDst(i,j)=PSrc(i,j)+?Scale*[(255-?PSrc(i,j))*Figure(i,j)]
Wherein, (i is the pixel value of the current pixel point of working as prepass of drawing with colored pencil j) to PDst, and Scale is a coefficient, and satisfies 0<Scale≤1.
In the generation system of drawing with colored pencil of the present invention, N=3.
Implement technical scheme of the present invention, step is simple and implementation efficiency is high.
Embodiment
At first explanation is, supposes that employed picture has three Color Channels, and it is red to be respectively R() passage, G(be green) passage, B(indigo plant) passage.In addition, when carrying out Flame Image Process, all be that the individual element point carries out, and at each pixel, it include three values, corresponds respectively to three Color Channels, these three values are specially: the pixel value of the pixel value of R passage, G passage and the pixel value of B passage.
As shown in Figure 1, in the process flow diagram of the generation method embodiment one of drawing with colored pencil of the present invention, this generation method comprises:
S1. opening one at the current color passage of coloured image is the N*N window at center with the current pixel point, wherein, N is the odd number greater than 1, for example N is 3, in addition, in this step, also should be noted that, when if at least one in other pixel in the window except that current pixel point do not exist, for example, current pixel point is the pixel of first row, first row, only has three pixels in this 3*3 window except that current pixel point, other five pixels do not exist, and then the pixel value of these five pixels directly gets zero;
S2. the size of the pixel value of other pixel is determined operator in pixel value by current pixel point relatively and the window;
S3. strengthen the factor according to the calculated for pixel values profile of operator and described current pixel point;
S4. handle according to the pixel value of the described current pixel point of described profile reinforcement factor pair, to generate the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil.
Fig. 2 is the process flow diagram of step S2 preferred embodiment among Fig. 1, and this step S2 may further comprise the steps:
Whether the pixel value of S21. judging current pixel point greater than the pixel value of other any pixel in the window, if, execution in step S22 then; If not, execution in step S23 then;
S22. imputing son is zero, execution in step S3;
S23. with the pixel value of current pixel point respectively with window in the pixel value of other pixel subtract each other again one by one and take absolute value, imputation is the maximal value in the resulting absolute value, execution in step S3 then, for example, be example with 3*3, if CRYSTAL (i, j) be operator to be calculated, PSrc (i j) is the pixel value of the current pixel point of working as prepass of coloured image, then:
CRYSTAL(I,J)=max(abs(PSrc(i,j)-PSrc(i,j-1)),abs(PSrc(i,j)-PSrc(i,j+1)),abs(PSrc(i,j)-PSrc(i-1,j-1)),abs(PSrc(i,j)-PSrc(i-1,j)),abs(PSrc(i,j)-PSrc(i-1,j+1)),abs(PSrc(i,j)-PSrc(i+1,j-1)),abs(PSrc(i,j)-PSrc(i+1,j)),abs(PSrc(i,j)-PSrc(i+1,j+1)))
In following formula, PSrc (i, j-1), PSrc (i, j+1), PSrc (i-1, j-1), PSrc (i-1, j), PSrc (i-1, j+1), PSrc (i+1, j-1), PSrc (i+1, j), (i+1 j+1) is interior and PSrc (i, j) pixel value of adjacent pixels point of 3*3 window respectively to PSrc.
In the step S3 of the foregoing description, can calculate profile according to following formula and strengthen the factor:
Figure(i,j)=1/?(CRYSTAL(i,j)/sqrt(PSrc(i,j)+c)/a+b)
Wherein, (i j) strengthens the factor for profile to Figure, (i j) is operator to CRYSTAL, and sqrt () is extraction of square root, (i is the pixel value of the current pixel point of working as prepass of coloured image j) to PSrc, and a, b, c are respectively coefficient, and satisfy 1≤a≤100,1≤b≤10,1≤c≤500, a preferably gets 10, b preferably gets 1, and c preferably gets 1.
In the step S4 of the foregoing description, calculate pairing pixel value of working as the current pixel point of prepass in the drawing with colored pencil according to following formula:
PDst(i,j)=PSrc(i,j)+?Scale*[(255-?PSrc(i,j))*Figure(i,j)]
Wherein, (i is the pixel value of the current pixel point of working as prepass of drawing with colored pencil j) to PDst, and Scale is a coefficient, and satisfies 0<Scale≤1.It should be noted that when the Scale value approached zero more, coloured image changed hardly, on the contrary, the Scale value was approached 1 o'clock more, and it is thicker that image outline can become, and Scale preferably gets 0.7.
Below only introduced the current pixel point of current color passage has been handled, when actual treatment, continuous circulation step S1-S4 finishes processing up to all pixels of each Color Channel of this coloured image, so just can obtain the design sketch of the pairing drawing with colored pencil of this coloured image.For example, in conjunction with Fig. 3 A and Fig. 3 B, Fig. 3 A is the coloured image before handling, and Fig. 3 B is to use said method the coloured image of Fig. 3 A to be handled the design sketch of the drawing with colored pencil of back generation.In addition, also need to prove,, can handle in any order, also can handle simultaneously for each Color Channel of coloured image.
Fig. 4 is the logical diagram of the generation system embodiment one of drawing with colored pencil of the present invention, and this generation system comprises that successively the window that links to each other chooses unit 100, operator computing unit 200, strengthens factor calculating unit 300 and pixel value calculating unit 400.Wherein, it is the N*N window at center with the current pixel point that window chooses that unit 100 is used for opening one at the current color passage of coloured image, and wherein, N is the odd number greater than 1, for example, and N=3; Operator computing unit 200 is used for determining operator by the size of the pixel value of other pixel in pixel value that compares current pixel point and the window; Strengthening factor calculating unit 300 is used for strengthening the factor according to the calculated for pixel values profile of operator and described current pixel point; Pixel value calculating unit 400 is used for handling according to the pixel value of the described current pixel point of described profile reinforcement factor pair, to generate the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil.
Fig. 5 is the logical diagram of operator computing unit preferred embodiment among Fig. 4, and in this embodiment, operator computing unit 200 comprises judging unit 201 and first computation subunit 202 and second computation subunit 203 that link to each other with judging unit 201.Wherein, judgment sub-unit 201 be used to judge current pixel point pixel value whether greater than the pixel value of other any pixel in the window; First computation subunit 202 be used for pixel value in current pixel point greater than window in during the pixel value of other any pixel, imputation is zero; Second computation subunit 203 is used for when the pixel value of current pixel point is not more than the pixel value of other any pixel in the window, with the pixel value of current pixel point respectively with window in the pixel value of other pixel subtract each other again one by one and take absolute value, imputation is the maximal value in the resulting absolute value.
Preferably, strengthen factor calculating unit 300 and calculate the profile reinforcement factor according to following formula:
Figure(i,j)=1/?(CRYSTAL(i,j)/sqrt(PSrc(i,j)+c)/a+b)
Wherein, (i j) strengthens the factor, CRYSTAL (i for profile to Figure, j) be operator, sqrt () is extraction of square root, and (i j) is the pixel value of the current pixel point of working as prepass of coloured image to PSrc, a, b, c are respectively coefficient, and satisfy 1≤a≤100,1≤b≤10,1≤c≤500.
Preferably, pixel value calculating unit 400 is calculated the pixel value of the current pixel point of working as prepass corresponding in the drawing with colored pencil according to following formula:
PDst(i,j)=PSrc(i,j)+?Scale*[(255-?PSrc(i,j))*Figure(i,j)]
Wherein, (i is the pixel value of the current pixel point of working as prepass of drawing with colored pencil j) to PDst, and Scale is a coefficient, and satisfies 0<Scale≤1.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within the claim scope of the present invention.