CN107886516A - The method and computing device that hair moves towards in a kind of calculating portrait - Google Patents

The method and computing device that hair moves towards in a kind of calculating portrait Download PDF

Info

Publication number
CN107886516A
CN107886516A CN201711240025.9A CN201711240025A CN107886516A CN 107886516 A CN107886516 A CN 107886516A CN 201711240025 A CN201711240025 A CN 201711240025A CN 107886516 A CN107886516 A CN 107886516A
Authority
CN
China
Prior art keywords
pixel
hair
connected region
portrait
hair direction
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
CN201711240025.9A
Other languages
Chinese (zh)
Other versions
CN107886516B (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.)
Xiamen Meitu Technology Co Ltd
Original Assignee
Xiamen Meitu 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 Xiamen Meitu Technology Co Ltd filed Critical Xiamen Meitu Technology Co Ltd
Priority to CN201711240025.9A priority Critical patent/CN107886516B/en
Publication of CN107886516A publication Critical patent/CN107886516A/en
Application granted granted Critical
Publication of CN107886516B publication Critical patent/CN107886516B/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
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The method that hair moves towards in portrait, including step are calculated the invention discloses a kind of:Calculate the gradient of each pixel in hair zones in portrait;According to the hair direction of each pixel of the gradient calculation of each pixel;At least one connected region is generated according to the hair direction of each pixel;Pixel beyond at least one connected region is incorporated to a connected region adjacent thereto by the first predetermined condition, generates new connected region;And the forward and reverse of hair direction in each new connected region is determined, obtain the hair direction of each new connected region.The present invention discloses the computing device for performing this method in the lump.

Description

The method and computing device that hair moves towards in a kind of calculating portrait
Technical field
The method and calculating that hair moves towards the present invention relates to technical field of image processing, in especially a kind of calculating portrait are set It is standby.
Background technology
In the application of face image processing, often need to obtain certain a part of texture information and be further processed. For example, when doing Freehandhand-drawing special effect processing to portrait (portrait described in the disclosure, which refers to, contains the images of face hair zones), need The hair trend of hair in portrait is obtained, and for example, when hair zones are carried out with the processing such as hair reconstruction, hair style modeling, Need to obtain hair trend of hair zones, etc..Therefore, in actual applications, often need to judge head in a portrait image Send out the trend (that is, tendency direction) of region hair.
The method that hair moves towards in existing calculating portrait has had a lot.Such as entered using multiple different angle shooting images Wardrobe send out Texture Matching, according to the big body Model of disparity computation hair, recycle the geometric shape of model to calculate hair in hair Trend;Either, by being fitted adjustment to existing Hair model, approximate Hair model is obtained, is walked so as to calculate hair To;Algorithm also is by deep learning, obtains that an input be portrait picture, to export be mould that hair moves towards temperature figure Type.However, the mode for obtaining 3D models needs great amount of calculation, and machine learning needs substantial amounts of labeled data and volume Huge model file, therefore above-mentioned computational methods not only take, and also have high requirement to the performance of Intelligent hardware.
To sum up, it is necessary to which a kind of calculate high efficiency and time conservation, the scheme for calculating hair trend in portrait of and can guarantee accuracy, with General module as hair zones relevant treatment algorithm is used in all kinds of facial image processings.
The content of the invention
Therefore, the invention provides it is a kind of calculate portrait in hair move towards method and computing device, with try hard to solve or Person at least alleviates existing at least one problem above.
According to an aspect of the invention, there is provided a kind of calculate the method that hair moves towards in portrait, this method is suitable to Performed in computing device, including step:Calculate the gradient of each pixel in hair zones in portrait;According to each pixel The hair direction of each pixel of gradient calculation;At least one connected region is generated according to the hair direction of each pixel;Will Pixel beyond at least one connected region is incorporated to a connected region adjacent thereto by the first predetermined condition, and generation newly connects Logical region;And the forward and reverse of hair direction in each new connected region is determined, obtain the hair direction of each new connected region.
Alternatively, in the method that hair moves towards in the calculating portrait according to the present invention, calculate in portrait in hair zones The step of gradient of each pixel, includes:Hair zones in portrait are obtained by hair zones recognition methods;And use Predetermined gradient operator calculates the gradient of each pixel in hair zones.
Alternatively, in the method that hair moves towards in the calculating portrait according to the present invention, each new connected region is being obtained Hair direction the step of after, in addition to step:The hair direction of each new connected region is smoothed, will be smooth Hair direction of the hair direction as the new connected region after processing.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, the hair direction of each pixel Represented with the angle angle in hair direction on the pixel and x-axis, be denoted as θ:θ=arctan (Gy/Gx), wherein, Gy is pixel The gradient of point in the y-axis direction, Gx is the gradient of pixel in the direction of the x axis.
Alternatively, in calculating in portrait in the method for hair trend, according to the hair of each pixel according to the present invention The step of direction generation at least one connected region, includes:According to the hair direction calculating of each pixel pixel and its phase The pixel connection weight of adjacent pixel;And at least one connected region is generated according to pixel connection weight.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, calculating pixel picture adjacent thereto The step of pixel connection weight of vegetarian refreshments, includes:If the Grad of the Grad of the pixel and one neighbor pixel is all higher than The absolute difference in the hair direction of Grads threshold and the pixel and the hair direction of the neighbor pixel is less than angle threshold, It is then 1 by the pixel connection weight of the pixel and the neighbor pixel;Otherwise, by the pixel of the pixel and the neighbor pixel Connection weight is 0.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, the adjacent pixel of pixel (y, x) Point includes:Pixel (y, x+1) and pixel (y+1, x).
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, pixel (y, x) and pixel The pixel connection weight L of (y, x+1)y,x+1It is expressed as:
With
The pixel connection weight L of pixel (y, x) and pixel (y+1, x)y+1,xIt is expressed as:
Wherein, Gy,xFor the Grad of pixel (y, x), Gy,x+1For pixel (y, x+1) Grad, Gy+1,xFor pixel The Grad of point (y+1, x), θy,xFor the hair direction of pixel (y, x), θy,x+1For the hair direction of pixel (y, x+1), θy+1,xFor the hair direction of pixel (y+1, x), ε is Grads threshold, and pi/2 is angle threshold.
Alternatively, according to the present invention calculate portrait in hair move towards method in, according to pixel connection weight generate to The step of few connected region, includes:If pixel connection weight meets the second predetermined condition, then it is assumed that the pixel connection weight is corresponding Two neighbor pixels connection;At least one connection block is generated by interconnected pixel;And judge at least one company The block area of logical block, when the block area for connecting block is more than area threshold, using the connection block as a connected region.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, area threshold is according to the hair The area in region determines.
Alternatively, the method that hair moves towards in portrait is being calculated according to the present invention, the step of generating new connected region Including:
Pixel beyond at least one connected region is incorporated to the maximum connected region of Grad adjacent thereto, New connected region corresponding to generation, wherein, the pixel beyond at least one connected region includes not being incorporated to the company of connected region Logical block and/or the pixel for being unsatisfactory for the second predetermined condition.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, it is determined that in each new connected region Forward and reverse step in hair direction includes:By minimizing the initial hair direction of each new connected region with newly connecting around it The difference in the initial hair direction in logical region, it is determined that in each new connected region hair direction it is forward and reverse.
Alternatively, in calculating in portrait in the method for hair trend according to the present invention, each new connected region of minimum The difference in initial hair direction and the initial hair direction of new connected region around it realized by formula below:
Wherein, n represents the number of new connected region,Represent new connected region DomainInitial hair direction,Represent new connected regionThe new connected region of surroundingInitial hair direction, ω=± 1.
According to another aspect of the invention, there is provided a kind of computing device, including:One or more processors;And storage Device;One or more programs, wherein one or more program storages in memory and be configured as by one or more handle Device performs, and one or more programs include being used for the instruction for performing the either method in method as described above.
In accordance with a further aspect of the present invention, there is provided a kind of computer-readable storage medium for storing one or more programs Matter, one or more programs include instruction, instructed when computing device so that computing device method as described above In either method.
The scheme that hair moves towards in portrait is calculated according to the present invention, it is not necessary to rely on model file and substantial amounts of training sample This, it is only necessary to is by calculating the hair direction in hair zones on each pixel, by the adjacent picture with identical hair direction Vegetarian refreshments is classified as a connected region, then true by minimizing each connected region and the difference in the hair direction of surrounding connected region The hair direction of each connected region is made, the hair for obtaining hair in portrait moves towards information, and most of calculate can be complete parallel Into computational efficiency is high.
Brief description of the drawings
In order to realize above-mentioned and related purpose, some illustrative sides are described herein in conjunction with following description and accompanying drawing Face, these aspects indicate the various modes that can put into practice principles disclosed herein, and all aspects and its equivalent aspect It is intended to fall under in the range of theme claimed.Read following detailed description in conjunction with the accompanying drawings, the disclosure it is above-mentioned And other purposes, feature and advantage will be apparent.Throughout the disclosure, identical reference generally refers to identical Part or element.
Fig. 1 shows the organigram of computing device 100 according to an embodiment of the invention;
Fig. 2 shows the flow chart of the method 200 that hair moves towards in calculating portrait according to an embodiment of the invention;With And
Fig. 3 A show the hair zones schematic diagram according to an embodiment of the invention with connected region, and Fig. 3 B are shown The schematic diagrames of hair zones according to an embodiment of the invention with new connected region.
Embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although the disclosure is shown in accompanying drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here Limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure Completely it is communicated to those skilled in the art.
Fig. 1 is the block diagram of Example Computing Device 100.In basic configuration 102, computing device 100, which typically comprises, is System memory 106 and one or more processor 104.Memory bus 108 can be used in processor 104 and system storage Communication between device 106.
Depending on desired configuration, processor 104 can be any kind of processor, include but is not limited to:Microprocessor Device (μ P), microcontroller (μ C), digital information processor (DSP) or any combination of them.Processor 104 can include all Cache, processor core such as one or more rank of on-chip cache 110 and second level cache 112 etc 114 and register 116.The processor core 114 of example can include arithmetic and logical unit (ALU), floating-point unit (FPU), Digital signal processing core (DSP core) or any combination of them.The Memory Controller 118 of example can be with processor 104 are used together, or in some implementations, Memory Controller 118 can be an interior section of processor 104.
Depending on desired configuration, system storage 106 can be any type of memory, include but is not limited to:Easily The property lost memory (RAM), nonvolatile memory (ROM, flash memory etc.) or any combination of them.System stores Device 106 can include operating system 120, one or more apply 122 and routine data 124.In some embodiments, It may be arranged to be operated using routine data 124 on an operating system using 122.In certain embodiments, computing device 100 are configured as performing the method for calculating that hair moves towards in portrait, are just contained in routine data 124 for performing methods described Instruction.
Computing device 100 can also include contributing to from various interface equipments (for example, output equipment 142, Peripheral Interface 144 and communication equipment 146) to basic configuration 102 via the communication of bus/interface controller 130 interface bus 140.Example Output equipment 142 include graphics processing unit 148 and audio treatment unit 150.They can be configured as contributing to via One or more A/V port 152 is communicated with the various external equipments of such as display or loudspeaker etc.Outside example If interface 144 can include serial interface controller 154 and parallel interface controller 156, they can be configured as contributing to Via one or more I/O port 158 and such as input equipment (for example, keyboard, mouse, pen, voice-input device, image Input equipment) or the external equipment of other peripheral hardwares (such as printer, scanner etc.) etc communicated.The communication of example is set Standby 146 can include network controller 160, and it can be arranged to be easy to via one or more COM1 164 and one The communication that other individual or multiple computing devices 162 pass through network communication link.In this programme, camera etc can be passed through Image input device obtain pending portrait in real time, pending portrait can also be obtained by communication equipment 146.
Network communication link can be an example of communication media.Communication media can be generally presented as in such as carrier wave Or computer-readable instruction in the modulated data signal of other transmission mechanisms etc, data structure, program module, and can With including any information delivery media." modulated data signal " can such signal, one in its data set or more It is individual or it change can the mode of coding information in the signal carry out.As nonrestrictive example, communication media can be with Include the wire medium of such as cable network or private line network etc, and it is such as sound, radio frequency (RF), microwave, infrared (IR) the various wireless mediums or including other wireless mediums.Term computer-readable medium used herein can include depositing Both storage media and communication media.In certain embodiments, one or more programs are stored in computer-readable medium, this Or multiple programs include performing the instruction of some methods, such as according to an embodiment of the invention, computing device 100 passes through the finger Make and calculate the method that hair moves towards in portrait to perform.
Computing device 100 can be implemented as a part for portable (or mobile) electronic equipment of small size, and these electronics are set Standby can be such as cell phone, digital camera, personal digital assistant (PDA), personal media player device, wireless network Browsing apparatus, personal helmet, application specific equipment or the mixing apparatus that any of the above function can be included.Calculating is set Standby 100 are also implemented as including desktop computer and the personal computer of notebook computer configuration.
Below with reference to Fig. 2, the method that hair moves towards in calculating portrait according to an embodiment of the invention is elaborated 200 flow.In short, method 200 will have identical by calculating the hair direction in hair zones on each pixel The neighbor pixel in hair direction is classified as a connected region, then the hair of each connected region is calculated by iteration convergence method Silk direction, information is moved towards to obtain the hair of hair in portrait.
As shown in Fig. 2 method 200 starts from step S210, the gradient of each pixel in hair zones in portrait is calculated.Such as Described previously, portrait described herein refers to the image for including face hair zones.
According to one embodiment of present invention, either received for the portrait collected in real time by communication interface Portrait, first pass through hair zones recognition methods and obtain hair zones in the portrait, following operation processing step is to obtaining The hair zones image got is handled.Alternatively, the method for identifying hair zones can be it is determined that the base of human face region On plinth, using features such as the color of hair, texture, shape, positions, region segmentation, such as side based on complexion model matching are carried out Method;Gauss hybrid models can also be built according to hair color and positional information come identify/be partitioned into hair zones;Can be with base Hair zones are identified in the method structure machine learning model of neural network machine study.The invention is not limited in this regard.Appoint The recognition methods of what hair zones can be combined with embodiments of the invention, complete the calculating that hair moves towards in portrait.
After hair zones are got, the gradient of each pixel in hair zones is calculated using predetermined gradient operator.Root According to one embodiment of the present of invention, gradient calculation is carried out on the luminance channel image of hair zones, to obtain hair edge Gradient information.Alternatively, predetermined gradient operator can be Sobel operators, Roberts operators, Prewitt operators, Lapacian Operator etc., by taking Sobel operators as an example, the gradient information of pixel (y, x) can be calculated by following formula:
Wherein, Gxy.xAnd Gyy.xPixel (y, x) is represented respectively in x-axis and y-axis direction (that is, horizontal direction and Vertical Square To) on the gradient tried to achieve, Iy,xFor the pixel value at image (y, x) place, Sxi,jAnd Syi,jRepresent and scrolled up in x-axis and y-axis side respectively The weights at product core (i, j) place, for 3*3 convolution kernel, i=3, j=3.
The gradient operator of horizontal direction (left side) and the 3*3 templates in vertical direction (right side) is shown individually below:
Then in step S220, according to the hair direction of each pixel of the gradient calculation of each pixel.According to this The embodiment of invention, the hair direction of each pixel is represented with the angle angle in hair direction on the pixel and x-axis, is denoted as θ, θ are calculated by following formula:
θ=arctan (Gy/Gx)
Wherein, Gy is the gradient of pixel in the y-axis direction, and Gx is the gradient of pixel in the direction of the x axis, with pixel Exemplified by (y, x), the hair direction θ of the pixely,x=arctan (Gyy,x/Gxy,x)。
Find under study for action, hair zones can't all have obvious hair everywhere, that is to say, that according to step S220 The most of θ calculated is insecure, is often disturbed by factors such as mixed and disorderly hair, noises.Meanwhile in specific implementation process In, inventors herein have recognized that:
A, the direction confidence level that the stronger region of gradient is showed is higher;
B, the general direction confidence level that the more unified region in direction is showed is higher;
C, in most cases, the hair direction in one piece of region is approximate with the direction of peripheral region.
To solve above-mentioned interference, it is by problem reduction according to the embodiment of the present invention:According to the hair of each pixel The unified subregion in each piece of high intensity, direction of direction finding.
In subsequent step S230, at least one connected region is generated according to the hair direction of each pixel.Specifically Ground, step S230 include the steps 1) and 2).
Step 1):Connected according to the pixel of the hair direction calculating of each pixel pixel pixel adjacent thereto Power.Wherein, the neighbor pixel of pixel (y, x) includes its two on x, y direction direct neighbor pixel:(y,x+1) (y+1, x).
According to one embodiment of present invention, if the Grad of the Grad of the pixel and one neighbor pixel is equal Absolute difference more than the hair direction of Grads threshold and the pixel and the hair direction of the neighbor pixel is less than angle threshold Value, then it is 1 by the pixel connection weight of the pixel and the neighbor pixel;Otherwise, by the pixel and the neighbor pixel Pixel connection weight is 0.
It is further explained by calculating of the following formula to pixel connection weight:
The pixel connection weight L of pixel (y, x) and pixel (y, x+1)y,x+1It is expressed as:
The pixel connection weight L of pixel (y, x) and pixel (y+1, x)y+1,xIt is expressed as:
In above formula, θy,xFor the hair direction of pixel (y, x), θy,x+1For the hair direction of pixel (y, x+1), θy+1,x For the hair direction of pixel (y+1, x), ε is Grads threshold, and pi/2 is angle threshold, Gy,xFor the Grad of pixel (y, x), Gy,x+1For pixel (y, x+1) Grad, Gy+1,xFor pixel (y+1, x) Grad, with Gy,xExemplified by:
As it was noted above, Gxy.xAnd Gyy.xGradient of the pixel (y, x) in x-axis and y-axis direction is represented respectively.
According to an embodiment of the invention, Grads threshold ε determines that alternatively, ε takes entirely according to the global Grad of hair zones The 30% of office's maximum of gradients.
Step 2):The pixel connection weight tried to achieve according to step 1) generates at least one connected region.
According to one embodiment of present invention, if pixel connection weight meets the second predetermined condition, then it is assumed that the pixel connects Two neighbor pixel connections corresponding to power (the second predetermined condition is that pixel connection weight is 1);Given birth to by interconnected pixel Into at least one connection block (that is, connection block meets:Any one pixel in the connection block connects block with same Interior at least one pixel connection, and do not connected with any one pixel outside this connects block);Judge that this is at least one The block area of each connection block in block is connected, when the block area for connecting block is more than area threshold, using the connection block as one Connected region, it is labeled asAccording to one embodiment of present invention, area threshold determines according to the area of hair zones, optional Ground, area threshold take the 0.5~1.0% of hair zones area.
After step S230 processing, there is at least one connected region in hair zones, as Fig. 3 A give hair zones One example, wherein 301,301,303 represent the connected region that generates after step S230 processing respectively, it can be denoted as
Then in step S240, by the pixel beyond this at least one connected region by the first predetermined condition be incorporated to Its adjacent connected region, generate new connected region.Wherein, the pixel beyond this at least one connected region is included not It is incorporated to connected regionConnection block and/or be unsatisfactory for the pixel of the second predetermined condition and (that is, be not connected with any pixel only Standing statue element), in Fig. 3 A, 304 represent not being incorporated to the connection block of connected region, the independence that 305 expressions are not connected with any pixel Pixel.According to one embodiment of present invention, the first predetermined condition is:Connected region is not incorporated to by above-mentionedConnection block, no Meet that the pixel of the second predetermined condition is incorporated to a maximum connected region of Grad adjacent thereto.
After step S240 processing, hair zones have been divided into the region of multiple connections, by this multiple connection Region turns into new connected region, is labeled asAs Fig. 3 B show example of Fig. 3 A hair zones after step S240 processing Figure, wherein, 310,320,330 represent the new connected region that generates after step S240 processing respectively, can be denoted as
It should be noted that signals of Fig. 3 A and Fig. 3 B only as the result for illustrating step S230 and step S240 Figure, in actual process, the distribution of connected region may there is a situation where more increasingly complex than diagram.
After step S230 and step S240 processing, the pixel moved towards with identical hair is grouped into a region, That is each new connected region has been provided with relatively accurate hair trend.Alternatively, with each pixel in new connected region Initial hair direction of the average in the hair direction of point as the new connected region, is denoted asIt is of course also possible to new connection The hair direction of each pixel carries out probability statistics (for example, rejecting hair direction and overall hair direction has difference in region Respective pixel point), calculate the initial hair direction of the new connected region.The invention is not limited in this regard.
Then in step s 250, it is determined that in each new connected region hair direction it is forward and reverse, obtain each new connection The hair direction in region., it is necessary to further discriminate between each new connected region as obtained by abovementioned stepsActual direction with it is required The initial hair direction obtainedIt is in the same direction or reverse.
According to one embodiment of present invention, it is determined that in each new connected region hair direction forward and reverse step bag Include:By minimize the initial hair direction of each new connected region and around it initial hair direction of new connected region difference Value is (i.e. so that the hair direction and the hair direction of new connected region around it of each new connected region keep same as much as possible To), it is determined that in each new connected region hair direction it is forward and reverse.Specifically, each new the first of connected region is minimized to originate The difference in silk direction and the initial hair direction of new connected region around it is realized by formula below:
Wherein, n represents the number of new connected region,Represent new connected region DomainInitial hair direction,Represent new connected regionThe new connected region of surroundingInitial hair direction, ω take 1 or Person -1.
After the processing of above-mentioned minimum, the hair direction of each new connected region is redefined out, is denoted as
According to another embodiment of the invention, the hair direction of each new connected region is being obtained through step S250 processing Afterwards, in addition to hair direction the step (not shown) of processing is further smoothed:To the hair direction of each new connected region It is smoothed, the hair direction using the hair direction after smoothing processing as the new connected region.Specifically, it is right as the following formula New connected regionHair directionThe hair direction that new connected region is abutted by surrounding is carried out smoothly:
In formula, n represents the number for the new connected region being smoothed, and alternatively, n takes 5*5 sizes.
The scheme that hair moves towards in portrait is calculated according to the present invention, it is not necessary to rely on model file and substantial amounts of training sample This, it is only necessary to is by calculating the hair direction in hair zones on each pixel, by the adjacent picture with identical hair direction Vegetarian refreshments is classified as a connected region, then true by minimizing each connected region and the difference in the hair direction of surrounding connected region The hair direction of each connected region is made, the hair for obtaining hair in portrait moves towards information, and most of calculate can be complete parallel Into computational efficiency is high.
It should be appreciated that in order to simplify the disclosure and help to understand one or more of each inventive aspect, it is right above The present invention exemplary embodiment description in, each feature of the invention be grouped together into sometimes single embodiment, figure or In person's descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. claimed hair The bright feature more features required than being expressly recited in each claim.More precisely, as the following claims As book reflects, inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows specific real Thus the claims for applying mode are expressly incorporated in the embodiment, wherein each claim is used as this hair in itself Bright separate embodiments.
Those skilled in the art should be understood the module or unit or group of the equipment in example disclosed herein Part can be arranged in equipment as depicted in this embodiment, or alternatively can be positioned at and the equipment in the example In different one or more equipment.Module in aforementioned exemplary can be combined as a module or be segmented into addition multiple Submodule.
Those skilled in the art, which are appreciated that, to be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment Member or component be combined into a module or unit or component, and can be divided into addition multiple submodule or subelement or Sub-component.In addition at least some in such feature and/or process or unit exclude each other, it can use any Combination is disclosed to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so to appoint Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification (including adjoint power Profit requires, summary and accompanying drawing) disclosed in each feature can be by providing the alternative features of identical, equivalent or similar purpose come generation Replace.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included some features rather than further feature, but the combination of the feature of different embodiments means in of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed One of meaning mode can use in any combination.
Various technologies described herein can combine hardware or software, or combinations thereof is realized together.So as to the present invention Method and apparatus, or some aspects of the process and apparatus of the present invention or part can take embedded tangible media, such as soft The form of program code (instructing) in disk, CD-ROM, hard disk drive or other any machine readable storage mediums, Wherein when program is loaded into the machine of such as computer etc, and is performed by the machine, the machine becomes to put into practice this hair Bright equipment.
In the case where program code performs on programmable computers, computing device generally comprises processor, processor Readable storage medium (including volatibility and nonvolatile memory and/or memory element), at least one input unit, and extremely A few output device.Wherein, memory is arranged to store program codes;Processor is arranged to according to the memory Instruction in the described program code of middle storage, performs method of the present invention.
By way of example and not limitation, computer-readable medium includes computer-readable storage medium and communication media.Calculate Machine computer-readable recording medium includes computer-readable storage medium and communication media.Computer-readable storage medium storage such as computer-readable instruction, The information such as data structure, program module or other data.Communication media is typically modulated with carrier wave or other transmission mechanisms etc. Data-signal processed passes to embody computer-readable instruction, data structure, program module or other data including any information Pass medium.Any combination above is also included within the scope of computer-readable medium.
The invention also discloses:
A9, the method as any one of A1-8, wherein, it is described that at least one connected region is generated according to pixel connection weight The step of domain, includes:If pixel connection weight meets the second predetermined condition, then it is assumed that two adjacent pictures corresponding to the pixel connection weight Vegetarian refreshments connects;At least one connection block is generated by interconnected pixel;And judge the block of at least one connection block Area, when the block area for connecting block is more than area threshold, using the connection block as a connected region.
A10, the method as described in A9, wherein, the area threshold determines according to the area of the hair zones.
A11, the method as described in A9 or 10, wherein, the step of generating new connected region, includes:By at least one company Pixel beyond logical region is incorporated to the maximum connected region of Grad adjacent thereto, new connected region corresponding to generation, its In, pixel beyond at least one connected region includes not being incorporated to the connection block of connected region and/or is unsatisfactory for second The pixel of predetermined condition.
A12, the method as any one of A1-11, wherein it is determined that in each new connected region hair direction it is positive and negative To the step of include:Originated by the initial hair direction for minimizing each new connected region with new the first of connected region around it The difference in silk direction, it is determined that in each new connected region hair direction it is forward and reverse.
A13, the method as described in A12, wherein, minimize the initial hair direction of each new connected region with around it newly The difference in the initial hair direction of connected region is realized by formula below:
Wherein, n represents the number of new connected region, Represent new connected regionInitial hair direction,Represent new connected regionThe new connected region of surroundingInitial hair direction, ω=± 1.
In addition, be described as herein can be by the processor of computer system or by performing for some in the embodiment The method or the combination of method element that other devices of the function are implemented.Therefore, have and be used to implement methods described or method The processor of the necessary instruction of element forms the device for implementing this method or method element.In addition, device embodiment Element described in this is the example of following device:The device is used to implement as in order to performed by implementing the element of the purpose of the invention Function.
As used in this, unless specifically stated so, come using ordinal number " first ", " second ", " the 3rd " etc. Description plain objects are merely representative of the different instances for being related to similar object, and are not intended to imply that the object being so described must Must have the time it is upper, spatially, in terms of sequence or given order in any other manner.
Although describing the present invention according to the embodiment of limited quantity, above description, the art are benefited from It is interior it is clear for the skilled person that in the scope of the present invention thus described, it can be envisaged that other embodiments.Additionally, it should be noted that The language that is used in this specification primarily to readable and teaching purpose and select, rather than in order to explain or limit Determine subject of the present invention and select.Therefore, in the case of without departing from the scope and spirit of the appended claims, for this Many modifications and changes will be apparent from for the those of ordinary skill of technical field.For the scope of the present invention, to this The done disclosure of invention is illustrative and not restrictive, and it is intended that the scope of the present invention be defined by the claims appended hereto.

Claims (10)

1. a kind of calculate the method that hair moves towards in portrait, methods described is suitable to perform in computing device, including step:
Calculate the gradient of each pixel in hair zones in portrait;
According to the hair direction of each pixel of the gradient calculation of each pixel;
At least one connected region is generated according to the hair direction of each pixel;
Pixel beyond at least one connected region is incorporated to a connected region adjacent thereto by the first predetermined condition Domain, generate new connected region;And
It is determined that in each new connected region hair direction it is forward and reverse, obtain the hair direction of each new connected region.
2. the method for claim 1, wherein step for calculating the gradient of each pixel in hair zones in portrait Suddenly include:
Hair zones in portrait are obtained by hair zones recognition methods;And
The gradient of each pixel in hair zones is calculated using predetermined gradient operator.
3. method as claimed in claim 1 or 2, wherein, after the step of obtaining the hair direction of each new connected region, Also include step:
The hair direction of each new connected region is smoothed, the hair direction after smoothing processing is new as this The hair direction of connected region.
4. such as the method any one of claim 1-3, wherein, the hair direction of each pixel pixel The angle angle of upper hair direction and x-axis represents, is denoted as θ:
θ=arctan (Gy/Gx),
Wherein, Gy is the gradient of pixel in the y-axis direction, and Gx is the gradient of pixel in the direction of the x axis.
5. such as the method any one of claim 1-4, wherein, the hair direction of each pixel of basis generate to The step of few connected region, includes:
According to the pixel connection weight of the described each hair direction calculating of pixel pixel pixel adjacent thereto;And
At least one connected region is generated according to the pixel connection weight.
6. method as claimed in claim 5, wherein, wrap the step of the pixel connection weight for calculating pixel pixel adjacent thereto Include:
If the Grad of the Grad of the pixel and one neighbor pixel is all higher than Grads threshold and the hair of the pixel The absolute difference in silk direction and the hair direction of the neighbor pixel is less than angle threshold, then by the pixel and the adjacent pixel The pixel connection weight of point is 1;
Otherwise, it is 0 by the pixel connection weight of the pixel and the neighbor pixel.
7. the method as described in claim 5 or 6, wherein, the neighbor pixel of pixel (y, x) includes:Pixel (y, x+1) With pixel (y+1, x).
8. method as claimed in claim 7, wherein, the pixel connection weight L of pixel (y, x) and pixel (y, x+1)y,x+1Table It is shown as:
With
The pixel connection weight L of pixel (y, x) and pixel (y+1, x)y+1,xIt is expressed as:
Wherein, Gy,xFor the Grad of pixel (y, x), Gy,x+1For pixel (y, x+1) Grad, Gy+1,xFor pixel (y+ 1, x) Grad, θy,xFor the hair direction of pixel (y, x), θy,x+1For the hair direction of pixel (y, x+1), θy+1,xFor The hair direction of pixel (y+1, x), ε are Grads threshold, and pi/2 is angle threshold.
9. a kind of computing device, including:
One or more processors;With
Memory;
One or more programs, wherein one or more of program storages are in the memory and are configured as by described one Individual or multiple computing devices, one or more of programs include being used to perform according in claim 1-8 methods describeds The instruction of either method.
10. a kind of computer-readable recording medium for storing one or more programs, one or more of programs include instruction, The instruction is when computing device so that appointing in method of the computing device according to claim 1-8 One method.
CN201711240025.9A 2017-11-30 2017-11-30 Method and computing equipment for computing hair trend in portrait Active CN107886516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711240025.9A CN107886516B (en) 2017-11-30 2017-11-30 Method and computing equipment for computing hair trend in portrait

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711240025.9A CN107886516B (en) 2017-11-30 2017-11-30 Method and computing equipment for computing hair trend in portrait

Publications (2)

Publication Number Publication Date
CN107886516A true CN107886516A (en) 2018-04-06
CN107886516B CN107886516B (en) 2020-05-15

Family

ID=61776306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711240025.9A Active CN107886516B (en) 2017-11-30 2017-11-30 Method and computing equipment for computing hair trend in portrait

Country Status (1)

Country Link
CN (1) CN107886516B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108629781A (en) * 2018-04-24 2018-10-09 成都品果科技有限公司 A kind of hair method for drafting
CN109087377A (en) * 2018-08-03 2018-12-25 北京字节跳动网络技术有限公司 Method and apparatus for handling image
CN109408653A (en) * 2018-09-30 2019-03-01 叠境数字科技(上海)有限公司 Human body hair style generation method based on multiple features retrieval and deformation
WO2020155711A1 (en) * 2019-02-02 2020-08-06 深圳市商汤科技有限公司 Image generating method and apparatus, electronic device, and storage medium
CN111540021A (en) * 2020-04-29 2020-08-14 网易(杭州)网络有限公司 Hair data 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
CN114187633A (en) * 2021-12-07 2022-03-15 北京百度网讯科技有限公司 Image processing method and device, and training method and device of image generation model
CN114758391A (en) * 2022-04-08 2022-07-15 北京百度网讯科技有限公司 Hairstyle image determining method and device, electronic equipment, storage medium and product

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7418371B2 (en) * 2005-03-30 2008-08-26 Seoul National University Industry Foundation Method and system for graphical hairstyle generation using statistical wisp model and pseudophysical approaches
JP4619112B2 (en) * 2004-12-27 2011-01-26 花王株式会社 Hair shape measurement method
CN102800129A (en) * 2012-06-20 2012-11-28 浙江大学 Hair modeling and portrait editing method based on single image
US20120313937A1 (en) * 2010-01-18 2012-12-13 Disney Enterprises, Inc. Coupled reconstruction of hair and skin
CN103606186A (en) * 2013-02-02 2014-02-26 浙江大学 Virtual hair style modeling method of images and videos
US20140198108A1 (en) * 2013-01-16 2014-07-17 Disney Enterprises, Inc. Multi-linear dynamic hair or clothing model with efficient collision handling
CN104376597A (en) * 2014-12-05 2015-02-25 北京航空航天大学 Multi-direction constrained hair reconstruction method
CN105405163A (en) * 2015-12-28 2016-03-16 北京航空航天大学 Vivid static-state hair modeling method based on multiple direction fields
CN107103619A (en) * 2017-04-19 2017-08-29 腾讯科技(上海)有限公司 A kind of processing method of hair grain direction, apparatus and system

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4619112B2 (en) * 2004-12-27 2011-01-26 花王株式会社 Hair shape measurement method
US7418371B2 (en) * 2005-03-30 2008-08-26 Seoul National University Industry Foundation Method and system for graphical hairstyle generation using statistical wisp model and pseudophysical approaches
US20120313937A1 (en) * 2010-01-18 2012-12-13 Disney Enterprises, Inc. Coupled reconstruction of hair and skin
CN102800129A (en) * 2012-06-20 2012-11-28 浙江大学 Hair modeling and portrait editing method based on single image
US20140198108A1 (en) * 2013-01-16 2014-07-17 Disney Enterprises, Inc. Multi-linear dynamic hair or clothing model with efficient collision handling
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
CN105405163A (en) * 2015-12-28 2016-03-16 北京航空航天大学 Vivid static-state hair modeling method based on multiple direction fields
CN107103619A (en) * 2017-04-19 2017-08-29 腾讯科技(上海)有限公司 A kind of processing method of hair grain direction, apparatus and system

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
H. CHEN,ET.AL: "A generative model of human hair for hair sketching", 《2005 IEEE COMPUTER SOCIETY CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION (CVPR"05)》 *
HONG CHEN,ET.AL: "A Generative Sketch Model for Human Hair Analysis and Synthesis", 《IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE》 *
WENZHANGZHI GUO: "Hair Segmentation Using Heuristically-Trained Neural Networks", 《HTTPS://TSPACE.LIBRARY.UTORONTO.CA/BITSTREAM/1807/72673/3/GUO_WENZHANGZHI_201606_MAS_THESIS.PDF》 *
刘莎: "基于学习的人脸表情动画生成方法研究", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
李康: "基于分区的颅骨面貌复原技术与真实感处理方法研究", 《中国博士学位论文全文数据库信息科技辑》 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108629781A (en) * 2018-04-24 2018-10-09 成都品果科技有限公司 A kind of hair method for drafting
CN108629781B (en) * 2018-04-24 2022-04-22 成都品果科技有限公司 Hair drawing method
CN109087377A (en) * 2018-08-03 2018-12-25 北京字节跳动网络技术有限公司 Method and apparatus for handling image
CN109408653B (en) * 2018-09-30 2022-01-28 叠境数字科技(上海)有限公司 Human body hairstyle generation method based on multi-feature retrieval and deformation
CN109408653A (en) * 2018-09-30 2019-03-01 叠境数字科技(上海)有限公司 Human body hair style generation method based on multiple features retrieval and deformation
WO2020155711A1 (en) * 2019-02-02 2020-08-06 深圳市商汤科技有限公司 Image generating method and apparatus, electronic device, and storage medium
US11410344B2 (en) 2019-02-02 2022-08-09 Shenzhen Sensetime Technology Co., Ltd. Method for image generation, electronic device, and storage medium
CN111540021A (en) * 2020-04-29 2020-08-14 网易(杭州)网络有限公司 Hair data 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
CN114187633A (en) * 2021-12-07 2022-03-15 北京百度网讯科技有限公司 Image processing method and device, and training method and device of image generation model
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
CN107886516B (en) 2020-05-15

Similar Documents

Publication Publication Date Title
CN107886516A (en) The method and computing device that hair moves towards in a kind of calculating portrait
CN109255769A (en) The training method and training pattern and image enchancing method of image enhancement network
WO2020010979A1 (en) Method and apparatus for training model for recognizing key points of hand, and method and apparatus for recognizing key points of hand
JP6154075B2 (en) Object detection and segmentation method, apparatus, and computer program product
CN107808147A (en) A kind of face Confidence method based on the tracking of real-time face point
EP2680222A1 (en) Method, apparatus and computer program product for processing media content
CN110473137A (en) Image processing method and device
CN110084313A (en) A method of generating object detection model
CN111208783B (en) Action simulation method, device, terminal and computer storage medium
CN110414574A (en) A kind of object detection method calculates equipment and storage medium
CN107369174A (en) The processing method and computing device of a kind of facial image
CN110516803A (en) Traditional computer vision algorithm is embodied as neural network
CN104318259A (en) Target picture identifying device and method for and computing device
CN110084253A (en) A method of generating object detection model
CN109886341A (en) A kind of trained method for generating Face datection model
CN108898142A (en) A kind of recognition methods and calculating equipment of handwritten formula
CN111831844A (en) Image retrieval method, image retrieval device, image retrieval apparatus, and medium
CN107832794A (en) A kind of convolutional neural networks generation method, the recognition methods of car system and computing device
CN110222703A (en) Image outline identification method, apparatus, equipment and medium
CN110287857A (en) A kind of training method of characteristic point detection model
WO2022206729A1 (en) Method and apparatus for selecting cover of video, computer device, and storage medium
CN109840912A (en) The modification method of abnormal pixel and equipment is calculated in a kind of image
CN108960012B (en) Feature point detection method and device and electronic equipment
CN107808394B (en) Image processing method based on convolutional neural network and mobile terminal
CN111260655B (en) Image generation method and device based on deep neural network model

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