CN106296569B - The method and apparatus for drawing portrait stick figure - Google Patents

The method and apparatus for drawing portrait stick figure Download PDF

Info

Publication number
CN106296569B
CN106296569B CN201510319160.7A CN201510319160A CN106296569B CN 106296569 B CN106296569 B CN 106296569B CN 201510319160 A CN201510319160 A CN 201510319160A CN 106296569 B CN106296569 B CN 106296569B
Authority
CN
China
Prior art keywords
portrait
stick
geometric transformation
pixel
training pattern
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510319160.7A
Other languages
Chinese (zh)
Other versions
CN106296569A (en
Inventor
黄鹏程
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201510319160.7A priority Critical patent/CN106296569B/en
Publication of CN106296569A publication Critical patent/CN106296569A/en
Application granted granted Critical
Publication of CN106296569B publication Critical patent/CN106296569B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • G06T3/04

Abstract

The invention discloses a kind of methods for drawing portrait stick figure, comprising: preset training pattern;Using training pattern to target portrait geometric transformation, the geometric transformation portrait with standard portrait geometric alignment is obtained;Using preset lines probability distribution area, selected pixels point obtains expectation stick figure to the pixel point sampling that lines probability distribution area is chosen in geometric transformation portrait from geometric transformation portrait;It determines the edge image of geometric transformation portrait, and using edge image amendment expectation stick figure, obtains amendment stick figure;Stick figure is corrected using the stick figure stencil matching of training pattern, generates the corresponding target stick figure of target portrait.The invention also discloses a kind of devices for drawing portrait stick figure.The present invention only handles the pixel of lines probability distribution area selection, reduces the pixel quantity of processing, improves processing speed;Expectation stick figure is corrected using edge image, improves the accuracy of stick figure.

Description

The method and apparatus for drawing portrait stick figure
Technical field
The present invention relates to technical field of image processing, it is related specifically to the method and apparatus for drawing portrait stick figure.
Background technique
Currently, many application programs with facial image processing can be installed at the terminal, the portrait that user can be shot Photo is converted to the image of drawing style, such as is converted to caricature, sketch images, oil colour painting, etching etc..One of conversion regime It can be the stick figure that portrait photo is converted to portrait profile, the portrait line very much like with portrait depicted by stick figure Item is drawn.It is to learn to obtain between portrait photo and stick figure by a large amount of sample training that existing portrait stick figure, which draws mode, Statistical relationship, obtain stick figure template, and desired stick figure is obtained using the nonparametric method of sampling.But using non-ginseng The number method of sampling needs to carry out neighborhood matching to each upper pixel of portrait photo, calculates the corresponding region of all sample portraits The similarity of corresponding pixel points is gone up with portrait photo, and in order to draw the portrait stick figure of high quality, existing method needs foot Enough sample spaces, this matched process is very time-consuming, and computation complexity is high, has seriously affected drafting efficiency.
Summary of the invention
The embodiment of the present invention provides a kind of method and apparatus for drawing portrait stick figure, being capable of Fast Drawing portrait lines It draws, draws high-efficient.
The embodiment of the present invention proposes a kind of method for drawing portrait stick figure, comprising steps of
Preset training pattern, the training pattern include standard portrait, lines probability distribution area and stick figure mould Version;
Geometric transformation is carried out to target portrait using training pattern, is obtained and the standard portrait in the training pattern The geometric transformation portrait of geometric alignment;
Picture is chosen from the geometric transformation portrait using preset lines probability distribution area in the training pattern Vegetarian refreshments, the pixel chosen in the geometric transformation portrait to the lines probability distribution area sample, it is expected that Stick figure;
It determines the edge image of the geometric transformation portrait, and the expectation stick figure is corrected using the edge image, Obtain amendment stick figure;
Stick figure is corrected described in stick figure stencil matching using the training pattern, it is corresponding to generate the target portrait Target stick figure.
The embodiment of the present invention also proposes a kind of device for drawing portrait stick figure, comprising:
Model generation module, is used for preset training pattern, and the training pattern includes standard portrait, lines probability point Cloth region and stick figure template;
Geometric transformation module, for carrying out geometric transformation to target portrait using training pattern, acquisition has been instructed with described Practice the geometric transformation portrait of the standard portrait geometric alignment in model;
Sampling module, for using preset lines probability distribution area in the training pattern from the geometric transformation Selected pixels point in portrait, the pixel chosen in the geometric transformation portrait to the lines probability distribution area are adopted Sample obtains expectation stick figure;
Correction module corrects institute for determining the edge image of the geometric transformation portrait, and using the edge image Desired stick figure is stated, amendment stick figure is obtained;
Stencil matching module, it is raw for correcting stick figure using described in the stick figure stencil matching of training pattern At the corresponding target stick figure of the target portrait.
The embodiment of the present invention uses preset lines probability distribution area and chooses from the target portrait after geometric transformation Pixel, and only the pixel of selection is handled, the quantity of processing pixel is greatly reduced, processing speed is improved; Meanwhile also using edge image amendment expectation stick figure in gray value, enable correct stick figure in lines gray value more Portrait profile accurately is sketched out, further improves the accuracy of the stick figure ultimately generated.
Detailed description of the invention
Fig. 1 is total line chart of terminal where drawing the device of portrait stick figure in the embodiment of the present invention;
Fig. 2 is the flow chart of the first embodiment for the method that the present invention draws portrait stick figure;
Fig. 3 is that the present invention draws the step process that lines probability distribution area is obtained in the embodiment of the method for portrait stick figure Figure;
Fig. 4 is the flow chart of the second embodiment for the method that the present invention draws portrait stick figure;
Fig. 5 is the flow chart of the 3rd embodiment for the method that the present invention draws portrait stick figure;
Fig. 6 is the flow chart of the fourth embodiment for the method that the present invention draws portrait stick figure;
Fig. 7 is the module diagram of the first embodiment for the device that the present invention draws portrait stick figure;
Fig. 8 is the module diagram of the second embodiment for the device that the present invention draws portrait stick figure;
Fig. 9 is the superposition schematic diagram of lines probability distribution area in the embodiment of the present invention.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
Referring to Fig.1, Fig. 1 is total line chart of terminal where drawing the device of portrait stick figure in the embodiment of the present invention, the end End may include: at least one processor 101, such as CPU, at least one network interface 104, user interface 103, memory 105, at least one communication bus 102.Wherein, communication bus 102 is for realizing the connection communication between these components.Wherein, User interface 103 may include display screen (Display), keyboard (Keyboard), can also include wireline interface, the nothing of standard Line interface.Network interface 104 may include standard wireline interface and wireless interface (such as WIFI interface).Memory 105 can be High speed RAM memory is also possible to non-labile memory (non-volatile memory), for example, at least a disk Memory.Memory 105 can also be that at least one is located remotely from the storage device of aforementioned processor 101.As a kind of calculating It may include operating system, network communication module, Subscriber Interface Module SIM and drafting portrait in the memory 105 of machine storage medium Stick figure program.
In the terminal, network interface 104 is mainly used for connection service for the device institute of drafting portrait stick figure shown in Fig. 1 Device or other terminals carry out data communication with server or other terminals;And user interface 103 is mainly used for reception user and refers to It enables, and is interacted with user;And processor 101 can be used for calling the drafting portrait stick figure journey stored in memory 105 Sequence, and execute following operation:
Preset training pattern, the training pattern include standard portrait, lines probability distribution area and stick figure mould Version;
Geometric transformation is carried out to target portrait using training pattern, is obtained and the standard portrait geometry in training pattern The geometric transformation portrait of alignment;
Using lines probability distribution area selected pixels point from geometric transformation portrait preset in training pattern, to line The pixel that probability distribution area is chosen in geometric transformation portrait is sampled, and expectation stick figure is obtained;
It determines the edge image of geometric transformation portrait, and using edge image amendment expectation stick figure, obtains amendment lines It draws;
Stick figure is corrected using the stick figure stencil matching of training pattern, generates the corresponding target lines of target portrait It draws.
In one embodiment, processor 101 calls in memory 105 the drafting portrait stick figure program that stores can be with Execute following operation:
Obtain the coordinate of the black pixel point of each sample stick figure of training pattern;
The coordinate of all black pixel points is superimposed, the coordinate set of acquisition constitutes lines probability distribution area.
In one embodiment, processor 101 calls in memory 105 the drafting portrait stick figure program that stores can be with Execute following operation:
Using lines probability distribution area from edge image selected pixels point;
Corresponding position in the pixel amendment expectation stick figure chosen in edge image using lines probability distribution area Pixel gray value, obtain amendment stick figure.
In one embodiment, processor 101 calls in memory 105 the drafting portrait stick figure program that stores can be with Execute following operation:
Neighborhood image matching is carried out to each pixel that lines probability distribution area is chosen in geometric transformation portrait, Calculate the regional area corresponding to ith pixel point of n sample portrait in training pattern gray value and relative to The similarity of ith pixel point, and obtain similarity be greater than similar threshold value k sample portrait, as with ith pixel point office The sample portrait of portion's Region Matching, wherein 1≤n≤20,1≤k≤10;
The corresponding sample stick figure of k sample portrait is obtained, to k sample stick figure corresponding to ith pixel point The gray value weighted sum of regional area obtains the expectation gray value of ith pixel point;
According to the expectation gray value of each pixel of the geometric transformation portrait in lines probability distribution area, the phase is generated Hope stick figure.
In one embodiment, processor 101 calls in memory 105 the drafting portrait stick figure program that stores can be with Execute following operation:
Multiple characteristic points of target portrait are extracted using training pattern;
Geometric transformation is carried out to target portrait according to characteristic point, makes the characteristic point of the geometric transformation portrait obtained and has trained The feature point alignment of standard portrait in model.
The described device and its place terminal for drawing portrait stick figure of the present embodiment Fig. 1, uses preset lines Probability distribution area selected pixels point from the target portrait after geometric transformation, and only the pixel of selection is handled, greatly The quantity for reducing processing pixel greatly, improves processing speed;Meanwhile also using in edge image amendment expectation stick figure Gray value enables the lines gray value corrected in stick figure more accurately to sketch out portrait profile, further improves final The accuracy of the stick figure of generation.
As shown in Fig. 2, Fig. 2 is the flow chart of the first embodiment for the method that the present invention draws portrait stick figure.This implementation The method for the drafting portrait stick figure that example is mentioned, comprising steps of
Step S09, preset training pattern, the training pattern include standard portrait, lines probability distribution area and Stick figure template;
In the present embodiment, multiple groups sample portrait and the modeling of sample stick figure are first passed through in advance, obtains the model trained.It is building In mold process, the feature point for calibration first on each sample portrait calculates the mean place of the characteristic point of each sample portrait, root Standard portrait is obtained according to the mean place of characteristic point, then each group sample portrait and its corresponding sample stick figure are done into geometry change Change, the sample portrait and sample stick figure after making geometric transformation all with standard portrait geometric alignment, then according to geometric transformation after Each sample lines draw the control parameters of each lines, generate unified stick figure template, complete modeling.
Step S10 carries out geometric transformation to target portrait using training pattern, obtains and the standard in training pattern The geometric transformation portrait of portrait geometric alignment;
It, can be by the photo of terminal photographic subjects portrait or from terminal when user needs terminal for target portrait stick figure The photo of target portrait is obtained in memory.The training pattern that terminal is obtained by aforementioned modeling is to the target portrait in photo Geometric transformation is carried out, target portrait and the standard portrait geometric alignment in training pattern are made.
Step S20 chooses picture from geometric transformation portrait using lines probability distribution area preset in training pattern Vegetarian refreshments;
In view of target portrait is after geometric transformation, pixel required for drafting stick figure is distributed in limited sky Between in, for example, then only needing face, eyes, nose, mouth, eyebrow, ear to the face in photo is depicted as stick figure Piece, the profile at the positions such as hair style, therefore lines probability distribution area can be preset, will be used to draw stick figure in portrait Necessary pixel is included in this lines probability distribution area, and uses lines probability distribution area from geometric transformation people The selected pixels point as in.
Step S30, the pixel chosen in geometric transformation portrait to lines probability distribution area sample, and obtain the phase Hope stick figure;
To show that gray value needed for stick figure, the present embodiment carry out geometric transformation portrait using non-parametric sampling mode Processing obtains expectation stick figure.To improve processing speed, it is only necessary to be carried out to the pixel that lines probability distribution area is chosen non- Parametrization sampling, advantageously reduces the quantity of processing pixel, improves processing speed.
Step S40 determines the edge image of geometric transformation portrait;
Step S50 corrects expectation stick figure using edge image, obtains amendment stick figure;
In order to further enable it is expected that the gray value of each pixel in stick figure more accurately draws out clearly line Item is drawn, and the present embodiment is also added into boundary operator to obtain the edge image of geometric transformation portrait, obtains each main spy in portrait Profile of sign, such as eye socket, eye benevolence, the profile of nose, nozzle type, face mask etc., and using edge image amendment expectation lines The gray value of pixel in picture obtains amendment stick figure, the lines gray value corrected in stick figure is enable more accurately to delineate Portrait profile out.
Step S60 corrects stick figure using the stick figure stencil matching of training pattern, generates the corresponding mesh of target portrait Mark stick figure.
Due to obtained amendment stick figure there is also part without between the lines or lines drawn there are interdependence or The rule of repulsion, according to the rule between the lines that stick figure template is included in model, to adjust the control ginseng of amendment stick figure Number, clashes some unnecessary lines or gray value, and prominent some necessary lines ultimately generate optimal target lines It draws.Further, since the present embodiment carries out geometric transformation to target portrait using training pattern in advance, therefore can also will match Stick figure afterwards carries out the inverse transformation of geometric transformation, obtains the target stick figure with original target portrait geometric alignment, so that The stick figure arrived is truer.
The present embodiment uses preset lines probability distribution area selected pixels from the target portrait after geometric transformation Point, and only the pixel of selection is handled, the quantity of processing pixel is greatly reduced, processing speed is improved;Meanwhile Also using the gray value in edge image amendment expectation stick figure, keep the lines gray value corrected in stick figure more accurate Portrait profile is sketched out, the accuracy of the stick figure ultimately generated is further improved.
As shown in figure 3, Fig. 3 is that the present invention draws acquisition lines probability distribution area in the embodiment of the method for portrait stick figure Step flow chart.For the present embodiment for the lines probability distribution area in the step S09 of embodiment illustrated in fig. 2, use is following Step obtains:
Step S71 obtains the coordinate of the black pixel point of each sample stick figure of training pattern;
The coordinate of all black pixel points is superimposed by step S72, and the coordinate set of acquisition constitutes lines probability distribution area Domain.
The present embodiment improves processing speed, during modeling training, will train to reduce the pixel quantity of processing All sample stick figures are overlapped in model, merge the coordinate of the black pixel point of each sample stick figure, are owned The coordinate set of black pixel point in sample stick figure, as shown in figure 9, the left side is each sample stick figure before superposition in Fig. 9, it is right Side is the coordinate set of the black pixel point obtained after being superimposed, the pixel for including, to draw in the region of this coordinate set Pixel necessary to stick figure processed.Due to using preset lines probability distribution area from the target portrait after geometric transformation Middle selected pixels point, and only the pixel of selection is handled, the quantity of processing pixel is greatly reduced, processing is improved Speed.
As shown in figure 4, Fig. 4 is the flow chart of the second embodiment for the method that the present invention draws portrait stick figure.This implementation Example includes all steps in embodiment illustrated in fig. 2, and wherein step S50 includes:
Step S51, using lines probability distribution area from edge image selected pixels point;
Step S52, the pixel amendment chosen in edge image using lines probability distribution area it is expected in stick figure The pixel gray value of corresponding position obtains amendment stick figure.
In the present embodiment, to make it is expected that the pixel gray value in stick figure more accurately delineates portrait profile, using side The pixel of edge image corrects the gray value of desired stick figure, makes it is expected that lines not black enough in stick figure are more clear, can It is main to choose the black pixel point in edge image to correct the gray value of desired stick figure.In addition, in order to reduce the picture of processing Lines probability distribution area selected pixels point from edge image can be used, only with the pixel in selected range in vegetarian refreshments quantity Point is conducive to further increase processing speed to correct desired stick figure.
As shown in figure 5, Fig. 5 is the flow chart of the 3rd embodiment for the method that the present invention draws portrait stick figure.This implementation Example includes all steps in embodiment illustrated in fig. 2, and wherein step S30 includes:
Step S31 carries out neighborhood to each pixel that lines probability distribution area is chosen in geometric transformation portrait Images match, calculate the gray value of the regional area corresponding to ith pixel point of n sample portrait in training pattern with And the similarity relative to ith pixel point, and obtain similarity be greater than similar threshold value k sample portrait, as with i-th The matched sample portrait of pixel regional area, wherein 1≤n≤20,1≤k≤10;
Step S32 obtains the corresponding sample stick figure of k sample portrait, to k sample stick figure corresponding to i-th The gray value weighted sum of the regional area of pixel obtains the expectation gray value of ith pixel point;
Step S33, according to the expectation gray scale of each pixel of the geometric transformation portrait in lines probability distribution area Value generates expectation stick figure.
The present embodiment is to further increase processing speed, reduces the sample size for neighborhood matching.Due to existing In neighborhood matching method, when sample size selection is very few, much noise can be generated, makes to generate many broken strings in the lines drawn Part.But due to after the present embodiment extended meeting the phase that the present embodiment obtains is corrected using the edge image that boundary operator obtains It hopes stick figure, makes it is expected that the disconnection portion of lines in stick figure gets repairing, therefore the present embodiment can reduce sample size, by sample This quantity n is reduced within 20, or even can be reduced to 10, only by the pixel of a small amount of sample portrait and geometric transformation portrait Point carries out neighborhood matching, obtains similarity of this portrait of various kinds relative to each pixel, and by the higher k sample people of similarity As the matched sample portrait with the pixel.Due to the reduction of sample size, correspondingly, k value can also be reduced, such as It is reduced within 10, or even is reduced to 3, obtained expectation stick figure will not influence most after edge image is corrected The image effect obtained eventually.In this way, have processing speed due to the reduction of sample size and the reduction of k value Effect improves.
As shown in fig. 6, Fig. 6 is the flow chart of the fourth embodiment for the method that the present invention draws portrait stick figure.This implementation Example includes all steps in embodiment illustrated in fig. 2, and wherein step S10 includes:
Step S11 extracts multiple characteristic points of target portrait using training pattern;
Step S12 carries out geometric transformation to target portrait according to characteristic point, makes the characteristic point of the geometric transformation portrait obtained With the feature point alignment of the standard portrait in training pattern.
The present embodiment, according to the characteristic point demarcated on each sample portrait, has been trained in modeling process early period Therefore model when needing target portrait stick figure, directlys adopt the feature of the i.e. extractable target person picture of training pattern Point.When to target portrait geometric transformation, the feature point alignment of the characteristic point of geometric transformation portrait and standard portrait obtains several What transformation portrait.To target portrait geometric transformation by the way of feature point alignment, be conducive to reduce present in conversion process Error reduces the error of subsequent processing, keeps the stick figure drawn more accurate.
As shown in fig. 7, Fig. 7 is the module diagram of the first embodiment for the device that the present invention draws portrait stick figure.This The device for the drafting portrait stick figure that embodiment is mentioned, comprising:
Model generation module 110 is used for preset training pattern, and training pattern includes standard portrait, lines probability point Cloth region and stick figure template;
Geometric transformation module 120 is obtained and has been trained for carrying out geometric transformation to target portrait using training pattern The geometric transformation portrait of standard portrait geometric alignment in model;
Sampling module 130, for using preset lines probability distribution area in training pattern from geometric transformation portrait Middle selected pixels point, the pixel chosen in geometric transformation portrait to lines probability distribution area sample, it is expected that Stick figure;
Correction module 140, for determining the edge image of geometric transformation portrait, and using edge image amendment expectation lines It draws, obtains amendment stick figure;
Stencil matching module 150 generates target for correcting stick figure using the stick figure stencil matching of training pattern The corresponding target stick figure of portrait.
In the present embodiment, multiple groups sample portrait and the modeling of sample stick figure are first passed through in advance, obtains the model trained.It is building In mold process, the feature point for calibration first on each sample portrait calculates the mean place of the characteristic point of each sample portrait, root Standard portrait is obtained according to the mean place of characteristic point, then each group sample portrait and its corresponding sample stick figure are done into geometry change Change, the sample portrait and sample stick figure after making geometric transformation all with standard portrait geometric alignment, then according to geometric transformation after Each sample lines draw the control parameters of each lines, generate unified stick figure template, complete modeling.
It, can be by the photo of terminal photographic subjects portrait or from terminal when user needs terminal for target portrait stick figure The photo of target portrait is obtained in memory.The training pattern that terminal is obtained by aforementioned modeling is to the target portrait in photo Geometric transformation is carried out, target portrait and the standard portrait geometric alignment in training pattern are made.
In view of target portrait is after geometric transformation, pixel required for drafting stick figure is distributed in limited sky Between in, for example, then only needing face, eyes, nose, mouth, eyebrow, ear to the face in photo is depicted as stick figure Piece, the profile at the positions such as hair style, therefore lines probability distribution area can be preset, will be used to draw stick figure in portrait Necessary pixel is included in this lines probability distribution area, and uses lines probability distribution area from geometric transformation people The selected pixels point as in.
To show that gray value needed for stick figure, the present embodiment carry out geometric transformation portrait using non-parametric sampling mode Processing obtains expectation stick figure.To improve processing speed, it is only necessary to be carried out to the pixel that lines probability distribution area is chosen non- Parametrization sampling, advantageously reduces the quantity of processing pixel, improves processing speed.
In order to further enable it is expected that the gray value of each pixel in stick figure more accurately draws out clearly line Item is drawn, and the present embodiment is also added into boundary operator to obtain the edge image of geometric transformation portrait, obtains each main spy in portrait Profile of sign, such as eye socket, eye benevolence, the profile of nose, nozzle type, face mask etc., and using edge image amendment expectation lines The gray value of pixel in picture obtains amendment stick figure, the lines gray value corrected in stick figure is enable more accurately to delineate Portrait profile out.
Due to obtained amendment stick figure there is also part without between the lines or lines drawn there are interdependence or The rule of repulsion, according to the rule between the lines that stick figure template is included in model, to adjust the control ginseng of amendment stick figure Number, clashes some unnecessary lines or gray value, and prominent some necessary lines ultimately generate optimal target lines It draws.Further, since the present embodiment carries out geometric transformation to target portrait using training pattern in advance, therefore can also will match Stick figure afterwards carries out the inverse transformation of geometric transformation, obtains the target stick figure with original target portrait geometric alignment, so that The stick figure arrived is truer.
The present embodiment uses preset lines probability distribution area selected pixels from the target portrait after geometric transformation Point, and only the pixel of selection is handled, the quantity of processing pixel is greatly reduced, processing speed is improved;Meanwhile Also using the gray value in edge image amendment expectation stick figure, keep the lines gray value corrected in stick figure more accurate Portrait profile is sketched out, the accuracy of the stick figure ultimately generated is further improved.
As shown in figure 8, Fig. 8 is the module diagram of the second embodiment for the device that the present invention draws portrait stick figure.This Embodiment includes all modules in embodiment illustrated in fig. 7, and the region also added for obtaining lines probability distribution area is pre- If module 160, which is used for:
Obtain the coordinate of the black pixel point of each sample stick figure of training pattern;
The coordinate of all black pixel points is superimposed, the coordinate set of acquisition constitutes lines probability distribution area.
The present embodiment improves processing speed, during modeling training, will train to reduce the pixel quantity of processing All sample stick figures are overlapped in model, merge the coordinate of the black pixel point of each sample stick figure, are owned The coordinate set of black pixel point in sample stick figure, as shown in figure 9, the left side is each sample stick figure before superposition in Fig. 9, it is right Side is the coordinate set of the black pixel point obtained after being superimposed, the pixel for including, to draw in the region of this coordinate set Pixel necessary to stick figure processed.Due to using preset lines probability distribution area from the target portrait after geometric transformation Middle selected pixels point, and only the pixel of selection is handled, the quantity of processing pixel is greatly reduced, processing is improved Speed.
Further, correction module 140 is also used to:
Using lines probability distribution area from edge image selected pixels point;
Corresponding position in the pixel amendment expectation stick figure chosen in edge image using lines probability distribution area Pixel gray value, obtain amendment stick figure.
In the present embodiment, to make it is expected that the pixel gray value in stick figure more accurately delineates portrait profile, using side The pixel of edge image corrects the gray value of desired stick figure, makes it is expected that lines not black enough in stick figure are more clear, can It is main to choose the black pixel point in edge image to correct the gray value of desired stick figure.In addition, in order to reduce the picture of processing Lines probability distribution area selected pixels point from edge image can be used, only with the pixel in selected range in vegetarian refreshments quantity Point is conducive to further increase processing speed to correct desired stick figure.
Further, sampling module 130 is also used to:
Neighborhood image matching is carried out to each pixel that lines probability distribution area is chosen in geometric transformation portrait, Calculate the regional area corresponding to ith pixel point of n sample portrait in training pattern gray value and relative to The similarity of ith pixel point, and obtain similarity be greater than similar threshold value k sample portrait, as with ith pixel point office The sample portrait of portion's Region Matching, wherein 1≤n≤20,1≤k≤10;
The corresponding sample stick figure of k sample portrait is obtained, to k sample stick figure corresponding to ith pixel point The gray value weighted sum of regional area obtains the expectation gray value of ith pixel point;
According to the expectation gray value of each pixel of the geometric transformation portrait in lines probability distribution area, the phase is generated Hope stick figure.
The present embodiment is to further increase processing speed, reduces the sample size for neighborhood matching.Due to existing In neighborhood matching method, when sample size selection is very few, much noise can be generated, makes to generate many broken strings in the lines drawn Part.But due to after the present embodiment extended meeting the phase that the present embodiment obtains is corrected using the edge image that boundary operator obtains It hopes stick figure, makes it is expected that the disconnection portion of lines in stick figure gets repairing, therefore the present embodiment can reduce sample size, by sample This quantity n is reduced within 20, or even can be reduced to 10, only by the pixel of a small amount of sample portrait and geometric transformation portrait Point carries out neighborhood matching, obtains similarity of this portrait of various kinds relative to each pixel, and by the higher k sample people of similarity As the matched sample portrait with the pixel.Due to the reduction of sample size, correspondingly, k value can also be reduced, such as It is reduced within 10, or even is reduced to 3, obtained expectation stick figure will not influence most after edge image is corrected The image effect obtained eventually.In this way, have processing speed due to the reduction of sample size and the reduction of k value Effect improves.
Further, geometric transformation module 120 is also used to:
Multiple characteristic points of target portrait are extracted using training pattern;
Geometric transformation is carried out to target portrait according to characteristic point, makes the characteristic point of the geometric transformation portrait obtained and has trained The feature point alignment of standard portrait in model.
The present embodiment, according to the characteristic point demarcated on each sample portrait, has been trained in modeling process early period Therefore model when needing target portrait stick figure, directlys adopt the feature of the i.e. extractable target person picture of training pattern Point.When to target portrait geometric transformation, the feature point alignment of the characteristic point of geometric transformation portrait and standard portrait obtains several What transformation portrait.To target portrait geometric transformation by the way of feature point alignment, be conducive to reduce present in conversion process Error reduces the error of subsequent processing, keeps the stick figure drawn more accurate.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or device.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a storage medium In (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, computer, clothes Business device or the network equipment etc.) execute method described in each embodiment of the present invention.
The above description is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all utilizations Equivalent structure or equivalent flow shift made by description of the invention and accompanying drawing content is applied directly or indirectly in other correlations Technical field, be included within the scope of the present invention.

Claims (8)

1. a kind of method for drawing portrait stick figure, which is characterized in that comprising steps of
Preset training pattern, the training pattern include standard portrait, lines probability distribution area and stick figure template, In, the lines probability distribution area is obtained using following steps: obtaining each sample stick figure of training pattern The coordinate of all black pixel points is superimposed by the coordinate of black pixel point, and the coordinate set of acquisition constitutes the lines probability point Cloth region;
Geometric transformation is carried out to target portrait using training pattern, is obtained and the standard portrait geometry in the training pattern The geometric transformation portrait of alignment;
Using preset lines probability distribution area in the training pattern from the geometric transformation portrait selected pixels point, The pixel chosen in the geometric transformation portrait according to the lines probability distribution area is sampled, expectation line is obtained Item is drawn;
It determines the edge image of the geometric transformation portrait, and the expectation stick figure is corrected using the edge image, obtain Correct stick figure;
Stick figure is corrected described in stick figure stencil matching using the training pattern, generates the corresponding mesh of the target portrait Mark stick figure.
2. drawing the method for portrait stick figure as described in claim 1, which is characterized in that described to correct institute using edge image Desired stick figure is stated, obtaining the step of correcting stick figure includes:
Using the lines probability distribution area from the edge image selected pixels point;
It is corrected in the expectation stick figure using the pixel that the lines probability distribution area is chosen in the edge image The pixel gray value of corresponding position obtains the amendment stick figure.
3. drawing the method for portrait stick figure as claimed in claim 1 or 2, which is characterized in that described to according to lines probability The pixel that distributed areas are chosen in the geometric transformation portrait is sampled, and is obtained the step of it is expected stick figure and is included:
Neighborhood image is carried out to each pixel that the lines probability distribution area is chosen in the geometric transformation portrait Matching, calculate the gray value of the regional area corresponding to ith pixel point of n sample portrait in the training pattern with And the similarity relative to ith pixel point, and obtain similarity be greater than similar threshold value k sample portrait, as with i-th The matched sample portrait of pixel regional area, wherein 1≤n≤20,1≤k≤10;
The corresponding sample stick figure of k sample portrait is obtained, to the part corresponding to ith pixel point of k sample stick figure The gray value weighted sum in region obtains the expectation gray value of ith pixel point;
It is raw according to the expectation gray value of each pixel of the geometric transformation portrait in the lines probability distribution area At desired stick figure.
4. drawing the method for portrait stick figure as claimed in claim 1 or 2, which is characterized in that described using training pattern Geometric transformation is carried out to target portrait, obtains the geometric transformation portrait with the standard portrait geometric alignment in the training pattern The step of include:
Multiple characteristic points of the target portrait are extracted using training pattern;
Geometric transformation is carried out to the target portrait according to the characteristic point, makes the characteristic point of the geometric transformation portrait obtained With the feature point alignment of the standard portrait in the training pattern.
5. a kind of device for drawing portrait stick figure characterized by comprising
Model generation module is used for preset training pattern, and the training pattern includes standard portrait, lines probability distribution area Domain and stick figure template;
Geometric transformation module obtains for carrying out geometric transformation to target portrait using training pattern and has trained mould with described The geometric transformation portrait of standard portrait geometric alignment in type;
Sampling module, for using preset lines probability distribution area in the training pattern from the geometric transformation portrait Middle selected pixels point, adopts the pixel chosen in the geometric transformation portrait according to the lines probability distribution area Sample obtains expectation stick figure;
Correction module corrects the phase for determining the edge image of the geometric transformation portrait, and using the edge image It hopes stick figure, obtains amendment stick figure;
Stencil matching module generates institute for correcting stick figure using described in the stick figure stencil matching of training pattern State the corresponding target stick figure of target portrait;
Described device further includes region presetting module, is used for: obtaining the black of each sample stick figure of training pattern The coordinate of pixel;The coordinate of all black pixel points is superimposed, the coordinate set of acquisition constitutes lines probability distribution area Domain.
6. drawing the device of portrait stick figure as claimed in claim 5, which is characterized in that the correction module is also used to:
Using the lines probability distribution area from the edge image selected pixels point;
It is corrected in the expectation stick figure using the pixel that the lines probability distribution area is chosen in the edge image The pixel gray value of corresponding position obtains the amendment stick figure.
7. such as the device described in claim 5 or 6 for drawing portrait stick figure, which is characterized in that the sampling module is also used to:
Neighborhood image is carried out to each pixel that the lines probability distribution area is chosen in the geometric transformation portrait Matching, calculate the gray value of the regional area corresponding to ith pixel point of n sample portrait in the training pattern with And the similarity relative to ith pixel point, and obtain similarity be greater than similar threshold value k sample portrait, as with i-th The matched sample portrait of pixel regional area, wherein 1≤n≤20,1≤k≤10;
The corresponding sample stick figure of k sample portrait is obtained, to the part corresponding to ith pixel point of k sample stick figure The gray value weighted sum in region obtains the expectation gray value of ith pixel point;
It is raw according to the expectation gray value of each pixel of the geometric transformation portrait in the lines probability distribution area At desired stick figure.
8. such as the device described in claim 5 or 6 for drawing portrait stick figure, which is characterized in that the geometric transformation module is also For:
Multiple characteristic points of the target portrait are extracted using training pattern;
Geometric transformation is carried out to the target portrait according to the characteristic point, makes the characteristic point of the geometric transformation portrait obtained With the feature point alignment of the standard portrait in the training pattern.
CN201510319160.7A 2015-06-11 2015-06-11 The method and apparatus for drawing portrait stick figure Active CN106296569B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510319160.7A CN106296569B (en) 2015-06-11 2015-06-11 The method and apparatus for drawing portrait stick figure

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510319160.7A CN106296569B (en) 2015-06-11 2015-06-11 The method and apparatus for drawing portrait stick figure

Publications (2)

Publication Number Publication Date
CN106296569A CN106296569A (en) 2017-01-04
CN106296569B true CN106296569B (en) 2019-08-02

Family

ID=57660294

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510319160.7A Active CN106296569B (en) 2015-06-11 2015-06-11 The method and apparatus for drawing portrait stick figure

Country Status (1)

Country Link
CN (1) CN106296569B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109727299A (en) * 2018-11-20 2019-05-07 广东智媒云图科技股份有限公司 A kind of control mechanical arm combines the method drawn a picture, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6845171B2 (en) * 2001-11-19 2005-01-18 Microsoft Corporation Automatic sketch generation
CN101159064A (en) * 2007-11-29 2008-04-09 腾讯科技(深圳)有限公司 Image generation system and method for generating image
CN104123741A (en) * 2014-06-24 2014-10-29 小米科技有限责任公司 Method and device for generating human face sketch
CN104484650A (en) * 2014-12-09 2015-04-01 北京信息科技大学 Method and device for identifying sketch face

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6845171B2 (en) * 2001-11-19 2005-01-18 Microsoft Corporation Automatic sketch generation
CN101159064A (en) * 2007-11-29 2008-04-09 腾讯科技(深圳)有限公司 Image generation system and method for generating image
CN104123741A (en) * 2014-06-24 2014-10-29 小米科技有限责任公司 Method and device for generating human face sketch
CN104484650A (en) * 2014-12-09 2015-04-01 北京信息科技大学 Method and device for identifying sketch face

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Example- based Facial Sketch Generation with Non-parametric Sampling;Hong Chen等;《ICCV 2001》;20010714;433-438
基于学习的人脸表情动画生成方法研究;刘莎;《中国优秀硕士学位论文全文数据库信息科技辑》;20140115;I138-1960

Also Published As

Publication number Publication date
CN106296569A (en) 2017-01-04

Similar Documents

Publication Publication Date Title
CN107146199B (en) Fusion method and device of face images and computing equipment
CN109829930B (en) Face image processing method and device, computer equipment and readable storage medium
JP7129502B2 (en) Face image processing method and device, image equipment and storage medium
CN107507216B (en) Method and device for replacing local area in image and storage medium
CN107507217B (en) Method and device for making certificate photo and storage medium
CN110443205B (en) Hand image segmentation method and device
CN107564080B (en) Face image replacement system
CN111383232B (en) Matting method, matting device, terminal equipment and computer readable storage medium
WO2019187298A1 (en) Image processing system and image processing method
US11200680B2 (en) Image processing method and apparatus
CN106709931B (en) Method for mapping facial makeup to face and facial makeup mapping device
CN111127486A (en) Image segmentation method, device, terminal and storage medium
CN112308944A (en) Augmented reality display method of simulated lip makeup
CN111353956A (en) Image restoration method and device, computer equipment and storage medium
CN112347288A (en) Character and picture vectorization method
CN106296569B (en) The method and apparatus for drawing portrait stick figure
CN110472600A (en) The identification of eyeground figure and its training method, device, equipment and storage medium
US20220414902A1 (en) Method for identifying authenticity of an object
US10354125B2 (en) Photograph processing method and system
CN115249362B (en) OCR table recognition method and system based on connectivity of pixels in stable direction
CN110458754B (en) Image generation method and terminal equipment
CN106485648A (en) Image acquisition device with correction function and correction method of image acquisition device
US20210374916A1 (en) Storage medium storing program, image processing apparatus, and training method of machine learning model
US11200708B1 (en) Real-time color vector preview generation
CN114782600A (en) Video specific area rendering system and rendering method based on auxiliary grid

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant