CN109087377A - Method and apparatus for handling image - Google Patents

Method and apparatus for handling image Download PDF

Info

Publication number
CN109087377A
CN109087377A CN201810879994.7A CN201810879994A CN109087377A CN 109087377 A CN109087377 A CN 109087377A CN 201810879994 A CN201810879994 A CN 201810879994A CN 109087377 A CN109087377 A CN 109087377A
Authority
CN
China
Prior art keywords
image
pixel
hair
curve
match
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.)
Granted
Application number
CN201810879994.7A
Other languages
Chinese (zh)
Other versions
CN109087377B (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.)
Douyin Vision Co Ltd
Douyin Vision Beijing Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201810879994.7A priority Critical patent/CN109087377B/en
Publication of CN109087377A publication Critical patent/CN109087377A/en
Application granted granted Critical
Publication of CN109087377B publication Critical patent/CN109087377B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Abstract

The embodiment of the present application discloses the method and apparatus for handling image.One specific embodiment of this method includes: to obtain target cranial image;Hair image is determined from target cranial image, and determines the extending direction for the pixel that hair image includes;From hair image, starting pixels point set is determined;The extending direction of the starting pixels point is determined based on the extending direction for the pixel that identified hair image includes for the starting pixels point in starting pixels point set;Based on the extending direction of the starting pixels point, determine that the starting pixels point is corresponding to match pixel point set;Based on identified to match pixel point set, hair curve is drawn in target cranial image.This embodiment improves the accuracys that hair curve is drawn in head image, and improve the flexibility of processing hair image.

Description

Method and apparatus for handling image
Technical field
The invention relates to field of computer technology, and in particular to the method and apparatus for handling image.
Background technique
With the development of image processing techniques, currently, occurring much answering for handling the application of image using these With operations such as user can deform the image of shooting, add material.The application of existing image procossing, if user Want more to be restyled the hair to the hair image that the head image of shooting includes, add hair etc. operation when, it is common practice to know The position of other hair image, then new hair image is inserted at the position of hair image.
Summary of the invention
The embodiment of the present application proposes the method and apparatus for handling image.
In a first aspect, the embodiment of the present application provides a kind of method for handling image, this method comprises: obtaining target Head image;Hair image is determined from target cranial image, and determines the extending direction for the pixel that hair image includes; From hair image, starting pixels point set is determined;For the starting pixels point in starting pixels point set, based on determined by The extending direction for the pixel that hair image includes determines the extending direction of the starting pixels point;Based on the starting pixels point Extending direction determines that the starting pixels point is corresponding to match pixel point set;Based on identified to match pixel point set, Hair curve is drawn in target cranial image.
In some embodiments, the extending direction based on the starting pixels point determines that the starting pixels point is corresponding to quasi- Close pixel collection, comprising: the starting pixels point is determined as to match pixel point, executes and following determines step: determine with to The distance of match pixel point is pre-determined distance and is in the pixel on the extending direction to match pixel point as pixel undetermined Point;Determine whether pixel undetermined is located in the region of hair image;It, will in response to determining not in the region of hair image It is corresponding to match pixel that set fixed, in hair image to match pixel point is determined as the starting pixels point Point set;It is located in the region of hair image in response to determining, based on the extension for the pixel that identified hair image includes Direction, determines the extending direction of pixel undetermined, and the pixel undetermined that the last time is determined is as to match pixel point, Continue to execute determining step.
In some embodiments, from hair image, starting pixels point set is determined, comprising: from hair image, determine Top area image;Top area image is divided into the first grid image set;For in the first grid image set One grid image selects pixel as starting pixels point from first grid image.
In some embodiments, from hair image, before determining starting pixels point set, method further include: by head Hair image is divided into the second grid image set.
In some embodiments, the extending direction for the pixel for including based on identified hair image, determines the starting The extending direction of pixel, comprising: from the second grid image set, the second grid image where determining starting pixels point is made For starting mesh image;It determines the mean direction of the extending direction for the pixel that starting mesh image includes, and determines starting The mean direction of the extending direction for the pixel that the adjacent mesh image of grid image includes;Based on preset, starting mesh figure The direction weight of picture and the direction weight of adjacent mesh image, are weighted read group total to identified mean direction, will count Calculate the extending direction that result is determined as starting pixels point.
In some embodiments, hair image is determined from target cranial image, comprising: input target cranial image pre- First trained hair image recognition model, obtains hair image, wherein hair image recognition model for characterize head image with The corresponding relationship of hair image.
In some embodiments, the extending direction for the pixel that hair image includes is determined, comprising: determine hair image packet The color change gradient direction of the pixel included, wherein color change gradient direction is used to characterize the color change width of pixel Spend maximum direction;The vertical direction of the color change gradient direction of identified pixel is determined as the to be processed of pixel Extending direction;Based on smothing filtering algorithm, the extending direction to be processed for the pixel that hair image includes is handled, is obtained The extending direction for the pixel that hair image includes.
In some embodiments, hair is drawn in target cranial image to match pixel point set based on determined by Curve, comprising: corresponding to, to match pixel point, treat match pixel in match pixel point set based on the starting pixels point Point carries out curve fitting, and obtains initial matched curve;Following plot step is executed using initial matched curve: being determined obtained Whether initial matched curve includes curved section of the curvature greater than predetermined curvature threshold value;Do not include in response to determination, in target cranial Initial matched curve is drawn in image as hair curve.
In some embodiments, this method further include: include that will be located at the song greater than predetermined curvature threshold value in response to determination Being deleted to match pixel point set to match pixel point at line segment;It treats remaining wait be fitted in match pixel point set Pixel carries out curve fitting, and obtains new initial matched curve;Using new initial matched curve, drafting step is continued to execute Suddenly.
In some embodiments, this method further include: include in response to determination determine be located at aim curve section to quasi- Close pixel and put in order place at the aim curve section to match pixel point after to match pixel point as truncation picture Vegetarian refreshments, wherein aim curve section is in initial matched curve, greater than the curved section of predetermined curvature threshold value;Song will be initially fitted Curved section deletion in line, being fitted according to truncation pixel;It is drawn on target cranial image in initial matched curve Remaining curved section is as hair curve;Curve matching is re-started to truncation pixel, new initial matched curve is obtained, adopts Plot step is continued to execute with new initial matched curve.
Second aspect, the embodiment of the present application provide it is a kind of for handling the device of image, the device include: obtain it is single Member is configured to obtain target cranial image;First determination unit is configured to determine hair figure from target cranial image Picture, and determine the extending direction for the pixel that hair image includes;Second determination unit is configured to from hair image, Determine starting pixels point set;Drawing unit is configured to for the starting pixels point in starting pixels point set, really based on institute The extending direction for the pixel that fixed hair image includes determines the extending direction of the starting pixels point;Based on the starting pixels The extending direction of point, determines that the starting pixels point is corresponding to match pixel point set;Based on identified to match pixel point Set draws hair curve in target cranial image.
In some embodiments, drawing unit includes: the first determining module, is configured to for the starting pixels point being determined as To match pixel point, executes following determining step: determining at a distance to match pixel point and be pre-determined distance and be in wait be fitted Pixel on the extending direction of pixel is as pixel undetermined;Determine whether pixel undetermined is located at the region of hair image In;In response to determining in the region of hair image, by it is fixed, in hair image to match pixel point It is corresponding to match pixel point set that set is determined as the starting pixels point;Second determining module is configured in response to determine In the region of hair image, based on the extending direction for the pixel that identified hair image includes, pixel undetermined is determined The extending direction of point, and the pixel undetermined that the last time is determined continue to execute determining step as to match pixel point.
In some embodiments, the second determination unit includes: third determining module, is configured to from hair image, really Determine top area image;Division module is configured to for top area image to be divided into the first grid image set;Select mould Block is configured to select pixel from first grid image for the first grid image in the first grid image set As starting pixels point.
In some embodiments, device further include: division unit is configured to hair image being divided into the second grid Image collection.
In some embodiments, drawing unit includes: the 4th determining module, is configured to from the second grid image set In, determine the second grid image where starting pixels point as starting mesh image;5th determining module, is configured to determine The mean direction of the extending direction for the pixel that starting mesh image includes, and determine the adjacent net trrellis diagram of starting mesh image As the mean direction of the extending direction for the pixel for including;Computing module is configured to based on preset, starting mesh image The direction weight of direction weight and adjacent mesh image is weighted read group total to identified mean direction, ties calculating Fruit is determined as the extending direction of starting pixels point.
In some embodiments, the first determination unit is further configured to: target cranial image is inputted training in advance Hair image recognition model, obtain hair image, wherein hair image recognition model is for characterizing head image and hair figure The corresponding relationship of picture.
In some embodiments, the first determination unit includes: the 6th determining module, is configured to determine hair image and includes Pixel color change gradient direction, wherein color change gradient direction is used to characterize the color variation amplitude of pixel Maximum direction;7th determining module is configured to the vertical direction of the color change gradient direction of identified pixel It is determined as the extending direction to be processed of pixel;Processing module is configured to be based on smothing filtering algorithm, includes to hair image The extending direction to be processed of pixel handled, obtain the extending direction for the pixel that hair image includes.
In some embodiments, drawing unit includes: fitting module, be configured to based on the starting pixels point it is corresponding to In match pixel point set to match pixel point, treat match pixel point and carry out curve fitting, obtain initial matched curve;It draws Molding block is configured to execute following plot step using initial matched curve: whether determining obtained initial matched curve It is greater than the curved section of predetermined curvature threshold value comprising curvature;Do not include in response to determination, is drawn in target cranial image initial quasi- Curve is closed as hair curve.
In some embodiments, drawing unit is further configured to: including that will be located at and be greater than default song in response to determination Being deleted to match pixel point set to match pixel point at the curved section of rate threshold value;It treats in match pixel point set and remains Remaining carries out curve fitting to match pixel point, obtains new initial matched curve;Using new initial matched curve, continue to hold Row plot step.
In some embodiments, drawing unit is further configured to: including to determine and be located at aim curve in response to determination Section place to match pixel point with put in order place at the aim curve section to match pixel point after to match pixel point As truncation pixel, wherein aim curve section is in initial matched curve, greater than the curved section of predetermined curvature threshold value;It will Curved section deletion in initial matched curve, being fitted according to truncation pixel;It is drawn on target cranial image initial quasi- The remaining curved section in curve is closed as hair curve;Curve matching is re-started to truncation pixel, is obtained new initial Matched curve continues to execute plot step using new initial matched curve.
The third aspect, the embodiment of the present application provide a kind of electronic equipment, which includes: one or more processing Device;Storage device is stored thereon with one or more programs;When one or more programs are executed by one or more processors, So that one or more processors realize the method as described in implementation any in first aspect.
Fourth aspect, the embodiment of the present application provide a kind of computer-readable medium, are stored thereon with computer program, should The method as described in implementation any in first aspect is realized when computer program is executed by processor.
Method and apparatus provided by the embodiments of the present application for handling image, by from the target cranial image of acquisition It determines hair image, and determines the extending direction for the pixel that hair image includes, then from hair image, determine starting picture Vegetarian refreshments set finally determines that the starting pixels point in starting pixels point set is corresponding to match pixel point set, and is based on To match pixel point set, hair curve is drawn in target cranial image, draws hair in head image to improve The accuracy of curve, and improve the flexibility of processing hair image.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that one embodiment of the application can be applied to exemplary system architecture figure therein;
Fig. 2 is the flow chart according to one embodiment of the method for handling image of the embodiment of the present application;
Fig. 3 is the method according to the embodiment of the present application for handling image based on to match pixel point set march The illustrative diagram of the process of line fitting;
Fig. 4 is the schematic diagram according to an application scenarios of the method for handling image of the embodiment of the present application;
Fig. 5 is the flow chart according to another embodiment of the method for handling image of the embodiment of the present application;
Fig. 6 is the structural schematic diagram according to one embodiment of the device for handling image of the embodiment of the present application;
Fig. 7 is adapted for the structural schematic diagram for the computer system for realizing the electronic equipment of the embodiment of the present application.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 is shown can the method for handling image using the embodiment of the present application or the device for handling image Exemplary system architecture 100.
As shown in Figure 1, system architecture 100 may include terminal device 101,102,103, network 104 and server 105. Network 104 between terminal device 101,102,103 and server 105 to provide the medium of communication link.Network 104 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 101,102,103 and be interacted by network 104 with server 105, to receive or send out Send message etc..Various applications, such as image processing class application, video playing can be installed on terminal device 101,102,103 Class application, social platform software etc..
Terminal device 101,102,103 can be hardware, be also possible to software.When terminal device 101,102,103 is hard When part, it can be with display screen and the various electronic equipments of supporting image to show, including but not limited to smart phone, plate Computer, E-book reader, MP3 player (Moving Picture Experts Group Audio Layer III, dynamic Image expert's compression standard audio level 3), MP4 (Moving Picture Experts Group Audio Layer IV, move State image expert's compression standard audio level 4) player, pocket computer on knee and desktop computer etc..When terminal is set Standby 101,102,103 when being software, may be mounted in above-mentioned cited electronic equipment.Its may be implemented into multiple softwares or Software module (such as providing the software of Distributed Services or software module), also may be implemented into single software or software mould Block.It is not specifically limited herein.
Server 105 can be to provide the server of various services, such as to the figure that terminal device 101,102,103 uploads As providing the backstage image processing server supported.Backstage image processing server can be to the head image of acquisition at Reason, and obtain processing result (such as drawing the head image after hair curve).
It should be noted that the method provided by the embodiment of the present application for handling image can be held by server 105 Row, can also be executed, correspondingly, the device for handling image can be set in server by terminal device 101,102,103 In 105, also it can be set in terminal device 101,102,103.
It should be noted that server can be hardware, it is also possible to software.When server is hardware, may be implemented At the distributed server cluster that multiple servers form, individual server also may be implemented into.It, can when server is software To be implemented as multiple softwares or software module (such as providing the software of Distributed Services or software module), also may be implemented At single software or software module.It is not specifically limited herein.
It should be understood that the number of terminal device, network and server in Fig. 1 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.It does not need in target cranial image from the feelings remotely obtained Under condition, above system framework can not include network, and only include terminal device or server.
With continued reference to Fig. 2, the process of one embodiment of the method for handling image according to the application is shown 200.The method for being used to handle image, comprising the following steps:
Step 201, target cranial image is obtained.
In the present embodiment, (such as server shown in FIG. 1 or terminal are set the executing subject for handling the method for image It is standby) it can be by wired connection mode or radio connection from long-range or from local obtain target cranial image.Wherein, mesh Mark head image can be by preset camera (such as the above-mentioned executing subject camera that includes or with above-mentioned executing subject it is logical Believe the camera of connection) head of target person (such as user or other personages using above-mentioned executing subject) is shot Obtained head image.It should be noted that target cranial image can be individual image;It is also possible to extract from video Picture frame.For example, target cranial image can be figure that the video played in above-mentioned executing subject includes, currently showing As frame.
Step 202, hair image is determined from target cranial image, and determines prolonging for the pixel that hair image includes Stretch direction.
In the present embodiment, above-mentioned executing subject can be true from target cranial image first, in accordance with existing various methods Determine hair image.Wherein, it can include but is not limited to following at least one from the method that head image determines hair image: being based on Color space statistics detection method, based on probabilistic model, the detection method of Gauss model, detection method neural network based Deng.
In some optional implementations of the present embodiment, above-mentioned executing subject can be in accordance with the following steps from target head Hair image is determined in portion's image:
By target cranial image input hair image recognition model trained in advance, hair image is obtained.Wherein, hair figure As identification model is used to characterize the corresponding relationship of head image Yu hair image.
As an example, hair image recognition model may include that Feature Selection Model and information generate model.Feature extraction Model can be using target cranial image as input, for extracting characteristics of image and the output of inputted target cranial image. Information generates model and can connect with Feature Selection Model, the characteristics of image for being exported based on Feature Selection Model, generates table The location information of the position of hair image is levied, and hair image is determined based on location information.It should be noted that herein, Feature Selection Model may include for extracting the structure of characteristics of image (such as convolutional layer), naturally it is also possible to including other structures (such as pond layer).Information generate model may include for generating the structure of information (such as full articulamentum), in addition can also be with Including other structures (such as output layer for exporting obtained hair image).
As another example, above-mentioned hair image recognition model can be based on existing target detection network (such as SSD (Single Shot MultiBox Detector), DPM (Deformable Part Model) etc.) establish model.Hair Image recognition model can determine the position of hair image from inputting in image therein.In general, hair image recognition model can With the location information of output, which can characterize the region in target cranial image.For example, location information may include Two of rectangle frame can determine a rectangle frame to angular coordinate to angular coordinate, by two in target cranial image, thus Determine the position of hair image.It should be noted that above-mentioned target detection network and being trained to target detection network Method is the well-known technique studied and applied extensively at present, and details are not described herein.
In the present embodiment, above-mentioned executing subject may further determine that the extension side for the pixel that hair image includes To.Wherein, extending direction is used to characterize the smallest direction of color variation amplitude of pixel.In general, extending direction can use angle Degree is to characterize.For example, certain pixel for including using hair image establishes rectangular coordinate system as origin, the ray of extending direction is characterized Angle between the horizontal axis positive direction of the rectangular coordinate system can be used for characterizing extending direction.
In the present embodiment, above-mentioned executing subject can determine the extending direction of pixel according to various methods.As showing Example, each pixel in the pixel for including for hair image, above-mentioned executing subject can using the pixel as the center of circle, with Preset length is that radius determines border circular areas, and compares the color change of each pixel of the sideline process of the border circular areas Value will be worth the radius of corresponding pixel and the folder of horizontal direction by color change on the sideline of border circular areas, the smallest Angle is determined as the extending direction of the pixel.Above-mentioned color change value can be some color value of pixel, and (such as RGB is (red Color Green Blue) one of value) difference or rgb value average value difference, or utilize existing calculating picture The difference of the gray value of the calculated pixel of method of the gray value of element.
In some optional implementations of the present embodiment, above-mentioned executing subject can determine hair in accordance with the following steps The extending direction for the pixel that image includes:
Firstly, determining the color change gradient direction for the pixel that hair image includes.Wherein, color change gradient direction The maximum direction of color variation amplitude for characterizing pixel.Specifically, above-mentioned executing subject can use existing calculating The color change gradient direction for the pixel that hair image includes is calculated in the algorithm of image gradient.Image gradient algorithm is logical Often consider the grey scale change in some neighborhood of each pixel of image, the single order closed on using edge or second dervative variation rule Rule is arranged gradient operator to some neighborhood of pixel in original image, is rolled up using gradient operator to each region in image Product calculates, and gradient operator can be Sobel operator, Robinson operator, Laplace operator etc..It should be noted that calculating figure As the algorithm of gradient be at present extensively study and application well-known technique, details are not described herein.
Then, the vertical direction of the color change gradient direction of identified pixel is determined as the to be processed of pixel Extending direction.In general, color change gradient direction is the maximum direction of color change of pixel, the direction vertical with the direction It can be determined as the smallest direction of pixel color change.
Finally, being based on smothing filtering algorithm, the extending direction to be processed for the pixel that hair image includes is handled, Obtain the extending direction for the pixel that hair image includes.In general, the extending direction for each pixel that hair image includes is each It is not identical, in order to make the extending direction of pixel of a small range keep similar, smothing filtering algorithm can be used to each picture The extending direction of vegetarian refreshments is smoothed.In practice, smoothing processing is also referred to as Fuzzy Processing, and there are many purposes, most commonly The resolution ratio of image is perhaps distorted or can be used to reduce for reducing the noise on image.It is above-mentioned in this implementation Smothing filtering algorithm that the common color value to pixel can be smoothed by executing subject be applied to pixel to Processing extending direction is smoothed.To reduce the gap of the extending direction between adjacent pixel.It needs to illustrate It is that above-mentioned smothing filtering algorithm can include but is not limited to following at least one: mean filter, median filtering, gaussian filtering, double Side filtering etc..
Step 203, from hair image, starting pixels point set is determined.
In the present embodiment, above-mentioned executing subject can determine starting pixels point according to various methods from hair image Set.As an example, above-mentioned executing subject can be according to region (such as the crown area that technical staff specifies on hair image Domain), or region (such as top in hair image and area and the hair image delimited automatically by above-mentioned executing subject Area ratio be preset ratio region), according to preset spacing distance, in this region determine starting pixels point set, Wherein, the distance between adjacent starting pixels point is above-mentioned spacing distance.
Step 204, for the starting pixels point in starting pixels point set, the picture for including based on identified hair image The extending direction of vegetarian refreshments determines the extending direction of the starting pixels point;Based on the extending direction of the starting pixels point, this is determined Beginning pixel is corresponding to match pixel point set;Based on identified to match pixel point set, in target cranial image Draw hair curve.
In the present embodiment, for the starting pixels point in starting pixels point set, above-mentioned executing subject can be executed such as Lower step:
Step 2041, the extending direction for the pixel for including based on identified hair image determines the starting pixels point Extending direction.As an example, since the extending direction of pixel that hair image includes being determined in step 202, on The extending direction of the starting pixels point can be determined by stating executing subject.Alternatively, above-mentioned executing subject can will include the starting The mean direction of the extending direction for the pixel that the image-region of pixel, default size includes is determined as the starting pixels point Extending direction.
In some optional implementations of the present embodiment, before step 203, above-mentioned executing subject can be by hair Image is divided into the second grid image set.Specifically, above-mentioned executing subject can add grid in hair image, addition The region of each grid covering is the second grid image.Wherein, the size of each grid of addition can be pre-set Size is also possible to the size come out according to the quantity of preset grid and the areal calculation of hair image.It needs to illustrate It is that the shape of grid can be the arbitrary shapes such as triangle, quadrangle.
In some optional implementations of the present embodiment, it is based on the second grid image set, above-mentioned executing subject can To determine the extending direction of the starting pixels point in accordance with the following steps:
Firstly, the second grid image where determining starting pixels point is used as starting net from the second grid image set Table images.
Then, it is determined that the mean direction of the extending direction for the pixel that starting mesh image includes, and determine starting net The mean direction of the extending direction for the pixel that the adjacent mesh image of table images includes.Specifically, adjacent mesh image can be with It is grid image in the second grid image set, positioned at starting mesh image peripheral.For example, starting mesh image is adjacent The quantity of grid image can be up to 8, be located at the top of starting mesh image, lower section, left, right, upper left side, Upper right side, lower left, lower right.In general, the extending direction for the pixel that grid image includes is characterized with angle value, above-mentioned execution Main body can calculate the average value of the corresponding angle value of each pixel, the pixel for including with average value characterization grid image The mean direction of extending direction.For example, grid image includes four pixels, the corresponding angle value of each pixel is respectively θ 1, θ 2, θ 3, θ 4, then average angle is (θ 1+ θ 2+ θ 3+ θ 4)/4.
Finally, the direction weight based on preset, starting mesh image direction weight and adjacent mesh image, to really Fixed mean direction is weighted read group total, and calculated result is determined as to the extending direction of starting pixels point.In general, starting net The direction weight of table images is greater than the direction weight of adjacent mesh image.For example, the direction weight of starting mesh image is 0.6, The angle value for characterizing the mean direction of starting mesh image is α 1, and the quantity of the adjacent mesh image of the starting mesh image is 4, It is located at top, lower section, left, the right of the starting mesh image, the direction weight of each adjacent mesh image is 0.1, the angle value for characterizing the mean direction of each adjacent mesh image is respectively α 2, α 3, α 4, α 5, then characterizes the starting pixels The angle value of the extending direction of point is α 1*0.6+ α 2*0.1+ α 3*0.1+ α 4*0.1+ α 5*0.1.It, can by using direction weight Using the reference by the color value of the pixel of the neighboring area of starting mesh image as the extending direction for determining starting pixels point Factor, so as to avoid because of head image cross-color caused by each starting pixels point extending direction gap it is excessive, have Help improve the display effect for drawing hair curve.
Step 2042, the extending direction based on the starting pixels point determines that the starting pixels point is corresponding to match pixel Point set.As an example, above-mentioned executing subject can will be located at the starting pixels point extending direction on, and with the starting pixels Pixel of the point apart from pre-determined distance is determined as one to match pixel point, then by the extending direction of starting pixels point to vertical side To offset predetermined angle, the extending direction to match pixel point newly determined, and so on, in the same manner one by one Determine it is new to match pixel point and to the extending direction of match pixel point, to obtain to match pixel point set.
In some optional implementations of the present embodiment, above-mentioned executing subject can determine this in accordance with the following steps Beginning pixel is corresponding to match pixel point set:
Firstly, the starting pixels point is determined as to execute following determining step: determining and picture to be fitted to match pixel point The distance of vegetarian refreshments is pre-determined distance and is in the pixel on the extending direction to match pixel point as pixel undetermined.Really Whether fixed pixel undetermined is located in the region of hair image.It, will really in response to determining in the region of hair image It is corresponding to match pixel point set that set fixed, in hair image to match pixel point is determined as the starting pixels point It closes.It should be noted that the distance between pixel can be the linear distance between pixel, it is also possible to the vertical of pixel The distance between coordinate, wherein ordinate can be the ordinate in the rectangular coordinate system established on hair image.
Then, it is located in response to determination pixel undetermined in the region of hair image, based on identified hair image packet The extending direction of the pixel included determines the extending direction of pixel undetermined, and the pixel undetermined that the last time is determined As to match pixel point, above-mentioned determining step is continued to execute.It should be appreciated that the method for determining the extending direction of pixel undetermined It can be identical as the extending direction of the starting pixels point is determined.
Step 2043, to match pixel point set based on determined by, hair curve is drawn in target cranial image.Tool Body, above-mentioned executing subject can according to existing various curve-fitting methods, using in match pixel point set to quasi- It closes pixel to carry out curve fitting, obtains matched curve, and matched curve is plotted in target cranial image.Above-mentioned curve Approximating method can include but is not limited to following at least one: conic fitting, Cubic Curve Fitting, three rank Beziers Fitting etc..
In some optional implementations of the present embodiment, above-mentioned executing subject can draw fitting in accordance with the following steps Curve:
Firstly, corresponding to, to match pixel point, treat fitting in match pixel point set based on the starting pixels point Pixel carries out curve fitting, and obtains initial matched curve.Specifically, above-mentioned executing subject can be according to existing various curves Approximating method obtains initial matched curve using to carrying out curve fitting in match pixel point set to match pixel point.
Then, following plot step is executed using initial matched curve: determines whether obtained initial matched curve wraps It is greater than the curved section of predetermined curvature threshold value containing curvature.It should be noted that the method for the curvature of calculated curve is to grind extensively at present The well-known technique studied carefully and applied, details are not described herein.Do not include curvature in response to the initial matched curve of determination and is greater than predetermined curvature The curved section of threshold value draws initial matched curve as hair curve in target cranial image.Specifically, executing subject can be with Hair curve is drawn out according to the line width and color of preset hair curve.
In some optional implementations of the present embodiment, above-mentioned executing subject can be in response to determining that initial fitting is bent Line includes the curved section that curvature is greater than predetermined curvature threshold value, first by be located at greater than the curved section of predetermined curvature threshold value to quasi- Pixel is closed to delete to match pixel point set.Then it treats remaining to match pixel click-through in match pixel point set Row curve matching obtains new initial matched curve.Then using new initial matched curve, above-mentioned implementation is continued to execute Described in plot step.By executing this implementation, the hair curve drawn in target cranial image includes each The curvature of curved section, which is respectively less than, is equal to predetermined curvature, so as to reduce hair curve and the instruction of target cranial image of drafting The deviation of the true hair style of personage facilitates the display effect for improving hair curve.
In some optional implementations of the present embodiment, above-mentioned executing subject may also respond to determine initial fitting Curve includes the curved section that curvature is greater than predetermined curvature threshold value, it is first determined at aim curve section to match pixel point and Put in order place at the aim curve section to match pixel point after to match pixel point as truncation pixel.Wherein, Aim curve section is in initial matched curve, greater than the curved section of predetermined curvature threshold value.
Then, by curved section deletion in initial matched curve, being fitted according to truncation pixel.
Then, the remaining curved section in initial matched curve is drawn on target cranial image as hair curve.
Finally, re-starting curve matching to truncation pixel, new initial matched curve is obtained, initial is intended using new It closes curve and continues to execute plot step described in above-mentioned implementation.
As an example, as shown in figure 3, Fig. 3 shows the implementation procedure of this implementation.Each dot characterization in Fig. 3 To match pixel point, 301 be the initial matched curve fitted, the 3011 (song in dotted line frame in such as figure of curved section therein Line segment) curvature be greater than preset curvature threshold, then to match pixel point 302,303,304 be truncation pixel.Then, by root It is deleted according to the curved section that truncation pixel 302,303,304 fits, remaining curve 305 is plotted in target cranial image On.Finally, re-starting curve matching based on truncation pixel 302,303,304, new initial matched curve 306 is obtained, is adopted Above-mentioned plot step is re-executed with new initial matched curve 306, so that it is bent to obtain the corresponding hair of a starting pixels point Line.By executing this implementation, can make full use of to each of include in match pixel point set to match pixel point, and And each curved section that the curve drawn includes respectively less than is equal to preset curvature threshold, to help further to improve hair The display effect of silk curve.
With continued reference to the signal that Fig. 4, Fig. 4 are according to the application scenarios of the method for handling image of the present embodiment Figure.In the application scenarios of Fig. 4, terminal device 401 obtains target cranial image 402 first.Wherein, target cranial image 402 It is the self-timer image of the user of using terminal equipment 401.Then, terminal device 401 is by using neural network trained in advance, Hair image 4021 is determined from target cranial image.Then, each picture that terminal device 401 includes by comparing hair image The gray value of each pixel of the neighboring area of vegetarian refreshments determines the extending direction for each pixel that hair image includes.Again Then, terminal device 401 delimit out top area 4022 from hair image 4021 automatically, and be arranged in advance in region overhead If quantity starting pixels point is as starting pixels point set.4023 in Fig. 4 be a starting in starting pixels point set Pixel.Subsequently, for each starting pixels point in starting pixels point set, terminal device 401 is based on identified head The extending direction for the pixel that hair image includes, determines that each starting pixels point is corresponding to match pixel point set.Finally, It is carried out curve fitting to match pixel point set based on each starting pixels point is corresponding, and by the Drawing of Curve of fitting in mesh It marks and is used as hair curve in head image.As shown in figure 4,4024 be corresponding to match pixel point based on starting pixels point 4023 Set carries out curve fitting, and then draw out a hair curve.
The method provided by the above embodiment of the application, by determining hair image from the target cranial image of acquisition, And determine the extending direction for the pixel that hair image includes, then from hair image, determine starting pixels point set, finally Determine that the starting pixels point in starting pixels point set is corresponding to match pixel point set, and based on to match pixel point set It closes, hair curve is drawn in target cranial image, so that the accuracy that hair curve is drawn in head image is improved, with And improve the flexibility of processing hair image.
With further reference to Fig. 5, it illustrates the processes 500 of another embodiment of the method for handling image.The use In the process 500 of the method for processing image, comprising the following steps:
Step 501, target cranial image is obtained.
In the present embodiment, step 501 and the step 201 in Fig. 2 corresponding embodiment are almost the same, and which is not described herein again.
Step 502, hair image is determined from target cranial image, and determines prolonging for the pixel that hair image includes Stretch direction.
In the present embodiment, step 502 and the step 202 in Fig. 2 corresponding embodiment are almost the same, and which is not described herein again.
Step 503, from hair image, top area image is determined.
In the present embodiment, above-mentioned executing subject can determine top area figure according to various methods from hair image Picture.For example, the area ratio on the top and area and hair image that are located in hair image can be pre- by above-mentioned executing subject If the region of ratio is determined as top area image.Alternatively, above-mentioned executing subject can be known according to existing face identification method Not Chu facial image, by hair image be located at facial image more than region be determined as top area.
Step 504, top area image is divided into the first grid image set.
In the present embodiment, top area image can be divided into the first grid image set by above-mentioned executing subject.Tool Body, above-mentioned executing subject can add grid in area image overhead, and the region of each grid covering of addition is the One grid image.Wherein, the size of each grid of addition can be pre-set size, be also possible to according to preset net The size that the quantity of lattice and the areal calculation of top area image come out.It should be noted that the shape of grid can be three The arbitrary shapes such as angular, quadrangle.
Step 505, for the first grid image in the first grid image set, picture is selected from first grid image Vegetarian refreshments is as starting pixels point.
In the present embodiment, for the first grid image in the first grid image set, above-mentioned executing subject can be from Select pixel as starting pixels point in first grid image.Specifically, above-mentioned executing subject can be according to various methods Pixel is selected from the first grid image, for example, random selection pixel is made from the pixel that the first grid image includes For starting pixels point;Or select the pixel at center in the first grid image, in the first grid image as rise Beginning pixel.By executing this step, available starting picture to each first grid image in the first grid image set Vegetarian refreshments set.
Step 506, for the starting pixels point in starting pixels point set, the picture for including based on identified hair image The extending direction of vegetarian refreshments determines the extending direction of the starting pixels point;Based on the extending direction of the starting pixels point, this is determined Beginning pixel is corresponding to match pixel point set;Based on identified to match pixel point set, in target cranial image Draw hair curve.
In the present embodiment, step 506 and the step 204 in Fig. 2 corresponding embodiment are almost the same, and which is not described herein again.
From figure 5 it can be seen that the method for handling image compared with the corresponding embodiment of Fig. 2, in the present embodiment Process 500 the step of highlighting to starting pixels point set is determined from hair image.The side of the present embodiment description as a result, Case can more accurately determine the position of starting pixels point in target cranial image, draw hair song to further improve The accuracy of line helps to improve the display effect for drawing hair curve.
With further reference to Fig. 6, as the realization to method shown in above-mentioned each figure, this application provides one kind for handling figure One embodiment of the device of picture, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which can specifically answer For in various electronic equipments.
As shown in fig. 6, the present embodiment includes: acquiring unit 601 for handling the device 600 of image, it is configured to obtain Take target cranial image;First determination unit 602 is configured to determine hair image from target cranial image, and determines The extending direction for the pixel that hair image includes;Second determination unit 603, is configured to from hair image, determines starting Pixel collection;Drawing unit 604 is configured to for the starting pixels point in starting pixels point set, based on determined by The extending direction for the pixel that hair image includes determines the extending direction of the starting pixels point;Based on the starting pixels point Extending direction determines that the starting pixels point is corresponding to match pixel point set;Based on identified to match pixel point set, Hair curve is drawn in target cranial image.
In the present embodiment, acquiring unit 601 can by wired connection mode or radio connection from long-range or Target cranial image is obtained from local.Wherein, target cranial image can be by preset camera (such as above-mentioned apparatus 600 Including camera or the camera that is communicated to connect with above-mentioned apparatus 600) (such as above-mentioned apparatus 600 is used to target person User or other personages) the head image that is shot of head.It should be noted that target cranial image can be list Only image;It is also possible to the picture frame extracted from video.For example, target cranial image can be in above-mentioned apparatus 600 Picture frame that the video of broadcasting includes, currently showing.
In the present embodiment, the first determination unit 602 can be first, in accordance with existing various methods from target cranial image Middle determining hair image.Wherein, it can include but is not limited to following at least one from the method that head image determines hair image: Based on color space statistics detection method, based on probabilistic model, the detection method of Gauss model, detection neural network based Method etc..In the present embodiment, the first determination unit 602 may further determine that the extension side for the pixel that hair image includes To.Wherein, extending direction is used to characterize the smallest direction of color variation amplitude of pixel.In general, extending direction can use angle Degree is to characterize.For example, certain pixel for including using hair image establishes rectangular coordinate system as origin, the ray of extending direction is characterized Angle between the horizontal axis positive direction of the rectangular coordinate system can be used for characterizing extending direction.
In the present embodiment, the first determination unit 602 can determine the extending direction of pixel according to various methods.As Example, each pixel in the pixel for including for hair image, the first determination unit 602 can be circle with the pixel The heart determines border circular areas by radius of preset length, and compares the face of each pixel of the sideline process of the border circular areas Color change value will be worth radius and the level side of corresponding pixel by the sideline of border circular areas, the smallest color change To angle be determined as the extending direction of the pixel.
In the present embodiment, the second determination unit 603 can determine starting pixels according to various methods from hair image Point set.As an example, the second determination unit 603 can be according to region (such as the head that technical staff specifies on hair image Push up region), or delimited automatically by the second determination unit 603 region (such as top in hair image and area with The area ratio of hair image is the region of preset ratio), according to preset spacing distance, starting pixels are determined in this region Point set, wherein the distance between adjacent starting pixels point is above-mentioned spacing distance.
In the present embodiment, for the starting pixels point in starting pixels point set, drawing unit 604 can execute as follows Step:
Firstly, the extending direction for the pixel for including based on identified hair image, determines prolonging for the starting pixels point Stretch direction.As an example, since the first determination unit 602 has determined the extending direction for the pixel that hair image includes, Drawing unit 604 can determine the extending direction of the starting pixels point.Alternatively, drawing unit 604 can will include the starting The mean direction of the extending direction for the pixel that the image-region of pixel, default size includes is determined as the starting pixels point Extending direction.
Then, the extending direction based on the starting pixels point determines that the starting pixels point is corresponding to match pixel point set It closes.As an example, drawing unit 604 can will be located at the starting pixels point extending direction on, and with the starting pixels point away from Pixel from pre-determined distance is determined as one to match pixel point, then the extending direction of starting pixels point is inclined to vertical direction Shifting predetermined angle, the extending direction to match pixel point newly determined, and so on, it determines one by one in the same manner It is new to match pixel point and to the extending direction of match pixel point out, to obtain to match pixel point set.
Finally, drawing hair curve in target cranial image to match pixel point set based on determined by.Specifically Ground, drawing unit 604 can be according to existing various curve-fitting methods, using to the picture to be fitted in match pixel point set Vegetarian refreshments carries out curve fitting, and obtains matched curve, and matched curve is plotted in head image.Above-mentioned curve-fitting method It can include but is not limited to following at least one: conic fitting, Cubic Curve Fitting, the fitting of three rank Beziers etc..
In some optional implementations of the present embodiment, drawing unit 604 may include: the first determining module (figure In be not shown), be configured to for the starting pixels point being determined as to match pixel point, execute and following determine step: determine with to The distance of match pixel point is pre-determined distance and is in the pixel on the extending direction to match pixel point as pixel undetermined Point;Determine whether pixel undetermined is located in the region of hair image;It, will in response to determining not in the region of hair image It is corresponding to match pixel that set fixed, in hair image to match pixel point is determined as the starting pixels point Point set;Second determining module (not shown) is configured in response to determine in the region of hair image, is based on institute The extending direction for the pixel that determining hair image includes determines the extending direction of pixel undetermined, and will be the last Determining pixel undetermined is used as to match pixel point, continues to execute determining step.
In some optional implementations of the present embodiment, the second determination unit 603 may include: third determining module (not shown) is configured to from hair image, determines top area image;Division module (not shown) is matched It is set to and top area image is divided into the first grid image set;Selecting module (not shown) is configured to for The first grid image in one grid image set selects pixel as starting pixels point from first grid image.
In some optional implementations of the present embodiment, device 600 can also include: that division unit (is not shown in figure Out), it is configured to for hair image to be divided into the second grid image set.
In some optional implementations of the present embodiment, drawing unit may include: the 4th determining module (in figure not Show), it is configured to from the second grid image set, the second grid image where determining starting pixels point is used as starting net Table images;5th determining module (not shown) is configured to determine the extension side for the pixel that starting mesh image includes To mean direction, and determine the mean square of the extending direction of the adjacent mesh image pixel that includes of starting mesh image To;Computing module (not shown) is configured to based on preset, starting mesh image direction weight and adjacent net trrellis diagram The direction weight of picture is weighted read group total to identified mean direction, and calculated result is determined as starting pixels point Extending direction.
In some optional implementations of the present embodiment, the first determination unit 602 can be further configured to: will Target cranial image input hair image recognition model trained in advance, obtains hair image, wherein hair image recognition model For characterizing the corresponding relationship of head image Yu hair image.
In some optional implementations of the present embodiment, the first determination unit 602 may include: the 6th determining module (not shown) is configured to determine the color change gradient direction for the pixel that hair image includes, wherein color change Gradient direction is used to characterize the maximum direction of color variation amplitude of pixel;7th determining module (not shown) is matched It is set to the extending direction to be processed that the vertical direction of the color change gradient direction of identified pixel is determined as to pixel; Processing module (not shown), is configured to based on smothing filtering algorithm, the pixel for including to hair image it is to be processed Extending direction is handled, and the extending direction for the pixel that hair image includes is obtained.
In some optional implementations of the present embodiment, drawing unit 604 may include: fitting module (in figure not Show), it is configured to corresponding to, to match pixel point, treat fitting in match pixel point set based on the starting pixels point Pixel carries out curve fitting, and obtains initial matched curve;Drafting module (not shown) is configured to using initial fitting Curve executes following plot step: determining whether obtained initial matched curve includes song of the curvature greater than predetermined curvature threshold value Line segment;Do not include in response to determination, initial matched curve is drawn in target cranial image as hair curve.
In some optional implementations of the present embodiment, drawing unit 604 can be further configured to: in response to Determination includes that will be located at deleting to match pixel point set at the curved section greater than predetermined curvature threshold value to match pixel point It removes;Treat it is remaining in match pixel point set carry out curve fitting to match pixel point, obtain new initial matched curve;It adopts With new initial matched curve, plot step is continued to execute.
In some optional implementations of the present embodiment, drawing unit 604 can be further configured to: in response to Determination includes, determine be located at aim curve section to match pixel point and the place of putting in order at aim curve section wait be fitted Truncation pixel is used as to match pixel point after pixel, wherein aim curve section is in initial matched curve, is greater than The curved section of predetermined curvature threshold value;By curved section deletion in initial matched curve, being fitted according to truncation pixel;In mesh The remaining curved section in initial matched curve is drawn on mark head image as hair curve;Truncation pixel is re-started Curve matching obtains new initial matched curve, continues to execute plot step using new initial matched curve.
The device provided by the above embodiment of the application, by determining hair image from the target cranial image of acquisition, And determine the extending direction for the pixel that hair image includes, then from hair image, determine starting pixels point set, finally Determine that the starting pixels point in starting pixels point set is corresponding to match pixel point set, and based on to match pixel point set It closes, hair curve is drawn in target cranial image, so that the accuracy that hair curve is drawn in head image is improved, with And improve the flexibility of processing hair image.
Below with reference to Fig. 7, it is (such as shown in FIG. 1 that it illustrates the electronic equipments for being suitable for being used to realize the embodiment of the present application Server or terminal device) computer system 700 structural schematic diagram.Electronic equipment shown in Fig. 7 is only an example, Should not function to the embodiment of the present application and use scope bring any restrictions.
As shown in fig. 7, computer system 700 includes central processing unit (CPU) 701, it can be read-only according to being stored in Program in memory (ROM) 702 or be loaded into the program in random access storage device (RAM) 703 from storage section 708 and Execute various movements appropriate and processing.In RAM 703, also it is stored with system 700 and operates required various programs and data. CPU 701, ROM 702 and RAM 703 are connected with each other by bus 704.Input/output (I/O) interface 705 is also connected to always Line 704.
I/O interface 705 is connected to lower component: the importation 706 including keyboard, mouse etc.;Including such as liquid crystal Show the output par, c 707 of device (LCD) etc. and loudspeaker etc.;Storage section 708 including hard disk etc.;And including such as LAN The communications portion 709 of the network interface card of card, modem etc..Communications portion 709 is executed via the network of such as internet Communication process.Driver 710 is also connected to I/O interface 705 as needed.Detachable media 711, such as disk, CD, magneto-optic Disk, semiconductor memory etc. are mounted on as needed on driver 710, in order to from the computer program root read thereon According to needing to be mounted into storage section 708.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes the program code for method shown in execution flow chart.In such reality It applies in example, which can be downloaded and installed from network by communications portion 709, and/or from detachable media 711 are mounted.When the computer program is executed by central processing unit (CPU) 701, limited in execution the present processes Above-mentioned function.
It should be noted that computer-readable medium described herein can be computer-readable signal media or meter Calculation machine readable medium either the two any combination.Computer-readable medium for example may be-but not limited to- Electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.It is computer-readable The more specific example of medium can include but is not limited to: have electrical connection, the portable computer magnetic of one or more conducting wires Disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or sudden strain of a muscle Deposit), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device or above-mentioned appoint The suitable combination of meaning.In this application, computer-readable medium can be any tangible medium for including or store program, the journey Sequence can be commanded execution system, device or device use or in connection.And in this application, it is computer-readable Signal media may include in a base band or as carrier wave a part propagate data-signal, wherein carrying computer can The program code of reading.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal, optical signal or Above-mentioned any appropriate combination.Computer-readable signal media can also be any calculating other than computer-readable medium Machine readable medium, the computer-readable medium can be sent, propagated or transmitted for by instruction execution system, device or device Part uses or program in connection.The program code for including on computer-readable medium can use any Jie appropriate Matter transmission, including but not limited to: wireless, electric wire, optical cable, RF etc. or above-mentioned any appropriate combination.
The calculating of the operation for executing the application can be write with one or more programming languages or combinations thereof Machine program code, described program design language include object oriented program language-such as Java, Smalltalk, C+ +, it further include conventional procedural programming language-such as " C " language or similar programming language.Program code can Fully to execute, partly execute on the user computer on the user computer, be executed as an independent software package, Part executes on the remote computer or executes on a remote computer or server completely on the user computer for part. In situations involving remote computers, remote computer can pass through the network of any kind --- including local area network (LAN) Or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as utilize Internet service Provider is connected by internet).
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor packet Include acquiring unit, the first determination unit, the second determination unit and drawing unit.Wherein, the title of these units is in certain situation Under do not constitute restriction to the unit itself, for example, acquiring unit is also described as " obtaining the list of target cranial image Member ".
As on the other hand, present invention also provides a kind of computer-readable medium, which be can be Included in electronic equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying electronic equipment. Above-mentioned computer-readable medium carries one or more program, when said one or multiple programs are held by the electronic equipment When row, so that the electronic equipment: obtaining target cranial image;Hair image is determined from target cranial image, and determines head The extending direction for the pixel that hair image includes;From hair image, starting pixels point set is determined;For starting pixels point set Starting pixels point in conjunction determines the starting pixels point based on the extending direction for the pixel that identified hair image includes Extending direction;Based on the extending direction of the starting pixels point, determine that the starting pixels point is corresponding to match pixel point set; Based on identified to match pixel point set, hair curve is drawn in target cranial image.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (22)

1. a kind of method for handling image, comprising:
Obtain target cranial image;
Hair image is determined from the target cranial image, and determines the extension side for the pixel that the hair image includes To;
From the hair image, starting pixels point set is determined;
For the starting pixels point in the starting pixels point set, the pixel that includes based on identified hair image prolongs Direction is stretched, determines the extending direction of the starting pixels point;Based on the extending direction of the starting pixels point, the starting pixels point is determined It is corresponding to match pixel point set;Based on identified to match pixel point set, drawn in the target cranial image Hair curve.
2. according to the method described in claim 1, wherein, the extending direction based on the starting pixels point determines the starting Pixel is corresponding to match pixel point set, comprising:
The starting pixels point is determined as to match pixel point, executes and following determine step: determine with to match pixel point away from From for pre-determined distance and being in the pixel on the extending direction to match pixel point as pixel undetermined;Determine picture undetermined Whether vegetarian refreshments is located in the region of the hair image;It, will really in response to determining in the region of the hair image It is corresponding to match pixel that set fixed, in the hair image to match pixel point is determined as the starting pixels point Point set;
It is located in the region of the hair image in response to determining, based on the extension for the pixel that identified hair image includes Direction, determines the extending direction of pixel undetermined, and the pixel undetermined that the last time is determined is as to match pixel point, Continue to execute the determining step.
3. it is described from the hair image according to the method described in claim 1, wherein, it determines starting pixels point set, wraps It includes:
From the hair image, top area image is determined;
The top area image is divided into the first grid image set;
For the first grid image in the first grid image set, selected from first grid image pixel as Starting pixels point.
4. according to the method described in claim 1, wherein, described from the hair image, determining starting pixels point set Before, the method also includes:
The hair image is divided into the second grid image set.
5. according to the method described in claim 4, wherein, the extension of the pixel for including based on identified hair image Direction determines the extending direction of the starting pixels point, comprising:
From the second grid image set, determine the second grid image where the starting pixels point as starting mesh Image;
It determines the mean direction of the extending direction for the pixel that the starting mesh image includes, and determines the starting mesh The mean direction of the extending direction for the pixel that the adjacent mesh image of image includes;
Direction weight based on preset, starting mesh image direction weight and adjacent mesh image, to identified average Direction is weighted read group total, and calculated result is determined as to the extending direction of the starting pixels point.
6. described to determine hair image from the target cranial image according to the method described in claim 1, wherein, comprising:
By target cranial image input hair image recognition model trained in advance, hair image is obtained, wherein the head Hair image recognition model is used to characterize the corresponding relationship of head image Yu hair image.
7. according to the method described in claim 1, wherein, the extension side for the pixel that the determination hair image includes To, comprising:
Determine the color change gradient direction for the pixel that the hair image includes, wherein color change gradient direction is used for Characterize the maximum direction of color variation amplitude of pixel;
The vertical direction of the color change gradient direction of identified pixel is determined as to the extending direction to be processed of pixel;
Based on smothing filtering algorithm, the extending direction to be processed for the pixel that the hair image includes is handled, is obtained The extending direction for the pixel that the hair image includes.
8. method described in one of -7 according to claim 1, wherein it is described based on determined by match pixel point set, Hair curve is drawn in the target cranial image, comprising:
It is corresponding to, to match pixel point, treat the progress of match pixel point in match pixel point set based on the starting pixels point Curve matching obtains initial matched curve;
Following plot step is executed using initial matched curve: determining whether obtained initial matched curve is greater than comprising curvature The curved section of predetermined curvature threshold value;Do not include in response to determination, initial matched curve is drawn in the target cranial image and is made For hair curve.
9. according to the method described in claim 8, wherein, the method also includes:
Include in response to determination, by be located at greater than predetermined curvature threshold value curved section to match pixel point to match pixel It is deleted in point set;Treat it is remaining in match pixel point set carry out curve fitting to match pixel point, obtain new initial Matched curve;Using new initial matched curve, the plot step is continued to execute.
10. according to the method described in claim 8, wherein, the method also includes:
Include in response to determination determine be located at aim curve section to match pixel point and put in order and be in aim curve section Pixel is truncated to being used as after match pixel point to match pixel point in place, wherein aim curve section is that initial fitting is bent Curved section in line, greater than predetermined curvature threshold value;By curve in initial matched curve, being fitted according to truncation pixel Section is deleted;The remaining curved section in initial matched curve is drawn on the target cranial image as hair curve;To cut Disconnected pixel re-starts curve matching, obtains new initial matched curve, continues to execute institute using new initial matched curve State plot step.
11. a kind of for handling the device of image, comprising:
Acquiring unit is configured to obtain target cranial image;
First determination unit is configured to determine hair image from the target cranial image, and determines the hair figure As the extending direction for the pixel for including;
Second determination unit is configured to from the hair image, determines starting pixels point set;
Drawing unit is configured to for the starting pixels point in the starting pixels point set, based on identified hair figure As the extending direction for the pixel for including, the extending direction of the starting pixels point is determined;Extension side based on the starting pixels point To determining that the starting pixels point is corresponding to match pixel point set;Based on identified to match pixel point set, described Hair curve is drawn in target cranial image.
12. device according to claim 11, wherein the drawing unit includes:
First determining module is configured to for the starting pixels point being determined as to execute following determining step: really to match pixel point It is fixed with to match pixel point at a distance from for pre-determined distance and be in the pixel on the extending direction to match pixel point as to Determine pixel;Determine whether pixel undetermined is located in the region of the hair image;It is not located at the hair in response to determining In the region of image, the set fixed, in the hair image to match pixel point is determined as the starting picture Vegetarian refreshments is corresponding to match pixel point set;
Second determining module is configured in response to determine in the region of the hair image, based on identified hair The extending direction for the pixel that image includes, determines the extending direction of pixel undetermined, and the last time is determined undetermined Pixel is used as to match pixel point, continues to execute the determining step.
13. device according to claim 11, wherein second determination unit includes:
Third determining module is configured to from the hair image, determines top area image;
Division module is configured to the top area image being divided into the first grid image set;
Selecting module is configured to for the first grid image in the first grid image set, from first grid chart Select pixel as starting pixels point as in.
14. device according to claim 11, wherein described device further include:
Division unit is configured to the hair image being divided into the second grid image set.
15. device according to claim 14, wherein the drawing unit includes:
4th determining module is configured to from the second grid image set, determines where the starting pixels point Two grid images are as starting mesh image;
5th determining module is configured to determine the mean square of the extending direction for the pixel that the starting mesh image includes To, and determine the mean direction of the extending direction for the pixel that the adjacent mesh image of the starting mesh image includes;
Computing module is configured to weigh based on the direction of preset, starting mesh image direction weight and adjacent mesh image Weight, is weighted read group total to identified mean direction, calculated result is determined as to the extension side of the starting pixels point To.
16. device according to claim 11, wherein first determination unit is further configured to:
By target cranial image input hair image recognition model trained in advance, hair image is obtained, wherein the head Hair image recognition model is used to characterize the corresponding relationship of head image Yu hair image.
17. device according to claim 11, wherein first determination unit includes:
6th determining module is configured to determine the color change gradient direction for the pixel that the hair image includes, wherein Color change gradient direction is used to characterize the maximum direction of color variation amplitude of pixel;
7th determining module is configured to the vertical direction of the color change gradient direction of identified pixel being determined as picture The extending direction to be processed of vegetarian refreshments;
Processing module is configured to the extension to be processed to the pixel that the hair image includes based on smothing filtering algorithm Direction is handled, and the extending direction for the pixel that the hair image includes is obtained.
18. device described in one of 1-17 according to claim 1, wherein the drawing unit includes:
Fitting module, be configured to based on the starting pixels point it is corresponding in match pixel point set to match pixel point, It treats match pixel point to carry out curve fitting, obtains initial matched curve;
Drafting module is configured to execute following plot step using initial matched curve: determining that obtained initial fitting is bent Whether line includes curved section of the curvature greater than predetermined curvature threshold value;Do not include in response to determination, in the target cranial image Initial matched curve is drawn as hair curve.
19. device according to claim 18, wherein the drawing unit is further configured to:
Include in response to determination, by be located at greater than predetermined curvature threshold value curved section to match pixel point to match pixel It is deleted in point set;Treat it is remaining in match pixel point set carry out curve fitting to match pixel point, obtain new initial Matched curve;Using new initial matched curve, the plot step is continued to execute.
20. device according to claim 18, wherein the drawing unit is further configured to:
Include in response to determination determine be located at aim curve section to match pixel point and put in order and be in aim curve section Pixel is truncated to being used as after match pixel point to match pixel point in place, wherein aim curve section is that initial fitting is bent Curved section in line, greater than predetermined curvature threshold value;By curve in initial matched curve, being fitted according to truncation pixel Section is deleted;The remaining curved section in initial matched curve is drawn on the target cranial image as hair curve;To cut Disconnected pixel re-starts curve matching, obtains new initial matched curve, continues to execute institute using new initial matched curve State plot step.
21. a kind of electronic equipment, comprising:
One or more processors;
Storage device is stored thereon with one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now method as described in any in claim 1-10.
22. a kind of computer-readable medium, is stored thereon with computer program, wherein the realization when program is executed by processor Method as described in any in claim 1-10.
CN201810879994.7A 2018-08-03 2018-08-03 Method and apparatus for handling image Active CN109087377B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810879994.7A CN109087377B (en) 2018-08-03 2018-08-03 Method and apparatus for handling image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810879994.7A CN109087377B (en) 2018-08-03 2018-08-03 Method and apparatus for handling image

Publications (2)

Publication Number Publication Date
CN109087377A true CN109087377A (en) 2018-12-25
CN109087377B CN109087377B (en) 2019-11-12

Family

ID=64833874

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810879994.7A Active CN109087377B (en) 2018-08-03 2018-08-03 Method and apparatus for handling image

Country Status (1)

Country Link
CN (1) CN109087377B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008923A (en) * 2019-04-11 2019-07-12 网易有道信息技术(北京)有限公司 Image processing method and training method and device, calculate equipment at medium
CN111080103A (en) * 2019-12-05 2020-04-28 中国农业科学院农业资源与农业区划研究所 Method for automatically evaluating crop yield
CN111260581A (en) * 2020-01-17 2020-06-09 北京达佳互联信息技术有限公司 Image processing method, device and storage medium
CN111524171A (en) * 2020-04-26 2020-08-11 网易(杭州)网络有限公司 Image processing method and device and electronic equipment
CN113763228A (en) * 2020-06-01 2021-12-07 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN114723888A (en) * 2022-04-08 2022-07-08 北京百度网讯科技有限公司 Three-dimensional hair model generation method, device, equipment, storage medium and product
CN114758391A (en) * 2022-04-08 2022-07-15 北京百度网讯科技有限公司 Hairstyle image determining method and device, electronic equipment, storage medium and product

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050253842A1 (en) * 2003-05-14 2005-11-17 Pixar Hair rendering method and apparatus
CN102800129A (en) * 2012-06-20 2012-11-28 浙江大学 Hair modeling and portrait editing method based on single image
CN103606186A (en) * 2013-02-02 2014-02-26 浙江大学 Virtual hair style modeling method of images and videos
CN104376597A (en) * 2014-12-05 2015-02-25 北京航空航天大学 Multi-direction constrained hair reconstruction method
CN107103619A (en) * 2017-04-19 2017-08-29 腾讯科技(上海)有限公司 A kind of processing method of hair grain direction, apparatus and system
CN107886516A (en) * 2017-11-30 2018-04-06 厦门美图之家科技有限公司 The method and computing device that hair moves towards in a kind of calculating portrait

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050253842A1 (en) * 2003-05-14 2005-11-17 Pixar Hair rendering method and apparatus
CN102800129A (en) * 2012-06-20 2012-11-28 浙江大学 Hair modeling and portrait editing method based on single image
CN103606186A (en) * 2013-02-02 2014-02-26 浙江大学 Virtual hair style modeling method of images and videos
CN104376597A (en) * 2014-12-05 2015-02-25 北京航空航天大学 Multi-direction constrained hair reconstruction method
CN107103619A (en) * 2017-04-19 2017-08-29 腾讯科技(上海)有限公司 A kind of processing method of hair grain direction, apparatus and system
CN107886516A (en) * 2017-11-30 2018-04-06 厦门美图之家科技有限公司 The method and computing device that hair moves towards in a kind of calculating portrait

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008923A (en) * 2019-04-11 2019-07-12 网易有道信息技术(北京)有限公司 Image processing method and training method and device, calculate equipment at medium
CN111080103A (en) * 2019-12-05 2020-04-28 中国农业科学院农业资源与农业区划研究所 Method for automatically evaluating crop yield
CN111260581A (en) * 2020-01-17 2020-06-09 北京达佳互联信息技术有限公司 Image processing method, device and storage medium
CN111260581B (en) * 2020-01-17 2023-09-26 北京达佳互联信息技术有限公司 Image processing method, device and storage medium
CN111524171A (en) * 2020-04-26 2020-08-11 网易(杭州)网络有限公司 Image processing method and device and electronic equipment
CN113763228A (en) * 2020-06-01 2021-12-07 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN113763228B (en) * 2020-06-01 2024-03-19 北京达佳互联信息技术有限公司 Image processing method, device, electronic equipment and storage medium
CN114723888A (en) * 2022-04-08 2022-07-08 北京百度网讯科技有限公司 Three-dimensional hair model generation method, device, equipment, storage medium and product
CN114758391A (en) * 2022-04-08 2022-07-15 北京百度网讯科技有限公司 Hairstyle image determining method and device, electronic equipment, storage medium and product
CN114758391B (en) * 2022-04-08 2023-09-12 北京百度网讯科技有限公司 Hair style image determining method, device, electronic equipment, storage medium and product

Also Published As

Publication number Publication date
CN109087377B (en) 2019-11-12

Similar Documents

Publication Publication Date Title
CN109087377B (en) Method and apparatus for handling image
CN107633218A (en) Method and apparatus for generating image
CN108446387A (en) Method and apparatus for updating face registration library
CN110175555A (en) Facial image clustering method and device
CN112954450B (en) Video processing method and device, electronic equipment and storage medium
CN109360028A (en) Method and apparatus for pushed information
CN109344752A (en) Method and apparatus for handling mouth image
CN107977946A (en) Method and apparatus for handling image
CN109272050B (en) Image processing method and device
CN108171211A (en) Biopsy method and device
CN109711508A (en) Image processing method and device
CN110177295A (en) Processing method, device and the electronic equipment that subtitle crosses the border
CN110084317A (en) The method and apparatus of image for identification
CN108182457A (en) For generating the method and apparatus of information
CN108171167B (en) Method and apparatus for exporting image
CN109559288A (en) Image processing method, device, electronic equipment and computer readable storage medium
CN109754464A (en) Method and apparatus for generating information
CN109271929A (en) Detection method and device
CN109255814A (en) Method and apparatus for handling image
CN108595211A (en) Method and apparatus for output data
CN109510943A (en) Method and apparatus for shooting image
CN113538304B (en) Training method and device for image enhancement model, and image enhancement method and device
CN109241930A (en) Method and apparatus for handling supercilium image
CN109446379A (en) Method and apparatus for handling information
CN108985178A (en) Method and apparatus for generating information

Legal Events

Date Code Title Description
PB01 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
CP01 Change in the name or title of a patent holder
CP01 Change in the name or title of a patent holder

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Patentee before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.