CN104751407B - A kind of method and apparatus for being blurred to image - Google Patents

A kind of method and apparatus for being blurred to image Download PDF

Info

Publication number
CN104751407B
CN104751407B CN201510106876.9A CN201510106876A CN104751407B CN 104751407 B CN104751407 B CN 104751407B CN 201510106876 A CN201510106876 A CN 201510106876A CN 104751407 B CN104751407 B CN 104751407B
Authority
CN
China
Prior art keywords
character contour
image
piecemeal
region
personage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510106876.9A
Other languages
Chinese (zh)
Other versions
CN104751407A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201510106876.9A priority Critical patent/CN104751407B/en
Publication of CN104751407A publication Critical patent/CN104751407A/en
Application granted granted Critical
Publication of CN104751407B publication Critical patent/CN104751407B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Analysis (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The present invention provides a kind of methods for being blurred to image, wherein method includes the following steps: the image information for the image specified according to user, determines the character contour in the image;Identified character contour is compared with corresponding character contour template, and the character contour in character contour template is adjusted according to comparison result, so that character contour adjusted is matched with the identified character contour in character contour template;According to the character contour adjusted, personage region in image that the user specifies, the transitional region between background area and personage region and background area are determined;Gradual virtualization is carried out by blurring to the background area, and to the transitional region, come the image after being blurred.According to the solution of the present invention, it can achieve preferably virtualization effect.

Description

A kind of method and apparatus for being blurred to image
Technical field
The present invention relates to field of computer technology more particularly to a kind of methods for being blurred to image.
Background technique
In the prior art, when being blurred to image, usually by the specified region blurred of user, and then using existing Image weakening method the specified region blurred of user blurred.
Summary of the invention
The object of the present invention is to provide a kind of methods for being blurred to image.
According to an aspect of the present invention, a kind of method for being blurred to image is provided, wherein this method includes Following steps:
According to the image information for the image that user specifies, the character contour in the image is determined;
Identified character contour is compared with corresponding character contour template, and personage is adjusted according to comparison result Character contour in contour mould, so that character contour adjusted and the identified character contour in character contour template Matching;
According to the character contour adjusted, determine personage region in image that the user specifies, background area with And the transitional region between personage region and background area;
Gradual virtualization is carried out by blurring to the background area, and to the transitional region, to be blurred Image afterwards, wherein the gradual virtualization indicate in the transitional region closer to the personage region part virtualization Degree is more shallow, and the virtualization degree closer to the part of the background area is deeper.
According to another aspect of the present invention, a kind of device for being blurred to image is additionally provided, wherein the dress It sets including following device:
Image information for the image specified according to user, determines the device of the character contour in the image;
For identified character contour to be compared with corresponding character contour template, and adjusted according to comparison result Character contour in character contour template, so that character contour adjusted and the identified personage in character contour template The device of outline;
For according to the character contour adjusted, determining the personage region in image that the user specifies, background area The device of transitional region between domain and personage region and background area;
For carrying out gradual virtualization by blurring to the background area, and to the transitional region, to obtain The device of image after virtualization, wherein the gradual virtualization indicates in the transitional region closer to the personage region Partial virtualization degree is more shallow, and the virtualization degree closer to the part of the background area is deeper.
Compared with prior art, the invention has the following advantages that 1) image can be more subtly divided into personage region, Transitional region and background area, and background area and transitional region are blurred respectively;Also, to the gradual of transitional region Virtualization is so that the virtualization degree for the part that transitional region is connected with personage region is 0, and the part being connected with background area Virtualization degree it is identical as the virtualization degree of background area, this makes the virtualization of image more smooth, and the image after virtualization can be with Bring better visual effect;2) personage can be presented on shooting display interface based on character contour template in computer equipment Profile, so that user be guided to show posture of preferably taking pictures;3) people in image can be directly determined according to character contour template Object profile and the virtualization for carrying out background area, therefore, user are not necessarily to that the region for needing to blur is manually specified, very convenient;And it should Kind determines character contour based on character contour template, and to the mode that transitional region and background area are blurred, additionally it is possible to Scene suitable for dynamic image;4) since character contour template can indicate correct character contour, even if computer Equipment fails to correctly identify out the character contour in image completely and (is limited to the processing capacity and algorithm of computer equipment, people Wrong identification in the details of object profile is entirely possible), it also can more correctly identify the background area in image It is blurred;5) according to the practical character contour in image, the character contour to indicate character contour template is adjusted, because This, is using for reference the shooting posture in character contour template, and can more correctly identify background based on character contour template While region, the personage that is taken can freely walk about in entire shooting picture, without being limited in character contour template Position defined by character contour.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, of the invention other Feature, objects and advantages will become more apparent upon:
Fig. 1 is the flow diagram of the method for being blurred to image of one embodiment of the invention;
Fig. 2 is the structural schematic diagram of the device for being blurred to image of one embodiment of the invention;
Fig. 3 is the schematic diagram of the image comprising personage of an example of the present invention;
Fig. 4 is the schematic diagram of two kinds of character contours of an example of the present invention;
Fig. 5 is the schematic diagram of the piecemeal near the part character contour of an example of the present invention.
The same or similar appended drawing reference represents the same or similar component in attached drawing.
Specific embodiment
Fig. 1 is the flow diagram of the method for being blurred to image of one embodiment of the invention.
Wherein, the method for the present embodiment is mainly realized by computer equipment;The computer equipment includes that network is set Standby and user equipment;The network equipment includes but is not limited to the service of single network server, multiple network servers composition Device group or the cloud consisting of a large number of computers or network servers for being based on cloud computing (Cloud Computing), wherein cloud meter It is one kind of distributed computing, a super virtual computer consisting of a loosely coupled set of computers;The net Network locating for network equipment includes but is not limited to internet, wide area network, Metropolitan Area Network (MAN), local area network, VPN network etc..
The user equipment includes but is not limited to PC machine, tablet computer, smart phone, PDA, digital camera etc..
It should be noted that the computer equipment is only for example, other computers that are existing or being likely to occur from now on Equipment is such as applicable to the present invention, should also be included within the scope of protection of the present invention, and is incorporated herein by reference.
Method according to the present embodiment includes step S1, step S2, step S3 and step S4.
In step sl, the image information for the image that computer equipment is specified according to user, determines the personage in the image Profile.
For example, the image information for the image that computer equipment is specified according to user, and combine user signified on this image Fixed region, from the character contour obtained in the region in the image.
Wherein, the image that user specifies includes any image that can be used in computer equipment.Preferably, user refers to Fixed image includes but is not limited to: (shooting of the camera of such as mobile device shows boundary to the image presented on shooting display interface The image etc. presented on face), user is in local image selected (such as in the photograph album of local).It should be noted that working as user Specified image is when shooting the image presented on display interface, and the computer equipment is usually user equipment.
Wherein, the image information of image includes any information relevant to the graphic feature of the image;Preferably, the figure As information includes but is not limited to the Aspect Ratio of image, the pixel of image, the resolution ratio of image, average gray value of image etc..
Preferably, the step S1 further comprises step S11, step S12 and step S13.
In step s 11, the image that computer equipment specifies user is divided into multiple piecemeals.
For example, image that computer equipment specifies user, as shown in Figure 3 is divided into multiple piecemeals.
Specifically, the image that computer equipment can be used that various ways specify user is divided into multiple piecemeals.
For example, the Aspect Ratio for the image that computer equipment is specified according to user divides the image into multiple piecemeals;Such as The Aspect Ratio for the image that user specifies is 16:9, then the image averaging is divided into k* (16*9) a piecemeal by computer equipment, Wherein, k is natural number.
In another example the image averaging that computer equipment specifies user is divided into predetermined piecemeal quantity piecemeal;As made a reservation for Quantity is 64, and the image averaging that computer equipment directly specifies user is divided into 8*8 piecemeal.
It should be noted that the piecemeal can have various shapes, such as rectangle, sector or other irregular shapes, Also, the shape and/or size of multiple piecemeals that the image that user specifies is divided may be different.For example, meter Rectangular image uniform is divided into M*N piecemeal by calculation machine equipment, and (M is the piecemeal quantity in horizontal direction, and N is Vertical Square Upward piecemeal quantity), which is the identical rectangle piecemeal of size.In another example computer equipment schemes ellipse As being divided into M*N piecemeal, the piecemeal of the image edge location is sector, and the piecemeal in middle position is rectangle.
It should be noted that the multiple piecemeal may partly overlap.For example, the pixel for the image that user specifies is A*B (A is the length in pixels of image, and B is the pixel wide of image), in step sl, computer equipment divides the image into size Identical M*N piecemeal, wherein the pixel of each piecemeal be that (m is the length in pixels of piecemeal to m*n, and n is the pixel of piecemeal Width);Then as the value of the theoretical length in pixels M*m of image length in pixels A actual greater than image, the M*N piecemeal is in water Square it will appear and partly overlap upwards;As the value of the theoretical pixel wide N*n of image pixel wide B actual greater than image, The M*N piecemeal will appear in vertical direction to partly overlap.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the image of any image for specifying user is divided into the implementation of multiple piecemeals, It should be included in the scope of the present invention.
In step s 12, computer equipment is according to the corresponding image of piecemeal each at least one piecemeal of multiple piecemeals Information determines the piecemeal attribute of each piecemeal.
Wherein, the piecemeal attribute is used to indicate piecemeal and belongs to personage region or inhuman object area.For example, piecemeal attribute is Indicate that piecemeal belongs to personage region when " 0 ", instruction piecemeal belongs to inhuman object area when piecemeal attribute is " 1 ".Wherein, the personage The region that region is located at by the personage in image, the inhuman object area are the region in image other than personage region;For example, The region that personage shown in Fig. 3 is located at is people's object area, and the white space other than the people's object area is inhuman object area.
Wherein, the corresponding image information of piecemeal includes any information relevant to the graphic feature of the piecemeal;Preferably, divide The corresponding image information of block includes the image information of image-region corresponding to the piecemeal.Preferably, the corresponding image letter of piecemeal Breath include but is not limited to the Aspect Ratio of piecemeal, the pixel of the piecemeal of image-region corresponding to piecemeal, the resolution ratio of piecemeal, point The gray value etc. of block.
Specifically, computer equipment is believed according to the corresponding image of piecemeal each at least one piecemeal of multiple piecemeal Breath, determines that the implementation of the piecemeal attribute of each piecemeal includes but is not limited to:
1) computer equipment is according to the corresponding image information of piecemeal each at least one piecemeal of multiple piecemeal, and ties Predetermined recognition rule is closed, determines the piecemeal attribute of each piecemeal.
Wherein, the predetermined recognition rule include it is any it is scheduled, can determine piecemeal according to the image information of piecemeal Piecemeal attribute rule.
For example, the predetermined recognition rule includes image information and piecemeal based on piecemeal defined in person recognition technology Correlation rule between attribute;For each piecemeal at least one described piecemeal, in conjunction with the correlation rule, computer equipment It can be according to the corresponding image information of the piecemeal, to determine the piecemeal attribute of the piecemeal.
2) computer equipment is made according to the corresponding image information of piecemeal each at least one piecemeal of the multiple piecemeal For the input of piecemeal attributive classification device, the piecemeal attribute of each piecemeal that the piecemeal attributive classification device exports, described is obtained.
Wherein, the piecemeal attributive classification device includes any piecemeal that piecemeal can be exported according to the image information of piecemeal The classifier of attribute.Preferably, the piecemeal attributive classification device is two classifiers based on image block (patch);For example, piecemeal Attributive classification device is using the image information of piecemeal as input, using the piecemeal attribute of piecemeal as output, also, works as and exports as " 0 " When indicate that the piecemeal belongs to personage region, when output be " 1 " when indicate that the piecemeal belongs to inhuman object area.
Preferably, step S12 uses above-mentioned implementation 2) when, this preferred embodiment is further comprising the steps of: computer is set It is standby to use multiple piecemeals for having determined that piecemeal attribute, piecemeal attributive classification device model is trained, the piecemeal attribute is obtained Classifier.
For example, existing 1000 piecemeals, wherein the piecemeal attribute instruction piecemeal of 600 piecemeals belongs to personage region, other 400 piecemeals piecemeal attribute instruction piecemeal belong to inhuman object area.Computer equipment uses 1000 piecemeals, to piecemeal Attributive classification device model is trained, and obtains piecemeal attributive classification device, which can be according to the image of piecemeal Information exports the piecemeal attribute of piecemeal.Then in step s 11, the image that computer equipment specifies user is divided into multiple points Block;In step s 12, computer equipment is using the corresponding image information of piecemeal each in multiple piecemeal as the piecemeal attribute point The input of class device, to obtain the piecemeal attribute of piecemeal that the piecemeal attributive classification device exports, each.
Preferably, computer equipment can be based on machine learning techniques, such as deep neural network technology, to establish piecemeal attribute Sorter model.
It should be noted that those skilled in the art will be understood that in step s 12, computer equipment may be needed only really The piecemeal attribute of part piecemeal in fixed multiple piecemeals, the piecemeal attribute without all piecemeals in the multiple piecemeals of determination.Example When such as, due to shooting personage, often there are certain spatial context, (i.e. image top edge is tended to belong at image top edge Inhuman object area), therefore, the piecemeal that computer equipment can directly determine the grade top edges belong to inhuman object area (or when top When the piecemeal at portion edge proportion in whole image is less than the piecemeal quantity of certain proportion or image higher than certain amount, The piecemeal for directly determining the grade top edges belongs to inhuman object area), step is executed without the piecemeal to the equal top edges S12.In another example when computer equipment determines that the part piecemeal in multiple piecemeals is character face's image based on person recognition technology When, computer equipment can directly determine the piecemeal attribute of each piecemeal in the part piecemeal, the determined piecemeal attribute instruction Piecemeal belongs to personage region;Then in step s 12, computer equipment can only near the part piecemeal it is a certain range of at least One piecemeal executes step S12 to determine the piecemeal attribute of each piecemeal at least one piecemeal, without to certain model It encloses outer piecemeal and executes step S12.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the corresponding image of each piecemeal in any at least one piecemeal according to multiple piecemeals Information determines the implementation of the piecemeal attribute of each piecemeal, should be included in the scope of the present invention.
In step s 13, computer equipment determines that the user is specified according to the piecemeal attribute of at least one piecemeal Image in character contour.
Specifically, computer equipment determines the reality of the character contour in image according to the piecemeal attribute of at least one piecemeal Existing mode includes but is not limited to:
1) computer equipment determines the personage in image directly according to the piecemeal for belonging to personage region at least one piecemeal Profile.
Specifically, computer equipment determines in image directly according to the piecemeal for belonging to personage region at least one piecemeal The character contour being made of the piecemeal that this etc. belongs to personage region.
For example, computer equipment based on the morphological operation in image processing techniques, calculates and belongs at least one piecemeal Multiple connected regions that the piecemeal in personage region is formed, and further calculate the maximum connected region of area in multiple connected region The profile in domain, and using the profile being calculated as the character contour in image.
Fig. 4 shows a part of two kinds of character contours in image;Wherein, Line1 is 1) institute is true using this implementation A part of fixed character contour.
2) computer equipment determines initial character contour according to the piecemeal attribute of at least one piecemeal;Also, computer is set It is standby that lines smoothing processing is carried out to initial character contour, determine character contour.
For example, Fig. 4 is the schematic diagram of the character contour in the determination image of an example of the present invention.Computer equipment according to The piecemeal attribute of at least one piecemeal determines that initial character contour line character contour, the Line1 in Fig. 4 show initial personage A part of profile;Then, computer equipment carries out lines smoothing processing to the initial character contour line character contour, determines people Object profile, Line2 shown in Fig. 4 are a part of character contour for obtain after lines smoothing processing to Line1.
Wherein, computer equipment determines the implementation of the initial character contour in image, with aforementioned implementation 1) in Computer equipment directly according to the piecemeal for belonging to personage region at least one piecemeal, determines the realization of the character contour in image Mode is same or similar.
Wherein, computer equipment can be used a variety of curve smoothing algorithms, such as smothing filtering algorithm, remove crude algorithm, come Lines smoothing processing is carried out to initial character contour.
The implementation 2) determined by character contour compare implementation 1) it is more smooth, it is also more accurate.
3) the step S13 further comprises step S13-1, step S13-2 and step S13-3.
In step S13-1, computer equipment divide at least one in resulting multiple piecemeals point according to image The piecemeal attribute of block, determines the piecemeal near character contour.
Specifically, computer equipment determines that character contour is attached according to the piecemeal attribute of at least one piecemeal in multiple piecemeals The implementation of close piecemeal includes but is not limited to:
A) for each piecemeal at least one described piecemeal, when different adjacent of the piecemeal attribute for being present in the piecemeal When piecemeal, the piecemeal which is identified as near character contour.
For example, Fig. 5 is the schematic diagram of the piecemeal near the part character contour of an example of the present invention.For the sake of simplicity, The figure only shown in part piecemeal in image, wherein P1 and P2 is two adjacent piecemeals.In step S13-1, work as calculating Machine equipment determine P1 piecemeal attribute and P2 piecemeal attribute it is not identical when, P1 and P2 are identified as character contour by computer equipment Neighbouring piecemeal.
B) computer equipment determines initial character contour according to the piecemeal attribute of at least one piecemeal;Computer equipment will Piecemeal near the initial character contour, as the piecemeal near the character contour.
Wherein, computer equipment determines the implementation of initial character contour according to the piecemeal attribute of at least one piecemeal With the implementation 1 of abovementioned steps S13) in computer equipment directly according to belong at least one piecemeal personage region point Block determines that the implementation of the character contour in image is same or similar, and details are not described herein.
For example, computer equipment determines initial character contour according to the piecemeal attribute of at least one piecemeal, wherein Fig. 5 institute Show that solid line is a part of the initial character contour;Also, computer equipment is by the piecemeal near initial character contour, such as comprising With all dotted line frames of the equitant lines of solid line shown in Fig. 5, as the piecemeal near the character contour.
In step S13-2, for each piecemeal in the piecemeal near character contour, computer equipment draws the piecemeal It is divided into multiple sub-piecemeals, and according to the corresponding image information of sub-piecemeal each in the multiple sub-piecemeal, determines each sub-piecemeal Sub-piecemeal attribute.Wherein, the sub-piecemeal attribute is used to indicate sub-piecemeal and belongs to personage region or inhuman object area.
For example, each piecemeal pixel in piecemeal near character contour is 40*40, for each piecemeal, calculate The piecemeal is averagely divided into 16 sub-piecemeals (pixel of each sub-piecemeal is 10*10) by machine equipment, and according to 16 sons point The corresponding image information of each sub-piecemeal, determines the sub-piecemeal attribute of each sub-piecemeal in block.
Wherein, piecemeal is divided into image in the implementation and abovementioned steps S11 of multiple sub-piecemeals by computer equipment The implementation for being divided into multiple piecemeals is same or similar, and details are not described herein.
Wherein, computer equipment determines every height according to the corresponding image information of each sub-piecemeal in multiple sub-piecemeals The implementation of the sub-piecemeal attribute of piecemeal, with computer equipment in abovementioned steps S12 according at least one point of multiple piecemeals The corresponding image information of each piecemeal in block determines that the implementation of the piecemeal attribute of each piecemeal is same or similar, This is repeated no more.
In step S13-3, the sub-piecemeal category for the sub-piecemeal that computer equipment includes according to the piecemeal near character contour Property, determine the character contour in image.
Specifically, the sub-piecemeal attribute for the sub-piecemeal that computer equipment includes according to the piecemeal near character contour determines The implementation of character contour in described image includes but is not limited to:
A) son for the sub-piecemeal for belonging to personage region that computer equipment directly includes according to the piecemeal near character contour Piecemeal attribute determines the character contour in image.
For example, the sub-piecemeal attribute for the sub-piecemeal that computer equipment includes according to the piecemeal near character contour, based on figure Belong to the region that the sub-piecemeal in personage region constituted as processing technique calculates, and using the profile in the region as the people in image Object profile.
B) the sub-piecemeal attribute for the sub-piecemeal that computer equipment includes according to the piecemeal near character contour determines roughly Character contour, and lines smoothing processing is carried out to the rough character contour, determine the character contour in image.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the image information of any image specified according to user, determines the personage in the image The implementation of profile, should be included in the scope of the present invention.
It should be noted that should shot when the image that user specifies includes shooting the image presented on display interface The image presented on display interface may be variation, also, the variation of the image with the presentation, and step S1 may be multiple It executes, which will be described in detail in subsequent preferred embodiment, and details are not described herein.
In step s 2, identified character contour is compared computer equipment with corresponding character contour template, And the character contour in character contour template is adjusted according to comparison result, so that character contour adjusted in character contour template It is matched with identified character contour.
Wherein, computer equipment obtains the implementation of corresponding character contour template and includes but is not limited to:
1) before step S2, computer equipment will in step sl determined by character contour and multiple character contour moulds Plate is matched, and selects the highest character contour template of matching degree, as corresponding character contour template.
Preferably, computer equipment is based on image masks technology come by identified character contour and multiple character contour moulds Plate is matched, and selects the highest character contour template of matching degree, as corresponding character contour template.
For example, computer equipment generates exposure mask figure mask corresponding to identified character contour0, personage in the exposure mask figure It is 1 that profile, which is formed by exposure mask value in enclosed region, and the exposure mask value outside character contour is 0;Similarly, computer equipment is distinguished Generate mask artwork corresponding to each of multiple character contour templates object contour mould;Then, computer equipment is counted respectively Calculate mask0Friendship and ratio with mask artwork corresponding to each personage's contour mould, wherein computer equipment is based on following formula It calculates the friendship and compares:
ratioi=(mask0∩maski)/(mask0∪maski))
Wherein, ratioiFor mask0And maskiFriendship and ratio;maskiFor personage's contour mould templateiCorresponding Mask artwork, wherein i=1 ... Y, Y are the total quantity of personage's contour mould;mask0∩maskiIndicate mask0With maskiBetween Intersection, mask0∪maskiIndicate mask0With maskiBetween union.
Later, computer equipment selects maximum friendship and than corresponding character contour template as corresponding character contour Template.
2) before step S2, the character contour template that computer equipment specifies user, as corresponding personage Contour mould.
For example, user selects character contour template template2 in local personage's contour mould library, then computer equipment It operates according to the user's choice, using template2 as corresponding character contour template.
As a preferred embodiment, the step S2 further comprises step S21 and step S22.
In the step s 21, identified character contour is compared computer equipment with corresponding character contour template, Determine the scaling and positional shift letter between the character contour and the identified character contour in the character contour template Breath.
Wherein, the scaling and positional shift information include character contour and the identified personage in character contour template Any relatively information between profile.Preferably, the scaling and positional shift information include but is not limited to:
1) the scaling information between the character contour and identified character contour in character contour template.Wherein, The scaling information is used to indicate the diminution between the character contour in character contour template and identified character contour Or the ratio of amplification.For example, the pantograph ratio between character contour and the identified character contour in character contour template Example information is 1:2, that is, identified character contour is exaggerated one times relative to the character contour in character contour template.
2) the positional shift letter between the character contour and identified character contour in character contour template on the image Breath.Wherein, the positional shift information includes any character contour being used to indicate in character contour template and identified people The information of positional shift between object profile on the image.For example, positional shift information is used to indicate identified character contour It is shifted 200 pixels to the right relative to the character contour in character contour template.
Preferably, computer equipment based on image masks technology come by identified character contour with by identified personage Profile is compared with corresponding character contour template.
For example, computer equipment generates the mask artwork mask of identified character contour0And character contour template is covered Mould figure mask1, and the mask value of the piecemeal near character contour is compared, with the determination scaling and positional shift information.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it is it should be appreciated by those skilled in the art that any that identified character contour is compared with corresponding character contour template, Determine the scaling and positional shift letter between the character contour and the identified character contour in the character contour template The implementation of breath, should be included in the scope of the present invention.
In step S22, computer equipment adjusts in character contour template according to the scaling and positional shift information Character contour, so that character contour adjusted is matched with the identified character contour in character contour template.
For example, in the step s 21, computer equipment determines identified character contour relative in character contour template Character contour is shifted to the right 100 pixels;Then in step S22, computer equipment takes turns the personage in character contour template Exterior feature is to 100 pixels of right translation, so that character contour and the identified character contour after translating in character contour template Match.
In another example in the step s 21, computer equipment determines identified character contour relative in character contour template Character contour be shifted 50 pixels to the right, and reduce 75%;Then in step S22, computer equipment is by character contour Character contour in template reduces 75% to 50 pixels of right translation, so that personage's wheel after translating in character contour template Exterior feature is matched with the identified character contour.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it is it should be appreciated by those skilled in the art that any that identified character contour is compared with corresponding character contour template, And the character contour in character contour template is adjusted according to comparison result, so that character contour adjusted in character contour template With the identified matched implementation of character contour, should be included in the scope of the present invention.
It should be noted that when the image that user specifies includes shooting the image presented on display interface, with the bat The variation of the image presented on display interface is taken the photograph, step S2 may be performed a plurality of times, which will give in subsequent preferred embodiment To be described in detail, details are not described herein.
In step s3, computer equipment is according to the character contour adjusted, determines in image that the user specifies Personage region, the transitional region between background area and personage region and background area.
Specifically, computer equipment is according to the character contour adjusted, determines the personage area in image that user specifies The implementation of transitional region between domain, background area and personage region and background area includes but is not limited to:
1) enclosed region that computer equipment is directly constituted character contour adjusted will be adjusted as personage region Character contour afterwards extends to the outside the region being formed by between profile and the character contour adjusted after preset width and makees For transitional region, using personage region in the image that user specifies and the region other than transitional region as background area.
For example, preset width is 20 pixels.The closure that computer equipment is directly constituted character contour adjusted Region as personage region, character contour adjusted is extended to the outside the profile that is formed by after the width of 20 pixels with Region between the character contour adjusted is as transitional region, using the region other than personage region and transitional region as back Scene area.
2) step S3 further comprises step S31 and step S32.
In step S31, computer equipment determines personage region according to character contour adjusted.
Specifically, the enclosed region that computer equipment is constituted character contour adjusted is as personage region.
In step s 32, computer equipment determines transition according to personage region and/or the image information of inhuman object area Region and background area.
Wherein, the inhuman object area includes transitional region and background area, that is, the inhuman object area includes people Any region other than object area.
Wherein, the image information of the personage region and/or inhuman object area includes any with personage region and/or inhuman The relevant information of the graphic feature of object area in the picture.Preferably, the image of the personage region and/or inhuman object area is believed Breath includes that any corresponding image-region is related in the picture with the image information of the personage region and/or inhuman object area Image information.Preferably, the image information of the personage region and/or inhuman object area includes but is not limited to:
A) size in personage region.Wherein, much information can be used to indicate the size in personage region, as personage region exists Shared ratio, the size in personage region etc. in image.
B) size of inhuman object area.Wherein, much information can be used to indicate the size of inhuman object area, such as non-personage Region shared ratio, the size of inhuman object area etc. in the picture.
C) colouring information of the colouring information in personage region and/or inhuman object area.
Wherein, the colouring information in the personage region includes any information relevant to the color in personage region, such as personage Averaged color value, the grey level histogram in personage region of color difference, personage region between region and inhuman object area etc..
Wherein, the colouring information of the inhuman object area includes any information relevant to the color of inhuman object area, such as The grey level histogram of the averaged color value of color difference, inhuman object area between personage region and inhuman object area, inhuman object area Deng.
Specifically, computer equipment determines transitional region according to personage region and/or the image information of inhuman object area Width, and character contour is extended to the outside into region that the width is formed by between profile and character contour as transitional region, And using personage region in image and the region other than transitional region as background area.Preferably, personage region is bigger, transition region Domain is wider;Inhuman object area is bigger, and transitional region is narrower;Color difference between personage region and inhuman object area is bigger, mistake It is wider to cross region;In personage region close to inhuman object area region, in inhuman object area close to personage region region it Between color difference it is bigger, transitional region is wider.
Wherein, computer equipment can be used various ways and determine and believed according to the image of personage region and/or inhuman object area Breath, determines the width of transitional region.
For example, being preset with width corresponding to multiple color difference ranges in computer equipment, computer equipment is according to personage area The color difference in domain and inhuman object area, using width corresponding to the color difference range that the color difference is fallen into as the width of transitional region.
In another example computer equipment is according to the size in personage region and the colouring information in personage region and/or non-personage The colouring information in region determines the width of transitional region.As an example, computer equipment is based on following formula, to determine The width of transitional region:
W=a*Size (Ifg)/Size(I)+b/|Avg(Ifg)-Avg(I-Ifg)|
Wherein, W is the width of transitional region;Size(Ifg) be people's object area size, Size (I) be image size, Size(Ifg)/Size (I) is people's object area shared ratio in the picture;Avg(Ifg) be people's object area averaged color value; Avg(I-Ifg) be inhuman object area averaged color value;|Avg(Ifg)-Avg(I-Ifg) | it is people's object area and inhuman object area Between color difference;A is size weight coefficient, and b is color difference weight coefficient, it is preferable that a and b is predetermined value.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System determines in image that user specifies it should be appreciated by those skilled in the art that any according to the character contour adjusted The implementation of transitional region between personage region, background area and personage region and background area should be included in this In the range of invention.
In step s 4, computer equipment is carried out by blurring to the background area, and to the transitional region Gradual virtualization, come the image after being blurred.
Wherein, a variety of image fuzzy algorithmic approaches can be used in computer equipment, as Gaussian mode is gelatinized (blurring) algorithm, PID (Proportion Integration Differentiation, proportional integral differential) algorithm etc. carries out background area empty Change, the transitional region after being blurred.For example, computer equipment, which is based on Gaussian mode, is gelatinized algorithm, Gaussian kernel (Gaussian is used Kernel convolution algorithm) is carried out with background area, to blur to background area.
Wherein, the gradual virtualization indicates that the virtualization degree in transitional region closer to the part in personage region is more shallow, Virtualization degree closer to the part of background area is deeper.
Wherein, the implementation that computer equipment carries out gradual virtualization to transitional region includes but is not limited to:
1) computer equipment is directly according to the corresponding image information of transitional region, to transition region from the edge in personage region Transitional region is carried out the virtualization of virtualization degree from low to high by the edge in domain.
Preferably, transitional region is carried out virtualization degree by 0 to predetermined extent virtualization by computer equipment.Wherein, described Predetermined extent is used to indicate scheduled virtualization degree;In this implementation, which is used to indicate transitional region, close The virtualization degree at the edge of background area;For example, predetermined extent is 20%, then computer equipment is directly corresponding according to transitional region Image information, to the edge of transitional region from the edge in personage region, by transitional region carry out virtualization degree by 0 it is progressive to 20% virtualization.
2) computer equipment blurs transitional region, the transitional region after being blurred;Then, computer equipment will Transitional region after virtualization is mixed with the transitional region not blurred, the transitional region after obtaining gradual virtualization.Wherein, more Close to personage region, specific gravity of the transitional region not blurred in mixing is higher;Mistake closer to the background area, after virtualization It is higher to cross specific gravity of the region in the mixing.
Wherein, the implementation and aforementioned computer equipment that computer equipment blurs transitional region are to background area The implementation blurred is same or similar, is not repeating herein.
Preferably, if computer equipment is based on Gaussian mode and is gelatinized algorithm, convolution fortune is carried out using Gaussian kernel and background area Calculate, to be blurred to background area, then this implementation 2) in, computer equipment use same size Gaussian kernel and mistake It crosses region and carries out convolution algorithm, the transitional region to blur to transitional region, after being blurred.
As an example, computer equipment based on following formula by after virtualization transitional region and the transition region that does not blur Domain is mixed, to obtain the transitional region after gradual virtualization:
Iout=alpha*Iclear+(1-alpha)*Iblurred
Wherein, IclearFor the transitional region not blurred, IblurredFor the transitional region after virtualization, IoutIt is mixed to get Transitional region after gradual virtualization.Wherein, alpha is mixing control parameter, which, which is used to indicate, does not blur Transitional region or virtualization after specific gravity of the transitional region in mixing, the value range of the mixing control parameter is [0,1];It is excellent Selection of land, alpha=d2/ (d1+d2), wherein d1 is that (pixel can be random in transitional region for a pixel in transitional region Or specific pixel) arrive the shortest distance in personage region, d2 is the shortest distance of the pixel to background area.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that it is any by being blurred to the background area, and the transitional region is carried out Gradual virtualization should be included in the scope of the present invention come the implementation of the image after being blurred.
As a preferred embodiment, step S4 can further include steps of computer equipment and obtain what user determined Blur extent index;Computer equipment blurs background area according to acquired virtualization extent index, and to the mistake It crosses region and carries out gradual virtualization, come the image after being blurred.Wherein, the virtualization extent index, which is used to indicate, is blurred Degree.
For example, computer equipment obtains the virtualization extent index p that user determines, wherein p=40%;Then computer equipment Background area is subjected to the virtualization that virtualization degree is 40%, and to the edge of transitional region from the edge in personage region, incited somebody to action Cross region carry out virtualization degree from 0 it is progressive to 40% virtualization, thus the image after being blurred.
Wherein, computer equipment can be used various ways and obtain the virtualization extent index that user determines.For example, computer is set It is standby to directly acquire the virtualization extent index that user inputs in the computer equipment;In another example computer equipment is according to user at this The selected virtualization extent index of user is determined to the selection operation of multiple optional virtualization extent index in computer equipment.
It should be noted that this preferred embodiment can be with the implementation 2 of abovementioned steps S4) it combines, it may be assumed that computer equipment According to acquired virtualization extent index, transitional region is blurred, the transitional region after being blurred;Then, computer Equipment mixes the transitional region after virtualization with the transitional region not blurred, the transitional region after obtaining gradual virtualization.
As a preferred embodiment, when the image that user specifies includes shooting the image presented on display interface, this reality It applies the method for example upon step s 2, and before step S3, further includes step S5 and step S6.
In step s 5, character contour adjusted is presented on shooting display interface in computer equipment.
For example, in step s 2, computer equipment according to comparison result by the character contour in character contour template to the right 100 pixels are translated, so that the character contour after translating in character contour template is matched with identified character contour;Later, In step s 5, the character contour after the translation is presented on shooting display interface in computer equipment.
In step s 6, computer equipment obtains image of the user based on the character contour shooting presented, and by the bat The image taken the photograph, the image specified as the user.
It should be noted that those skilled in the art will be understood that in this preferred embodiment, step S1, step S2 and step S5 may be only performed once, it is also possible to be performed a plurality of times.
For example, if the personage shot in the image or image presented on display interface does not have until executing step S6 Variation, then computer equipment only needs to be implemented step S1, S2 and a S5.Wherein, computer equipment can be based on bio-identification skill Art, such as the identification of face recognition, the bodily form, to judge whether the position for shooting personage in the image presented on display interface becomes Change.
In another example computer equipment is after executing step S1, S2 and a S5, whenever the figure presented on shooting display interface As or image in personage change (for example, the movement due to personage in actual scene, alternatively, shooting condition is as shot Angle, shooting focal length etc. change caused by variation), computer equipment can execute step S1, S2 and S5, with present with The matched character contour of figure picture of the personage in image after variation, until user executes shooting operation, so that computer is set It is standby to execute step S6.
It should be noted that computer equipment can not also detect whether shooting display interface changes, and with certain Time interval repeats step S1, S2 and S5, until step S6 is performed.
It should be noted that computer equipment executes step S3 and S4 to the image taken after step S6.
It should be noted that needing to be taken turns according to the character contour determined in step S1 with multiple personages in computer equipment Wide template is matched, in the case where obtaining corresponding character contour template, whenever computer equipment repeats step S1, calculating Machine equipment can reacquire corresponding personage's wheel before executing step S2 according to the character contour of determination newest in step S1 Wide template.
As a preferred embodiment, the method for the present embodiment is further comprising the steps of: computer equipment is by the figure after virtualization As being presented to the user;Computer equipment executes corresponding operating to the image after the virtualization according to the operation of user feedback.Wherein, The corresponding operating include it is any can be to operation performed by the image after virtualization;Preferably, the corresponding operating include but It is not limited to preservation performed by the image after virtualization, delete operation etc..
As a preferred embodiment, the method for the present embodiment further includes step S7, step S8 and step S9.
In the step s 7, computer equipment obtains the image information of an image comprising personage.
Specifically, computer equipment can obtain the image information of the image comprising personage from local or other equipment.
In step s 8, computer equipment determines in the image according to the image information of the image comprising personage Character contour.
Specifically, computer determines the character contour in the image according to the image information of the image comprising personage Implementation and step S1 in the image information of image specified according to user of computer equipment, determine the personage in the image The implementation of profile is same or similar, and details are not described herein.
In step s 9, computer equipment generates character contour template according to determined character contour.By this step Suddenly, locally determining character contour can be generated a template by computer equipment, for subsequent use.
As a preferred embodiment, the scheme of the present embodiment is further comprising the steps of: computer equipment is by local personage Contour mould is uploaded in network;Preferably, the network is community network, such as discussion bar, microblogging, wechat.By this step, Computer equipment can share local character contour template with the public in network.
As a preferred embodiment, the scheme of the present embodiment is further comprising the steps of: computer equipment is downloaded from network Character contour template.By this step, character contour template in the available network of computer equipment, to enrich local people Object contour mould.
In the prior art, when being blurred to image, usually by the specified region blurred of user, and then using existing Image weakening method carry out the virtualization of virtualization degree to the specified region blurred of user., it is clear that this image Virtualization mode needs user accurately to operate to image, is inconvenient.In addition, image virtualization mode is only applicable to The still image of forming, and the scene for being not applied for dynamic image (such as when user finds a view to shooting picture, can not be held The operation in the specified virtualization region of row).
In addition, in the prior art, often only special camera, could by two objects or scene apart from each other, Directly to shoot the photo with virtualization effect.For example, if in shooting picture including a personage and having one with the personage The background environment of set a distance, then can be used special camera, directly shoot background blurring and personage clearly image.But it is existing General camera in technology simultaneously has above-mentioned function.Therefore, in order to enable the image of general camera shooting can also have background empty The effect of change, therefore produce image virtualization technology.However, due to image virtualization idea from aforementioned special camera bat Camera shooting function, and why aforementioned special camera can be realized aforementioned shooting function, be because having between figure and ground's environment There is certain distance, that is, under this shooting environmental, image is divided into two levels: figure and ground (i.e. personage region and non- Personage region).Therefore, by this influence, those skilled in the art often have such inertial thinking: by dividing image For the two levels of figure and ground, to realize background blurring effect.In addition, in the equal images virtualization technology, it is necessary to by User is come the image of clearly specifying needs to blur.
In addition, many users simultaneously are bad to pose when taking pictures, which is usually only capable of showing most in actual life Simple posture (such as normal stance or sitting posture), alternatively, showing other postures of its currently known dawn;Also, this etc. User is only capable of learning new posture by artificial approach, as view and emulate in other people photos posture, by other people oral transmissions new Posture etc..However, user is only capable of the experience of taking pictures by itself due in the prior art, alternatively, the photo met knows Some postures of taking pictures, and when taking pictures adjust itself to imitate the posture that it is known, this make user know and The posture that can be shown is typically more fixed and negligible amounts, also, differ with desired effect can for the posture actually shown of user It can be larger;In addition, user views and emulates posture in other people photos or when by the new posture of other people oral transmissions, it may be necessary to more The various postures of netpage search are come for viewing and emulating, or need to teach people and repeatedly solve in fact so that the posture that user shows reaches pre- Phase effect, this needs takes a significant amount of time, and process is relatively complicated.In the prior art and there is no technologies regarding to the issue above Scheme.
Above three can be solved the problems, such as simultaneously according to the scheme of the present embodiment.According to the scheme of the present embodiment, can incite somebody to action Image is more subtly divided into personage region, transitional region and background area, and carries out respectively to background area and transitional region Virtualization;Also, gradual virtualization to transitional region so that the part that transitional region is connected with personage region virtualization degree Be 0, and and the virtualization degree of part that is connected of background area it is identical as the virtualization degree of background area, this makes the void of image Change is more smooth, and the image after virtualization can bring better visual effect.
In addition, computer equipment can be presented on shooting display interface based on character contour template in the present embodiment Character contour, so that user be guided to show posture of preferably taking pictures.It, can be directly according to character contour mould also, in the present embodiment Plate determines the character contour in image and carries out the virtualization of background area, and therefore, user, which is not necessarily to be manually specified, to be needed to blur Region, it is very convenient;And this kind determines character contour based on character contour template, and carries out to transitional region and background area The mode of virtualization, additionally it is possible to the scene suitable for dynamic image.What makes more sense is that since character contour template can indicate just Therefore true character contour (is limited to count even if computer equipment fails to correctly identify out the character contour in image completely The processing capacity and algorithm of machine equipment are calculated, the wrong identification in the details of character contour is entirely possible), it also can be more correct The background area in image is identified to be blurred in ground.In addition, understood in the present embodiment according to the practical character contour in image, Character contour to indicate character contour template is adjusted, and therefore, is using for reference the shooting posture in character contour template, and Personage while more correctly identifying background area, can be taken based on character contour template can be in entire shooting picture It is middle freely to walk about, without position defined by the character contour that is limited in character contour template.
Fig. 2 is the structural schematic diagram of the device for being blurred to image of one embodiment of the invention.This is used for pair The device (hereinafter referred to as " image virtualization device ") that image is blurred includes the image of the image for being specified according to user Information determines the device hereinafter referred to as " the first determining device 1 " of the character contour in the image), for by identified people Object profile is compared with corresponding character contour template, and adjusts the personage in character contour template according to comparison result and take turns Exterior feature, so that character contour adjusted and the identified matched device of character contour (following letter in character contour template Referred to as " adjustment device 2 "), for according to the character contour adjusted, determining the personage area in image that the user specifies Device (hereinafter referred to as " the second determining device of transitional region between domain, background area and personage region and background area 3 ") and for carrying out gradual virtualization by blurring to the background area, and to the transitional region, to obtain The device of image after virtualization (" virtualization device 4 " is referred to as with lower part).
The image information for the image that first determining device 1 is specified according to user, determines the character contour in the image.
For example, the image information for the image that the first determining device 1 is specified according to user, and combine user institute on this image Specified region, from the character contour obtained in the region in the image.
Wherein, the image that user specifies includes any image that can be used in computer equipment.Preferably, user refers to Fixed image includes but is not limited to: (shooting of the camera of such as mobile device shows boundary to the image presented on shooting display interface The image etc. presented on face), user is in local image selected (such as in the photograph album of local).It should be noted that working as user Specified image is when shooting the image presented on display interface, and the computer equipment is usually user equipment.
Wherein, the image information of image includes any information relevant to the graphic feature of the image;Preferably, the figure As information includes but is not limited to the Aspect Ratio of image, the pixel of image, the resolution ratio of image, average gray value of image etc..
Preferably, the first determining device 1 further comprises that the image for specifying the user is divided into multiple piecemeals Device (hereinafter referred to as " dividing device ", not shown), for each at least one piecemeal according to the multiple piecemeal The corresponding image information of piecemeal determines device (hereinafter referred to as " the determining dress of the first son of the piecemeal attribute of each piecemeal Set ", it is not shown), for the piecemeal attribute according at least one piecemeal, determine the device of the character contour in described image (hereinafter referred to as " the second sub- determining device ", not shown).
The image that dividing device specifies user is divided into multiple piecemeals.
For example, image that dividing device specifies user, as shown in Figure 3 is divided into multiple piecemeals.
Specifically, the image that dividing device can be used that various ways specify user is divided into multiple piecemeals.
For example, the Aspect Ratio for the image that dividing device is specified according to user divides the image into multiple piecemeals;Such as use The Aspect Ratio of the specified image in family is 16:9, then the image averaging is divided into k* (16*9) a piecemeal by dividing device, wherein K is natural number.
In another example the image averaging that dividing device specifies user is divided into predetermined piecemeal quantity piecemeal;Such as predetermined number Amount is 64, and the image averaging that dividing device directly specifies user is divided into 8*8 piecemeal.
It should be noted that the piecemeal can have various shapes, such as rectangle, sector or other irregular shapes, Also, the shape and/or size of multiple piecemeals that the image that user specifies is divided may be different.For example, drawing Rectangular image uniform is divided into M*N piecemeal by separating device, and (M is the piecemeal quantity in horizontal direction, and N is vertical direction On piecemeal quantity), the M*N piecemeal be the identical rectangle piecemeal of size.In another example dividing device draws oval image It is divided into M*N piecemeal, the piecemeal of the image edge location is sector, and the piecemeal in middle position is rectangle.
It should be noted that the multiple piecemeal may partly overlap.For example, the pixel for the image that user specifies is A*B (A is the length in pixels of image, and B is the pixel wide of image), it is M*N point identical that dividing device divides the image into size Block, wherein the pixel of each piecemeal be m*n (m is the length in pixels of piecemeal, and n is the pixel wide of piecemeal);Then work as image The value of theoretical length in pixels M*m when being greater than the actual length in pixels A of image, which will appear in the horizontal direction It partly overlaps;As the value of the theoretical pixel wide N*n of image pixel wide B actual greater than image, which is hanging down Histogram will appear upwards to partly overlap.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the image of any image for specifying user is divided into the implementation of multiple piecemeals, It should be included in the scope of the present invention.
First sub- determining device is determined according to the corresponding image information of piecemeal each at least one piecemeal of multiple piecemeals The piecemeal attribute of each piecemeal.
Wherein, the piecemeal attribute is used to indicate piecemeal and belongs to personage region or inhuman object area.For example, piecemeal attribute is Indicate that piecemeal belongs to personage region when " 0 ", instruction piecemeal belongs to inhuman object area when piecemeal attribute is " 1 ".Wherein, the personage The region that region is located at by the personage in image, the inhuman object area are the region in image other than personage region;For example, The region that personage shown in Fig. 3 is located at is people's object area, and the white space other than the people's object area is inhuman object area.
Wherein, the corresponding image information of piecemeal includes any information relevant to the graphic feature of the piecemeal;Preferably, divide The corresponding image information of block includes the image information of image-region corresponding to the piecemeal.Preferably, the corresponding image letter of piecemeal Breath include but is not limited to the Aspect Ratio of piecemeal, the pixel of the piecemeal of image-region corresponding to piecemeal, the resolution ratio of piecemeal, point The gray value etc. of block.
Specifically, the first sub- determining device is according to the corresponding image of piecemeal each at least one piecemeal of multiple piecemeal Information determines that the implementation of the piecemeal attribute of each piecemeal includes but is not limited to:
1) the first sub- determining device is according to the corresponding image information of piecemeal each at least one piecemeal of multiple piecemeal, And predetermined recognition rule is combined, determine the piecemeal attribute of each piecemeal.
Wherein, the predetermined recognition rule include it is any it is scheduled, can determine piecemeal according to the image information of piecemeal Piecemeal attribute rule.
For example, the predetermined recognition rule includes image information and piecemeal based on piecemeal defined in person recognition technology Correlation rule between attribute;For each piecemeal at least one described piecemeal, in conjunction with the correlation rule, the first son is determined Device can be according to the corresponding image information of the piecemeal, to determine the piecemeal attribute of the piecemeal.
2) the first sub- determining device is believed according to the corresponding image of piecemeal each at least one piecemeal of the multiple piecemeal The input as piecemeal attributive classification device is ceased, the piecemeal attribute of each piecemeal that the piecemeal attributive classification device exports, described is obtained.
Wherein, the piecemeal attributive classification device includes any piecemeal that piecemeal can be exported according to the image information of piecemeal The classifier of attribute.Preferably, the piecemeal attributive classification device is two classifiers based on image block (patch);For example, piecemeal Attributive classification device is using the image information of piecemeal as input, using the piecemeal attribute of piecemeal as output, also, works as and exports as " 0 " When indicate that the piecemeal belongs to personage region, when output be " 1 " when indicate that the piecemeal belongs to inhuman object area.
Preferably, the first sub- determining device uses above-mentioned implementation 2) when, this preferred embodiment further includes for using more A piecemeal for having determined that piecemeal attribute is trained piecemeal attributive classification device model, obtains the piecemeal attributive classification device Device (hereinafter referred to as " training device ", not shown).
For example, existing 1000 piecemeals, wherein the piecemeal attribute instruction piecemeal of 600 piecemeals belongs to personage region, other 400 piecemeals piecemeal attribute instruction piecemeal belong to inhuman object area.Training device uses 1000 piecemeals, to piecemeal category Property sorter model be trained, obtain piecemeal attributive classification device, which can believe according to the image of piecemeal It ceases to export the piecemeal attribute of piecemeal.The image that then dividing device specifies user is divided into multiple piecemeals;First son determines dress It sets using the corresponding image information of piecemeal each in multiple piecemeal as the input of the piecemeal attributive classification device, to obtain the piecemeal The piecemeal attribute of the output of attributive classification device, each piecemeal.
Preferably, training device can be based on machine learning techniques, such as deep neural network technology, divide to establish piecemeal attribute Class device model.
It should be noted that those skilled in the art will be understood that the first sub- determining device may only need to determine multiple points The piecemeal attribute of part piecemeal in block, the piecemeal attribute without all piecemeals in the multiple piecemeals of determination.For example, due to clapping When taking the photograph personage, often there are certain spatial context, (i.e. image top edge tends to belong to non-personage area at image top edge Domain), therefore, the piecemeal that computer equipment can directly determine the grade top edges belongs to inhuman object area (or when top edge When piecemeal proportion in whole image is less than the piecemeal quantity of certain proportion or image higher than certain amount, directly determine The piecemeal of the grade top edges belongs to inhuman object area), it is held without piecemeal of the first sub- determining device to the grade top edges Row operation.In another example when computer equipment determines that the part piecemeal in multiple piecemeals is character face based on person recognition technology When image, computer equipment can directly determine the piecemeal attribute of each piecemeal in the part piecemeal, the determined piecemeal attribute Instruction piecemeal belongs to personage region;Then the first sub- determining device can only near the part piecemeal it is a certain range of at least one Piecemeal executes operation to determine the piecemeal attribute of each piecemeal at least one piecemeal, without point outside to a certain range Block executes operation.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the corresponding image of each piecemeal in any at least one piecemeal according to multiple piecemeals Information determines the implementation of the piecemeal attribute of each piecemeal, should be included in the scope of the present invention.
Second sub- determining device determines in image that the user specifies according to the piecemeal attribute of at least one piecemeal Character contour.
Specifically, the second sub- determining device determines the character contour in image according to the piecemeal attribute of at least one piecemeal Implementation include but is not limited to:
1) the second sub- determining device determines in image directly according to the piecemeal for belonging to personage region at least one piecemeal Character contour.
Specifically, the second sub- determining device determines figure directly according to the piecemeal for belonging to personage region at least one piecemeal The character contour being made of as in the piecemeal that this etc. belongs to personage region.
For example, the second sub- determining device is calculated at least one piecemeal based on the morphological operation in image processing techniques Belong to multiple connected regions that the piecemeal in personage region is formed, and further calculates the maximum company of area in multiple connected region The profile in logical region, and using the profile being calculated as the character contour in image.
Fig. 4 shows a part of two kinds of character contours in image;Wherein, Line1 is 1) institute is true using this implementation A part of fixed character contour.
2) the second sub- determining device determines initial character contour according to the piecemeal attribute of at least one piecemeal;Also, second Sub- determining device carries out lines smoothing processing to initial character contour, determines character contour.
For example, Fig. 4 is the schematic diagram of the character contour in the determination image of an example of the present invention.Second sub- determining device According to the piecemeal attribute of at least one piecemeal, determine that initial character contour line character contour, the Line1 in Fig. 4 are shown initially A part of character contour;Then, the second sub- determining device smoothly locates initial character contour line character contour progress lines Reason, determines character contour, and Line2 shown in Fig. 4 is a part of character contour for obtain after lines smoothing processing to Line1.
Wherein, the second sub- determining device determines the implementation of the initial character contour in image, with aforementioned implementation 1) the second sub- determining device determines personage's wheel in image directly according to the piecemeal for belonging to personage region at least one piecemeal in Wide implementation is same or similar.
Wherein, a variety of curve smoothing algorithms can be used in the second sub- determining device, and such as smothing filtering algorithm removes crude algorithm Deng to initial character contour progress lines smoothing processing.
The implementation 2) determined by character contour compare implementation 1) it is more smooth, it is also more accurate.
3) the second sub- determining device further comprises divide in resulting multiple piecemeals at least to image for basis The piecemeal attribute of one piecemeal determines device (hereinafter referred to as " the 5th sub- determining device ", the figure of the piecemeal near character contour Do not show), for for each piecemeal in the piecemeal near character contour, which is divided into multiple sub-piecemeals, and according to The corresponding image information of each sub-piecemeal in the multiple sub-piecemeal, determine the sub-piecemeal attribute of each sub-piecemeal device (with Down referred to as " the 6th sub- determining device ", not shown) and sub-piecemeal for including according to the piecemeal near character contour Sub-piecemeal attribute determines the character contour (hereinafter referred to as " the 7th sub- determining device ", not shown) in image.
5th sub- determining device is according to the piecemeal category for divide to image at least one piecemeal in resulting multiple piecemeals Property, determine the piecemeal near character contour.
Specifically, the 5th sub- determining device determines that personage takes turns according to the piecemeal attribute of at least one piecemeal in multiple piecemeals The implementation of piecemeal near exterior feature includes but is not limited to:
A) for each piecemeal at least one described piecemeal, when different adjacent of the piecemeal attribute for being present in the piecemeal When piecemeal, which is identified as the piecemeal near character contour by the 5th sub- determining device.
For example, Fig. 5 is the schematic diagram of the piecemeal near the part character contour of an example of the present invention.For the sake of simplicity, The figure only shown in part piecemeal in image, wherein P1 and P2 is two adjacent piecemeals.When determine the piecemeal attribute of P1 with When the piecemeal attribute of P2 is not identical, P1 and P2 are identified as the piecemeal near character contour by the 5th sub- determining device.
B) the 5th sub- determining device determines initial character contour according to the piecemeal attribute of at least one piecemeal;5th son is really Device is determined by the piecemeal near the initial character contour, as the piecemeal near the character contour.
Wherein, the 5th sub- determining device determines the realization of initial character contour according to the piecemeal attribute of at least one piecemeal The implementation 1 of mode and the aforementioned second sub- determining device) in directly according to belong at least one piecemeal personage region point Block determines that the implementation of the character contour in image is same or similar, and details are not described herein.
For example, piecemeal attribute of the 5th sub- determining device according at least one piecemeal, determines initial character contour, wherein Solid line shown in Fig. 5 is a part of the initial character contour;Also, the 5th sub- determining device by near initial character contour point Block, such as all dotted line frames comprising the equitant lines of solid line as shown in Fig. 5, as the piecemeal near the character contour.
For each piecemeal in the piecemeal near character contour, which is divided into multiple sons by the 6th sub- determining device Piecemeal, and according to the corresponding image information of sub-piecemeal each in the multiple sub-piecemeal, determine the sub-piecemeal category of each sub-piecemeal Property.Wherein, the sub-piecemeal attribute is used to indicate sub-piecemeal and belongs to personage region or inhuman object area.
For example, each piecemeal pixel in piecemeal near character contour is 40*40, for each piecemeal, the 6th The piecemeal is averagely divided into 16 sub-piecemeals (pixel of each sub-piecemeal is 10*10) by sub- determining device, and according to this 16 The corresponding image information of each sub-piecemeal, determines the sub-piecemeal attribute of each sub-piecemeal in sub-piecemeal.
Wherein, piecemeal is divided into the implementation of multiple sub-piecemeals and aforementioned dividing device and will schemed by the 6th sub- determining device The implementation that picture is divided into multiple piecemeals is same or similar, and details are not described herein.
Wherein, the 6th sub- determining device determines every according to the corresponding image information of each sub-piecemeal in multiple sub-piecemeals The implementation of the sub-piecemeal attribute of a sub-piecemeal, with the aforementioned first sub- determining device according at least one piecemeal of multiple piecemeals In the corresponding image information of each piecemeal, determine that the implementation of the piecemeal attribute of each piecemeal is same or similar, herein It repeats no more.
The sub-piecemeal attribute for the sub-piecemeal that 7th sub- determining device includes according to the piecemeal near character contour, determines image In character contour.
Specifically, the sub-piecemeal attribute for the sub-piecemeal that the 7th sub- determining device includes according to the piecemeal near character contour, The implementation for determining the character contour in described image includes but is not limited to:
A) sub-piecemeal for belonging to personage region that the 7th sub- determining device directly includes according to the piecemeal near character contour Sub-piecemeal attribute, determine the character contour in image.
For example, the sub-piecemeal attribute for the sub-piecemeal that the 7th sub- determining device includes according to the piecemeal near character contour, base The region for belonging to the sub-piecemeal in personage region and being constituted is calculated in image processing techniques, and using the profile in the region as in image Character contour.
B) the sub-piecemeal attribute for the sub-piecemeal that the 7th sub- determining device includes according to the piecemeal near character contour determines thick Character contour slightly, and lines smoothing processing is carried out to the rough character contour, determine the character contour in image.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that the image information of any image specified according to user, determines the personage in the image The implementation of profile, should be included in the scope of the present invention.
It should be noted that should shot when the image that user specifies includes shooting the image presented on display interface The image presented on display interface may be variation, also, the variation of the image with the presentation, and the first determining device 1 can It can be performed a plurality of times, which will be described in detail in subsequent preferred embodiment, and details are not described herein.
Identified character contour is compared adjustment device 2 with corresponding character contour template, and ties according to comparing Fruit adjusts the character contour in character contour template, so that character contour adjusted and identified people in character contour template Object outline.
Wherein, adjustment device 2 obtains the implementation of corresponding character contour template and includes but is not limited to:
1) image virtualization device further includes the following device that operation is executed before adjusting device 2: being used for will be identified Character contour is matched with multiple character contour templates, and selects the highest character contour template of matching degree, as the phase The device (hereinafter referred to as " coalignment ", not shown) for the character contour template answered.
Preferably, coalignment is based on image masks technology come by identified character contour and multiple character contour templates It is matched, and selects the highest character contour template of matching degree, as corresponding character contour template.
For example, coalignment generates exposure mask figure mask corresponding to identified character contour0, personage's wheel in the exposure mask figure It is 1 that exterior feature, which is formed by exposure mask value in enclosed region, and the exposure mask value outside character contour is 0;Similarly, coalignment generates respectively Mask artwork corresponding to each of multiple character contour templates object contour mould;Then, coalignment calculates separately mask0 Friendship and ratio with mask artwork corresponding to each personage's contour mould, wherein coalignment is based on following formula and calculates the friendship And compare:
ratioi=(mask0∩maski)/(mask0∪maski))
Wherein, ratioiFor mask0And maskiFriendship and ratio;maskiFor personage's contour mould templateiCorresponding Mask artwork, wherein i=1 ... Y, Y are the total quantity of personage's contour mould;mask0∩maskiIndicate mask0With maskiBetween Intersection, mask0∪maskiIndicate mask0With maskiBetween union.
Later, coalignment selects maximum friendship and than corresponding character contour template as corresponding character contour mould Plate.
2) image virtualization device further includes the following device that operation is executed before adjusting device 2: for specifying user Character contour template, as corresponding character contour template device (hereinafter referred to as " third determining device ", figure not Show).
For example, user selects character contour template template2 in local personage's contour mould library, then third determines dress It sets and operates according to the user's choice, using template2 as corresponding character contour template.
As a preferred embodiment, adjustment device 2 further comprises for by identified character contour and corresponding people Object contour mould is compared, and determines between the character contour and the identified character contour in the character contour template Scaling and positional shift information device (hereinafter referred to as " comparison device ", not shown) and for according to the scaling With positional shift information, the character contour in character contour template is adjusted, so that personage's wheel adjusted in character contour template The wide and identified matched device of character contour (hereinafter referred to as " sub- adjustment device ", not shown).
Identified character contour is compared comparison device with corresponding character contour template, determines personage's wheel The scaling and positional shift information between character contour and the identified character contour in wide template.
Wherein, the scaling and positional shift information include character contour and the identified personage in character contour template Any relatively information between profile.Preferably, the scaling and positional shift information include but is not limited to:
1) the scaling information between the character contour and identified character contour in character contour template.Wherein, The scaling information is used to indicate the diminution between the character contour in character contour template and identified character contour Or the ratio of amplification.For example, the pantograph ratio between character contour and the identified character contour in character contour template Example information is 1:2, that is, identified character contour is exaggerated one times relative to the character contour in character contour template.
2) the positional shift letter between the character contour and identified character contour in character contour template on the image Breath.Wherein, the positional shift information includes any character contour being used to indicate in character contour template and identified people The information of positional shift between object profile on the image.For example, positional shift information is used to indicate identified character contour It is shifted 200 pixels to the right relative to the character contour in character contour template.
Preferably, comparison device is taken turns identified character contour with by identified personage based on image masks technology It is wide to be compared with corresponding character contour template.
For example, comparison device generates the mask artwork mask of identified character contour0And the mask of character contour template Scheme mask1, and the mask value of the piecemeal near character contour is compared, with the determination scaling and positional shift information.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it is it should be appreciated by those skilled in the art that any that identified character contour is compared with corresponding character contour template, Determine the scaling and positional shift letter between the character contour and the identified character contour in the character contour template The implementation of breath, should be included in the scope of the present invention.
Son adjustment device adjusts the character contour in character contour template according to the scaling and positional shift information, with Match character contour adjusted in personage's contour mould with the identified character contour.
For example, comparison device determines that identified character contour is put down to the right relative to the character contour in character contour template 100 pixels are moved;Son adjusts device for the character contour in character contour template to 100 pixels of right translation, so that personage Character contour after translating in contour mould is matched with the identified character contour.
In another example comparison device determines identified character contour relative to the character contour in character contour template to the right 50 pixels are shifted, and reduce 75%;Then son adjustment device is by the character contour in character contour template to right translation 50 A pixel, and 75% is reduced, so that the character contour after translating in character contour template is matched with the identified character contour.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it is it should be appreciated by those skilled in the art that any that identified character contour is compared with corresponding character contour template, And the character contour in character contour template is adjusted according to comparison result, so that character contour adjusted in character contour template With the identified matched implementation of character contour, should be included in the scope of the present invention.
It should be noted that when the image that user specifies includes shooting the image presented on display interface, with the bat The variation of the image presented on display interface is taken the photograph, adjustment device 2 may be performed a plurality of times, which will be in subsequent preferred embodiment It is described in detail, details are not described herein.
Second determining device 3 determines the personage area in image that the user specifies according to the character contour adjusted Transitional region between domain, background area and personage region and background area.
Specifically, the second determining device 3 is according to the character contour adjusted, determines the personage in image that user specifies The implementation of transitional region between region, background area and personage region and background area includes but is not limited to:
1) enclosed region that the second determining device 3 is directly constituted character contour adjusted, will as personage region Character contour adjusted extends to the outside the area that preset width is formed by later between profile and the character contour adjusted Domain is as transitional region, using personage region in the image that user specifies and the region other than transitional region as background area.
For example, preset width is 20 pixels.Second determining device 3 is directly closed what character contour adjusted was constituted Region is closed as personage region, character contour adjusted is extended to the outside to the profile being formed by after the width of 20 pixels Region between the character contour adjusted as transitional region, using the region other than personage region and transitional region as Background area.
2) the second determining device 3 further comprises for determining the personage area according to the character contour adjusted The device (hereinafter referred to as " the sub- determining device of third ", not shown) in domain and for according to the personage region and/or inhuman The image information of object area determines device (hereinafter referred to as " the determining dress of the 4th son of the transitional region and background area Set ").
The sub- determining device of third determines personage region according to character contour adjusted.
Specifically, the enclosed region that the sub- determining device of third is constituted character contour adjusted is as personage region.
4th sub- determining device according to personage region and/or the image information of inhuman object area, determine transitional region and Background area.
Wherein, the inhuman object area includes transitional region and background area, that is, the inhuman object area includes people Any region other than object area.
Wherein, the image information of the personage region and/or inhuman object area includes any with personage region and/or inhuman The relevant information of the graphic feature of object area in the picture.Preferably, the image of the personage region and/or inhuman object area is believed Breath includes that any corresponding image-region is related in the picture with the image information of the personage region and/or inhuman object area Image information.Preferably, the image information of the personage region and/or inhuman object area includes but is not limited to:
A) size in personage region.Wherein, much information can be used to indicate the size in personage region, as personage region exists Shared ratio, the size in personage region etc. in image.
B) size of inhuman object area.Wherein, much information can be used to indicate the size of inhuman object area, such as non-personage Region shared ratio, the size of inhuman object area etc. in the picture.
C) colouring information of the colouring information in personage region and/or inhuman object area.
Wherein, the colouring information in the personage region includes any information relevant to the color in personage region, such as personage Averaged color value, the grey level histogram in personage region of color difference, personage region between region and inhuman object area etc..
Wherein, the colouring information of the inhuman object area includes any information relevant to the color of inhuman object area, such as The grey level histogram of the averaged color value of color difference, inhuman object area between personage region and inhuman object area, inhuman object area Deng.
Specifically, the 4th sub- determining device determines transition region according to personage region and/or the image information of inhuman object area The width in domain, and character contour is extended to the outside into region that the width is formed by between profile and character contour as transition region Domain, and using personage region in image and the region other than transitional region as background area.Preferably, personage region is bigger, mistake It is wider to cross region;Inhuman object area is bigger, and transitional region is narrower;Color difference between personage region and inhuman object area is got over Greatly, transitional region is wider;Close to the region of inhuman object area in personage region, with the area in inhuman object area close to personage region Color difference between domain is bigger, and transitional region is wider.
Wherein, the 4th sub- determining device can be used various ways and determine according to personage region and/or the figure of inhuman object area As information, the width of transitional region is determined.
For example, width corresponding to multiple color difference ranges is preset in computer equipment, the 4th sub- determining device personage area The color difference in domain and inhuman object area, using width corresponding to the color difference range that the color difference is fallen into as the width of transitional region.
In another example the 4th sub- determining device is according to the size in personage region and the colouring information in personage region and/or non- The colouring information in personage region determines the width of transitional region.As an example, the 4th sub- determining device is based on following public affairs Formula, to determine the width of transitional region:
W=a*Size (Ifg)/Size(I)+b/|Avg(Ifg)-Avg(I-Ifg)|
Wherein, W is the width of transitional region;Size(Ifg) be people's object area size, Size (I) be image size, Size(Ifg)/Size (I) is people's object area shared ratio in the picture;Avg(Ifg) be people's object area averaged color value; Avg(I-Ifg) be inhuman object area averaged color value;|Avg(Ifg)-Avg(I-Ifg) | it is people's object area and inhuman object area Between color difference;A is size weight coefficient, and b is color difference weight coefficient, it is preferable that a and b is predetermined value.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System determines in image that user specifies it should be appreciated by those skilled in the art that any according to the character contour adjusted The implementation of transitional region between personage region, background area and personage region and background area should be included in this In the range of invention.
Device 4 is blurred by blurring to the background area, and gradual virtualization is carried out to the transitional region, come Image after being blurred.
Wherein, a variety of image fuzzy algorithmic approaches can be used in virtualization device 4, as Gaussian mode is gelatinized (blurring) algorithm, PID (Proportion Integration Differentiation, proportional integral differential) algorithm etc. carries out background area empty Change, the transitional region after being blurred.For example, virtualization device 4, which is based on Gaussian mode, is gelatinized algorithm, Gaussian kernel (Gaussian is used Kernel convolution algorithm) is carried out with background area, to blur to background area.
Wherein, the gradual virtualization indicates that the virtualization degree in transitional region closer to the part in personage region is more shallow, Virtualization degree closer to the part of background area is deeper.
Wherein, the implementation that virtualization device 4 carries out gradual virtualization to transitional region includes but is not limited to:
1) virtualization device 4 is directly according to the corresponding image information of transitional region, to transition region from the edge in personage region Transitional region is carried out the virtualization of virtualization degree from low to high by the edge in domain.
Preferably, transitional region is carried out virtualization degree by 0 to predetermined extent virtualization by virtualization device 4.Wherein, described pre- Determine degree and is used to indicate scheduled virtualization degree;In this implementation, which is used to indicate transitional region, close back The virtualization degree at the edge of scene area;For example, predetermined extent is 20%, then it is directly corresponding according to transitional region to blur device 4 Image information, to the edge of transitional region from the edge in personage region, by transitional region carry out virtualization degree by 0 it is progressive to 20% virtualization.
2) virtualization device 4 blurs transitional region, the transitional region after being blurred;Then, virtualization device 4 will be empty Transitional region after change is mixed with the transitional region not blurred, the transitional region after obtaining gradual virtualization.Wherein, it more leans on Person of modern times's object area, specific gravity of the transitional region not blurred in mixing are higher;Transition closer to the background area, after virtualization Specific gravity of the region in the mixing is higher.
Wherein, the implementation and aforementioned virtualization device 4 that virtualization device 4 blurs transitional region to background area into The implementation of row virtualization is same or similar, is not repeating herein.
Preferably, if virtualization device 4, which is based on Gaussian mode, is gelatinized algorithm, convolution fortune is carried out using Gaussian kernel and background area Calculate, to be blurred to background area, then this implementation 2) in, virtualization device 4 using same size Gaussian kernel and mistake It crosses region and carries out convolution algorithm, the transitional region to blur to transitional region, after being blurred.
As an example, virtualization device 4 based on following formula by after virtualization transitional region and the transition region that does not blur Domain is mixed, to obtain the transitional region after gradual virtualization:
Iout=alpha*Iclear+(1-alpha)*Iblurred
Wherein, IclearFor the transitional region not blurred, IblurredFor the transitional region after virtualization, IoutIt is mixed to get Transitional region after gradual virtualization.Wherein, alpha is mixing control parameter, which, which is used to indicate, does not blur Transitional region or virtualization after specific gravity of the transitional region in mixing, the value range of the mixing control parameter is [0,1];It is excellent Selection of land, alpha=d2/ (d1+d2), wherein d1 is that (pixel can be random in transitional region for a pixel in transitional region Or specific pixel) arrive the shortest distance in personage region, d2 is the shortest distance of the pixel to background area.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention, rather than to limit of the invention System, it should be appreciated by those skilled in the art that it is any by being blurred to the background area, and the transitional region is carried out Gradual virtualization should be included in the scope of the present invention come the implementation of the image after being blurred.
As a preferred embodiment, virtualization device 4 can further comprise following device: the virtualization determined for obtaining user Extent index (hereinafter referred to as " the first acquisition device ", not shown), for according to acquired virtualization extent index, to background Region is blurred, and carries out gradual virtualization to the transitional region, (hereinafter referred to as " sub come the image after being blurred Blur device ", not shown).Wherein, the virtualization extent index is used to indicate the degree blurred.
For example, the first acquisition device obtains the virtualization extent index p that user determines, wherein p=40%;Then fictitious makeup It sets and background area is subjected to the virtualization that virtualization degree is 40%, and to the edge of transitional region from the edge in personage region, it will Transitional region carry out virtualization degree from 0 it is progressive to 40% virtualization, thus the image after being blurred.
Wherein, the first acquisition device can be used various ways and obtain the virtualization extent index that user determines.For example, first obtains Device is taken to directly acquire the virtualization extent index that user inputs in the computer equipment;In another example the first acquisition device according to Family determines that the selected virtualization degree of user is joined to the selection operation of multiple optional virtualization extent index in the computer equipment Number.
It should be noted that this preferred embodiment can be with the implementation 2 of aforementioned virtualization device 4) it combines, it may be assumed that first obtains It takes device according to acquired virtualization extent index, transitional region is blurred, the transitional region after being blurred;Then, Virtualization device 4 mixes the transitional region after virtualization with the transitional region not blurred, the transition after obtaining gradual virtualization Region.
As a preferred embodiment, when the image that user specifies includes shooting the image presented on display interface, this reality The image virtualization device for applying example further includes and executing before the second determining device 3 the following dress of operation after adjusting device 2 Set: (hereinafter referred to as " first is presented dress to the device for the character contour adjusted to be presented on shooting display interface Set ", it is not shown), for obtaining image of the user based on the character contour shooting presented, and by the image of the shooting, as The device (hereinafter referred to as " the second acquisition device ", not shown) for the image that the user specifies.
Character contour adjusted is presented on shooting display interface in first presentation device.
For example, adjustment device 2 according to comparison result by the character contour in character contour template to 100 pictures of right translation Element, so that the character contour after translating in character contour template is matched with identified character contour;Later, the first presentation device Character contour after the translation is presented on shooting display interface.
Second acquisition device obtains image of the user based on the character contour shooting presented, and by the image of the shooting, The image specified as the user.
It should be noted that those skilled in the art will be understood that in this preferred embodiment, the first determining device 1, adjustment dress Set 2 and first presentation device may be only performed once operation, it is also possible to operation is performed a plurality of times.
For example, if shooting the people in the image or image presented on display interface until executing the second acquisition device Object does not change, then the first determining device 1, adjustment device 2 and the first presentation device only need to be implemented once-through operation.Wherein, it counts Biological identification technology can be based on by calculating machine equipment, such as face recognition, the bodily form identify, to judge to shoot the figure presented on display interface Whether the position of personage changes as in.
In another example the first determining device 1, adjustment device 2 and the first presentation device after executing once-through operation, whenever shooting The personage in image or image presented on display interface change (for example, the movement due to personage in actual scene, or Person, shooting condition as shooting angle, shooting focal length etc. change caused by variation), the first determining device 1, adjustment device 2 Operation can be executed with the first presentation device, with the matched personage's wheel of the figure picture of the personage in the image after presenting and changing Exterior feature, until user executes shooting operation, the second acquisition device executes operation.
It should be noted that computer equipment can not also detect shooting display interface whether change, and make first really Determine device 1, adjustment device 2 and the first presentation device and repeat operation at a certain time interval, until the second acquisition device Execute operation.
It should be noted that after the second acquisition device executes operation, 4 pairs of the device bats of the second determining device 3 and virtualization The image taken the photograph executes operation.
It should be noted that coalignment need according to character contour determined by the first determining device 1 come with it is multiple Character contour template is matched, in the case where obtaining corresponding character contour template, whenever the first determining device 1 repeats to hold Row operation, coalignment execute operation before adjusting device, and coalignment is according to the people of newest determination in the first determining device 1 Object profile reacquires corresponding character contour template.
As a preferred embodiment, the image virtualization device of the present embodiment further includes following device: for it will blur after Device (hereinafter referred to as " the second presentation device ", not shown) that image is presented to the user, for the standby behaviour according to user feedback Make, the device (hereinafter referred to as " executive device ", not shown) of corresponding operating is executed to the image after the virtualization.Wherein, described Corresponding operating include it is any can be to operation performed by the image after virtualization;Preferably, the corresponding operating includes but unlimited In to preservation performed by the image after virtualization, delete operation etc..
As a preferred embodiment, the image virtualization device of the present embodiment further includes for obtaining one figure comprising personage The device (hereinafter referred to as " third acquisition device ", not shown) of the image information of picture, the figure for according to including personage The image information of picture, determine the character contour in the image device (hereinafter referred to as " third determining device ", not shown), with And for according to determined character contour, (hereinafter referred to as " generating means ", figure to be not for the device of generation character contour template Show).
Third acquisition device obtains the image information of an image comprising personage.
Specifically, third acquisition device can obtain the image information of the image comprising personage from local or other equipment.
Third determining device determines the character contour in the image according to the image information of the image comprising personage.
Specifically, third determining device determines the people in the image according to the image information of the image comprising personage The image information for the image that the implementation of object profile and the first determining device 1 are specified according to user, determines the people in the image The implementation of object profile is same or similar, and details are not described herein.
Generating means generate character contour template according to determined character contour.Pass through generating means, computer equipment Locally determining character contour can be generated a template, for subsequent use.
As a preferred embodiment, the image virtualization device of the present embodiment further includes for by local character contour template The device (hereinafter referred to as " uploading device ", not shown) being uploaded in network;Preferably, the network is community network, such as Discussion bar, microblogging, wechat etc..By uploading device, computer equipment can be by the public in local character contour template and network Share.
As a preferred embodiment, the image virtualization device of the present embodiment further includes for downloading character contour from network The device (hereinafter referred to as " download apparatus ", not shown) of template.By download apparatus, in the available network of computer equipment Character contour template, to enrich local character contour template.
In the prior art, when being blurred to image, usually by the specified region blurred of user, and then using existing Image weakening method carry out the virtualization of virtualization degree to the specified region blurred of user., it is clear that this image Virtualization mode needs user accurately to operate to image, is inconvenient.In addition, image virtualization mode is only applicable to The still image of forming, and the scene for being not applied for dynamic image (such as when user finds a view to shooting picture, can not be held The operation in the specified virtualization region of row).
In addition, in the prior art, often only special camera, could by two objects or scene apart from each other, Directly to shoot the photo with virtualization effect.For example, if in shooting picture including a personage and having one with the personage The background environment of set a distance, then can be used special camera, directly shoot background blurring and personage clearly image.But it is existing General camera in technology simultaneously has above-mentioned function.Therefore, in order to enable the image of general camera shooting can also have background empty The effect of change, therefore produce image virtualization technology.However, due to image virtualization idea from aforementioned special camera bat Camera shooting function, and why aforementioned special camera can be realized aforementioned shooting function, be because having between figure and ground's environment There is certain distance, that is, under this shooting environmental, image is divided into two levels: figure and ground (i.e. personage region and non- Personage region).Therefore, by this influence, those skilled in the art often have such inertial thinking: by dividing image For the two levels of figure and ground, to realize background blurring effect.In addition, in the equal images virtualization technology, it is necessary to by User is come the image of clearly specifying needs to blur.
In addition, many users simultaneously are bad to pose when taking pictures, which is usually only capable of showing most in actual life Simple posture (such as normal stance or sitting posture), alternatively, showing other postures of its currently known dawn;Also, this etc. User is only capable of learning new posture by artificial approach, as view and emulate in other people photos posture, by other people oral transmissions new Posture etc..However, user is only capable of the experience of taking pictures by itself due in the prior art, alternatively, the photo met knows Some postures of taking pictures, and when taking pictures adjust itself to imitate the posture that it is known, this make user know and The posture that can be shown is typically more fixed and negligible amounts, also, differ with desired effect can for the posture actually shown of user It can be larger;In addition, user views and emulates posture in other people photos or when by the new posture of other people oral transmissions, it may be necessary to more The various postures of netpage search are come for viewing and emulating, or need to teach people and repeatedly solve in fact so that the posture that user shows reaches pre- Phase effect, this needs takes a significant amount of time, and process is relatively complicated.In the prior art and there is no technologies regarding to the issue above Scheme.
Above three can be solved the problems, such as simultaneously according to the scheme of the present embodiment.According to the scheme of the present embodiment, can incite somebody to action Image is more subtly divided into personage region, transitional region and background area, and carries out respectively to background area and transitional region Virtualization;Also, gradual virtualization to transitional region so that the part that transitional region is connected with personage region virtualization degree Be 0, and and the virtualization degree of part that is connected of background area it is identical as the virtualization degree of background area, this makes the void of image Change is more smooth, and the image after virtualization can bring better visual effect.
In addition, computer equipment can be presented on shooting display interface based on character contour template in the present embodiment Character contour, so that user be guided to show posture of preferably taking pictures.It, can be directly according to character contour mould also, in the present embodiment Plate determines the character contour in image and carries out the virtualization of background area, and therefore, user, which is not necessarily to be manually specified, to be needed to blur Region, it is very convenient;And this kind determines character contour based on character contour template, and carries out to transitional region and background area The mode of virtualization, additionally it is possible to the scene suitable for dynamic image.What makes more sense is that since character contour template can indicate just Therefore true character contour (is limited to count even if computer equipment fails to correctly identify out the character contour in image completely The processing capacity and algorithm of machine equipment are calculated, the wrong identification in the details of character contour is entirely possible), it also can be more correct The background area in image is identified to be blurred in ground.In addition, understood in the present embodiment according to the practical character contour in image, Character contour to indicate character contour template is adjusted, and therefore, is using for reference the shooting posture in character contour template, and Personage while more correctly identifying background area, can be taken based on character contour template can be in entire shooting picture It is middle freely to walk about, without position defined by the character contour that is limited in character contour template.
It should be noted that the present invention can be carried out in the assembly of software and/or software and hardware, for example, this hair Specific integrated circuit (ASIC) can be used in bright each device or any other is realized similar to hardware device.In one embodiment In, software program of the invention can be executed to implement the above steps or functions by processor.Similarly, of the invention Software program (including relevant data structure) can be stored in computer readable recording medium, for example, RAM memory, Magnetic or optical driver or floppy disc and similar devices.In addition, some of the steps or functions of the present invention may be implemented in hardware, example Such as, as the circuit cooperated with processor thereby executing each step or function.
It is obvious to a person skilled in the art that invention is not limited to the details of the above exemplary embodiments, Er Qie In the case where without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Benefit requires rather than above description limits, it is intended that all by what is fallen within the meaning and scope of the equivalent elements of the claims Variation is included in the present invention.Any reference signs in the claims should not be construed as limiting the involved claims.This Outside, it is clear that one word of " comprising " does not exclude other units or steps, and odd number is not excluded for plural number.That states in system claims is multiple Unit or device can also be implemented through software or hardware by a unit or device.The first, the second equal words are used to table Show title, and does not indicate any particular order.

Claims (18)

1. a kind of method for being blurred to image, wherein method includes the following steps:
According to the image information for the image that user specifies, the character contour in the image is determined;
Identified character contour is compared with corresponding character contour template, and character contour is adjusted according to comparison result Character contour in template, so that character contour adjusted and the identified character contour in character contour template Match;
According to the character contour adjusted, personage region, background area and the people in image that the user specifies are determined Transitional region between object area and background area;
Gradual virtualization is carried out by blurring to the background area, and to the transitional region, after being blurred Image, wherein the gradual virtualization indicate in the transitional region closer to the personage region part virtualization degree More shallow, the virtualization degree closer to the part of the background area is deeper;
Wherein, the step of character contour adjusted in character contour template includes:
Identified character contour is compared with corresponding character contour template, determines the people in the character contour template Scaling and positional shift information between object profile and the identified character contour, wherein the scaling and positional shift Information includes the scaling information between character contour and identified character contour in character contour template, and/or, people Positional shift information between character contour and identified character contour in object contour mould on the image;
According to the scaling and positional shift information, the character contour in character contour template is adjusted, so that character contour template In character contour adjusted matched with the identified character contour so that using for reference the bat in character contour template Take the photograph posture, and can be whole come the personage that while more correctly identifying background area, is taken based on character contour template It freely walks about in a shooting picture, without position defined by the character contour that is limited in character contour template.
2. according to the method described in claim 1, wherein, the image information of the image specified according to user determines the figure As in character contour the step of include:
The image that the user specifies is divided into multiple piecemeals;
According to the corresponding image information of piecemeal each at least one piecemeal of the multiple piecemeal, each piecemeal is determined Piecemeal attribute, wherein the piecemeal attribute is used to indicate piecemeal and belongs to personage region or inhuman object area;
According to the piecemeal attribute of at least one piecemeal, the character contour in described image is determined.
3. method according to claim 1 or 2, wherein personage wheel of this method in the adjustment character contour template It is further comprising the steps of before wide step:
Identified character contour is matched with multiple character contour templates, and selects the highest character contour mould of matching degree Plate, as corresponding character contour template.
4. the method according to claim 1, wherein determine personage region, background area and the personage region in described image The step of transitional region between background area includes:
According to the character contour adjusted, the personage region is determined;
According to the personage region and/or the image information of inhuman object area, the transitional region and background area are determined, In, the inhuman object area includes the transitional region and the background area.
5. according to the method described in claim 4, wherein, the image information of the personage region and/or inhuman object area includes At least one of below:
The size in the personage region;
The size of the inhuman object area;
The colouring information of the colouring information in the personage region and/or the inhuman object area.
6. method according to claim 1 or 2, wherein include: to the step of transitional region progress gradual virtualization
The transitional region is blurred, the transitional region after being blurred;
Transitional region after virtualization is mixed with the transitional region not blurred, the transitional region after obtaining gradual virtualization;
Wherein, closer to the personage region, specific gravity of the transitional region not blurred in the mixing is higher;Closer to The background area, specific gravity of the transitional region in the mixing after the virtualization are higher.
7. method according to claim 1 or 2, wherein by being blurred to the background area, and to the transition Region carries out gradual virtualization, includes: come the step of image after being blurred
Obtain the virtualization extent index that user determines;
According to the virtualization extent index, the background area is blurred, and gradual void is carried out to the transitional region Change, come the image after being blurred.
8. method according to claim 1 or 2, wherein the image that the user specifies, which includes on shooting display interface, is in Existing image, this method determine the personage region, described after the step of adjusting the character contour in character contour template It is further comprising the steps of before the step of background area and the transitional region:
The character contour adjusted is presented on shooting display interface;
Image of the user based on the character contour shooting presented is obtained, and by the image of the shooting, is specified as the user Image.
9. method according to claim 1 or 2, wherein this method is further comprising the steps of:
Image after the virtualization is presented to the user;
According to the operation of user feedback, corresponding operating is executed to the image after the virtualization.
10. a kind of device for being blurred to image, wherein the device includes following device:
Image information for the image specified according to user, determines the device of the character contour in the image;
Personage is adjusted for identified character contour to be compared with corresponding character contour template, and according to comparison result Character contour in contour mould, so that character contour adjusted and the identified character contour in character contour template Matched device;
For according to the character contour adjusted, determine the personage region in image that the user specifies, background area with And the device of the transitional region between personage region and background area;
For carrying out gradual virtualization by blurring to the background area, and to the transitional region, to be blurred The device of image afterwards, wherein the gradual virtualization indicates the part in the transitional region closer to the personage region Virtualization degree it is more shallow, the virtualization degree closer to the part of the background area is deeper;
Wherein, the device for adjusting the character contour in character contour template includes:
For identified character contour to be compared with corresponding character contour template, determine in the character contour template Character contour and the identified character contour between scaling and positional shift information device, wherein the scaling And positional shift information includes the scaling letter between character contour and identified character contour in character contour template Breath, and/or, the positional shift letter between the character contour and identified character contour in character contour template on the image Breath;
For the character contour in character contour template being adjusted, so that character contour according to the scaling and positional shift information Character contour adjusted is matched with the identified character contour in template, so that in using for reference character contour template Shooting posture, and can be based on character contour template come while more correctly identifying background area, the personage that is taken can It freely walks about in entire shooting picture, the dress without position defined by the character contour that is limited in character contour template It sets.
11. device according to claim 10, wherein the image information of the image for being specified according to user, determining should The device of character contour in image includes:
Image for specifying the user is divided into the device of multiple piecemeals;
For the corresponding image information of piecemeal each at least one piecemeal according to the multiple piecemeal, described each point is determined The device of the piecemeal attribute of block, wherein the piecemeal attribute is used to indicate piecemeal and belongs to personage region or inhuman object area;
For the piecemeal attribute according at least one piecemeal, the device of the character contour in described image is determined.
12. device described in 0 or 11 according to claim 1, wherein the device further includes described for adjusting character contour mould The following device of operation is executed before the device of character contour in plate:
For matching identified character contour with multiple character contour templates, and select the highest personage's wheel of matching degree Wide template, the device as corresponding character contour template.
13. device according to claim 10, wherein for determine the personage region in described image, background area with And the device of the transitional region between personage region and background area includes:
For determining the device in the personage region according to the character contour adjusted;
For the image information according to the personage region and/or inhuman object area, the transitional region and background area are determined The device in domain, wherein the inhuman object area includes the transitional region and the background area.
14. device according to claim 13, wherein the image information packet of the personage region and/or inhuman object area It includes at least one of following:
The size in the personage region;
The size of the inhuman object area;
The colouring information of the colouring information in the personage region and/or the inhuman object area.
15. device described in 0 or 11 according to claim 1, wherein carry out the operation packet of gradual virtualization to the transitional region It includes:
The transitional region is blurred, the transitional region after being blurred;
Transitional region after virtualization is mixed with the transitional region not blurred, the transitional region after obtaining gradual virtualization;
Wherein, closer to the personage region, specific gravity of the transitional region not blurred in the mixing is higher;Closer to The background area, specific gravity of the transitional region in the mixing after the virtualization are higher.
16. device described in 0 or 11 according to claim 1, wherein for by being blurred to the background area, and it is right The transitional region carries out gradual virtualization, and the device come the image after being blurred includes:
For obtaining the device for the virtualization extent index that user determines;
For being blurred to the background area according to the virtualization extent index, and the transitional region is carried out progressive Formula virtualization, come the device of the image after being blurred.
17. device described in 0 or 11 according to claim 1, wherein the image that the user specifies includes on shooting display interface The image of presentation, the device further include being used for after the device for being used to adjust the character contour in character contour template The following device of operation is executed before determining the device of the personage region, the background area and the transitional region
For the device of the character contour adjusted to be presented on shooting display interface;
For obtaining image of the user based on the character contour shooting presented, and by the image of the shooting, as the user The device of specified image.
18. device described in 0 or 11 according to claim 1, wherein the device further includes following device:
Device for the image after the virtualization to be presented to the user;
For the operation according to user feedback, the device of corresponding operating is executed to the image after the virtualization.
CN201510106876.9A 2015-03-11 2015-03-11 A kind of method and apparatus for being blurred to image Active CN104751407B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510106876.9A CN104751407B (en) 2015-03-11 2015-03-11 A kind of method and apparatus for being blurred to image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510106876.9A CN104751407B (en) 2015-03-11 2015-03-11 A kind of method and apparatus for being blurred to image

Publications (2)

Publication Number Publication Date
CN104751407A CN104751407A (en) 2015-07-01
CN104751407B true CN104751407B (en) 2019-01-25

Family

ID=53591030

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510106876.9A Active CN104751407B (en) 2015-03-11 2015-03-11 A kind of method and apparatus for being blurred to image

Country Status (1)

Country Link
CN (1) CN104751407B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105005980B (en) * 2015-07-21 2019-02-01 深圳Tcl数字技术有限公司 Image processing method and device
CN108230252B (en) * 2017-01-24 2022-02-01 深圳市商汤科技有限公司 Image processing method and device and electronic equipment
CN107222676B (en) 2017-05-26 2020-06-02 Tcl移动通信科技(宁波)有限公司 Blurred picture generation method, storage device and mobile terminal
CN107948517B (en) * 2017-11-30 2020-05-15 Oppo广东移动通信有限公司 Preview picture blurring processing method, device and equipment
CN109961452A (en) * 2017-12-22 2019-07-02 广东欧珀移动通信有限公司 Processing method, device, storage medium and the electronic equipment of photo
CN108305223B (en) * 2018-01-09 2020-11-03 珠海格力电器股份有限公司 Image background blurring processing method and device
CN108307110A (en) * 2018-01-18 2018-07-20 维沃移动通信有限公司 A kind of image weakening method and mobile terminal
CN113163133A (en) 2018-10-15 2021-07-23 华为技术有限公司 Image processing method, device and equipment
CN112215762A (en) * 2019-07-12 2021-01-12 阿里巴巴集团控股有限公司 Video image processing method and device and electronic equipment
WO2021102702A1 (en) * 2019-11-26 2021-06-03 深圳市大疆创新科技有限公司 Image processing method and apparatus
WO2021102704A1 (en) * 2019-11-26 2021-06-03 深圳市大疆创新科技有限公司 Image processing method and apparatus

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101276409A (en) * 2007-03-27 2008-10-01 三洋电机株式会社 Image processing apparatus
CN101339612A (en) * 2008-08-19 2009-01-07 陈建峰 Face contour checking and classification method
CN102170552A (en) * 2010-02-25 2011-08-31 株式会社理光 Video conference system and processing method used therein
CN103297697A (en) * 2013-05-30 2013-09-11 北京小米科技有限责任公司 Method and device for displaying template pictures during photographing
CN103778436A (en) * 2014-01-20 2014-05-07 电子科技大学 Pedestrian gesture inspecting method based on image processing

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IES20060564A2 (en) * 2006-05-03 2006-11-01 Fotonation Vision Ltd Improved foreground / background separation
JP2009027298A (en) * 2007-07-18 2009-02-05 Ricoh Co Ltd Imaging apparatus and control method thereof
CN102932541A (en) * 2012-10-25 2013-02-13 广东欧珀移动通信有限公司 Mobile phone photographing method and system
CN103973977B (en) * 2014-04-15 2018-04-27 联想(北京)有限公司 Virtualization processing method, device and the electronic equipment of a kind of preview interface
CN104318603A (en) * 2014-09-12 2015-01-28 上海明穆电子科技有限公司 Method and system for generating 3D model by calling picture from mobile phone photo album

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101276409A (en) * 2007-03-27 2008-10-01 三洋电机株式会社 Image processing apparatus
CN101339612A (en) * 2008-08-19 2009-01-07 陈建峰 Face contour checking and classification method
CN102170552A (en) * 2010-02-25 2011-08-31 株式会社理光 Video conference system and processing method used therein
CN103297697A (en) * 2013-05-30 2013-09-11 北京小米科技有限责任公司 Method and device for displaying template pictures during photographing
CN103778436A (en) * 2014-01-20 2014-05-07 电子科技大学 Pedestrian gesture inspecting method based on image processing

Also Published As

Publication number Publication date
CN104751407A (en) 2015-07-01

Similar Documents

Publication Publication Date Title
CN104751407B (en) A kind of method and apparatus for being blurred to image
CN104751405B (en) A kind of method and apparatus for being blurred to image
CN104751406B (en) A kind of method and apparatus for being blurred to image
CN104834898B (en) A kind of quality classification method of personage's photographs
Bhattacharya et al. A framework for photo-quality assessment and enhancement based on visual aesthetics
CN106030661B (en) The independent 3D scene texture background in the visual field
US8265351B2 (en) Method, system and computer program product for automatic and semi-automatic modification of digital images of faces
CN108288027A (en) A kind of detection method of picture quality, device and equipment
WO2016011834A1 (en) Image processing method and system
Raman et al. Reconstruction of high contrast images for dynamic scenes
US20150243031A1 (en) Method and device for determining at least one object feature of an object comprised in an image
US20110292051A1 (en) Automatic Avatar Creation
CN108305312A (en) The generation method and device of 3D virtual images
CN104182970B (en) Souvenir photo portrait position recommendation method based on photography composition rule
CN110378943A (en) Image processing method, device, electronic equipment and storage medium
CN109325988A (en) A kind of facial expression synthetic method, device and electronic equipment
CN107852533A (en) Three-dimensional content generating means and its three-dimensional content generation method
CN101098241A (en) Method and system for implementing virtual image
US9727802B2 (en) Automatic, computer-based detection of triangular compositions in digital photographic images
US9025906B2 (en) Generating an assembled group image from subject images
US9892542B2 (en) Creating bump and normal maps from images with multi-scale control
CN109360179A (en) A kind of image interfusion method, device and readable storage medium storing program for executing
Wang et al. Where2stand: A human position recommendation system for souvenir photography
CN110519509A (en) Composition evaluation method, method for imaging, device, electronic equipment, storage medium
US20200019764A1 (en) Portrait Image Evaluation Based on Aesthetics

Legal Events

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