WO2021077836A1 - 抠图方法及装置 - Google Patents

抠图方法及装置 Download PDF

Info

Publication number
WO2021077836A1
WO2021077836A1 PCT/CN2020/105441 CN2020105441W WO2021077836A1 WO 2021077836 A1 WO2021077836 A1 WO 2021077836A1 CN 2020105441 W CN2020105441 W CN 2020105441W WO 2021077836 A1 WO2021077836 A1 WO 2021077836A1
Authority
WO
WIPO (PCT)
Prior art keywords
point
image
image area
pixel
edge
Prior art date
Application number
PCT/CN2020/105441
Other languages
English (en)
French (fr)
Inventor
诸葛晶晶
倪光耀
杨辉
Original Assignee
北京字节跳动网络技术有限公司
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 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Priority to US17/770,983 priority Critical patent/US20220375098A1/en
Publication of WO2021077836A1 publication Critical patent/WO2021077836A1/zh

Links

Images

Classifications

    • G06T3/04
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/18Eye characteristics, e.g. of the iris
    • G06V40/193Preprocessing; Feature extraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/181Segmentation; Edge detection involving edge growing; involving edge linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/771Feature selection, e.g. selecting representative features from a multi-dimensional feature space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20092Interactive image processing based on input by user
    • G06T2207/20101Interactive definition of point of interest, landmark or seed
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20164Salient point detection; Corner detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20168Radial search
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V2201/00Indexing scheme relating to image or video recognition or understanding
    • G06V2201/07Target detection

Definitions

  • the present disclosure relates to the field of information processing technology, and in particular, to a matting method, device, and computer-readable storage medium.
  • Cutout is one of the most common operations in image processing. It separates a certain part of a picture or video from the original picture or video into a separate layer. Mainly to prepare for the later synthesis.
  • a matting template with a fixed shape and transparency is usually used for matting.
  • a cutout template based on a standard face in advance.
  • the parts of the human eye in the cutout template are transparent, and the remaining parts are masked colors (for example, black).
  • the face area is first detected from the image, and then the matting template is superimposed on the image of the face area to obtain the eye area.
  • the image and the matting template are often not completely matched.
  • the cutting out template is usually designed based on the standard human face, but the human face in the image is often not exactly the same as the standard human face.
  • the image cut out using the matting template may only include part of the human eye, and the complete human eye image cannot be cut out.
  • the image area cut out using the matting template is too large relative to the human eye, that is, the cut out image contains the image of the non-human eye part.
  • the angle of the face in the image is different from the standard face
  • the standard face is a front face and the face in the image is a side face
  • the position of the eyes in the face in the image is the same as that in the standard face.
  • the positions of the eyes are different, which results in the image cut out using the cutout template does not include the human eye at all. It can be seen that it is often difficult to accurately cut out the required area from the image using the used matting template.
  • the technical problem solved by the present disclosure is to provide a matting method to at least partially solve the technical problem of using a matting template in the prior art that it is difficult to accurately cut out a required area from an image.
  • a matting device, a matting hardware device, a computer-readable storage medium, and a matting terminal are also provided.
  • a matting method including:
  • a matting device including:
  • the feature point detection module is used to perform feature point detection on the image to obtain multiple feature points
  • a marked area acquisition module configured to acquire the first image area manually marked on the image
  • An area determination module configured to adjust the first image area according to the feature points to obtain a second image area
  • the matting module is used for matting the image according to the second image area.
  • An electronic device including:
  • Memory for storing non-transitory computer readable instructions
  • the processor is configured to run the computer-readable instructions so that the processor implements any of the above-mentioned matting methods when executed.
  • a computer-readable storage medium for storing non-transitory computer-readable instructions.
  • the computer is caused to execute any one of the above-mentioned matting methods.
  • a picture-cutting terminal includes any of the above-mentioned picture-cutting devices.
  • the part to be cut out in the image can be marked in the first image area by manual annotation, and then the first image area can be adjusted according to the feature points, so that the second image area can be more updated. Accurately locate the part to be cut out in the image, and then cut out according to the second image area, so that the required area can be cut out accurately. In this way, since the cutout template is replaced by manual labeling, even if the image does not match the cutout template, the required image part can be accurately cut out.
  • Fig. 1a is a schematic flowchart of a matting method according to an embodiment of the present disclosure
  • Fig. 1b is a schematic diagram of facial feature points in a matting method according to an embodiment of the present disclosure
  • Fig. 1c is a schematic diagram of manual marking points in a matting method according to an embodiment of the present disclosure
  • FIG. 1d is a schematic diagram of a second image area and external expansion points in a matting method according to an embodiment of the present disclosure
  • FIG. 1e is a schematic diagram of the vertices in the matting method according to an embodiment of the present disclosure as convex points;
  • FIG. 1f is a schematic diagram in which the vertices in the matting method according to an embodiment of the present disclosure are concave points;
  • FIG. 1g is a schematic diagram of an expanded point whose vertices are convex points in a matting method according to an embodiment of the present disclosure
  • FIG. 1h is a schematic diagram of an expanded point whose apex is a concave point in a matting method according to an embodiment of the present disclosure
  • Fig. 1i is a schematic diagram of a cut-out image area in a cut-out method according to an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of the structure of an image matting device according to an embodiment of the present disclosure
  • Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
  • an embodiment of the present disclosure provides a matting method. As shown in Fig. 1a, the matting method mainly includes the following steps S11 to S14.
  • Step S11 Perform feature point detection on the image to obtain multiple feature points.
  • the image can be a human face image, an animal image, and so on.
  • the feature point is the point where the gray value of the image changes drastically or the point with larger curvature on the edge of the image (that is, the intersection of two edges), which has distinct characteristics, can effectively reflect the essential characteristics of the image, and can identify The target object in the image.
  • the image is a face image
  • the feature points on the face image can be detected to obtain the feature points on the face.
  • the white points in Figure 1b are the feature points on the face. , Including the eyes and surrounding pixels, the nose and surrounding pixels, etc.
  • a feature point detection algorithm can be used to obtain feature points in the image.
  • the image is a human face image
  • the template face can also be used to detect the feature points of the image.
  • Step S12 Obtain a first image area manually marked on the image.
  • the user determines the first image area by marking dots or dashes around the image area to be cut out.
  • the first image area is an artificially determined initial image area, and is usually a rough range including the cut-out image area.
  • the user wants to cut out the eye area, he can mark points around the eye area of the image or determine the approximate range of the cut out eye area by drawing a circle.
  • the black dots shown in Figure 1c are manually labeled annotation points, and the white dots are feature points.
  • Step S13 Adjust the first image area according to the feature points to obtain a second image area.
  • the feature points are the feature points located inside, at the edge and around the first image area. Since these feature points can characterize image features to the maximum, these feature points are used to adjust them so that the determined range of the second image area is closer to the image area to be cut out, that is, the cut out image area is more accurate.
  • Step S14 Cut out the image according to the second image area.
  • the second image area can be directly used as a cut-out area to cut out; or further adjustments can be made on the basis of the second image area to re-determine the image area before cutting out.
  • the fourth option see the fourth option below. Description of the embodiment.
  • the first image area is manually labeled and the first image area is adjusted according to the feature points. Since the feature points can represent image features to the maximum, the feature points are used to adjust them , So that the determined range of the second image area is closer to the image area to be cut out, thereby making the cut out image area more accurate.
  • the feature points and the labeled first image area are determined according to the image, for different images, the detected feature points and the labeled first image area can be the same as the part of the image itself that needs to be cut out. Therefore, the present embodiment can accurately cut out the target area for different images, so that it can be applied to the cutout of various images.
  • step S12 specifically includes:
  • Step S121 Obtain manually annotated points on the image.
  • users can customize marking points according to their own needs. For example, if the user wants to cut out the eye area, the eye area of the image, that is, around the eyes can be marked with annotation points.
  • the black dots as shown in FIG. 1c are manually labeled annotation points, and the manually labeled annotation points are obtained from the image.
  • Step S122 Determine the label point as an edge point of the first image area.
  • an image area enclosed by an annotation point is used as the first image area, that is, the annotation point becomes an edge point of the first image area.
  • step S13 specifically includes:
  • Step S131 Adjust the position of the marking point according to the characteristic point, and determine the first target point corresponding to the marking point.
  • the marked points are manually marked, the image area determined by them cannot be accurately matched to the image area that needs to be cut out. Therefore, it needs to be adjusted according to the characteristic points. Since the feature point can represent the image feature to the maximum, the feature point is used to adjust it to obtain the first target point. The range of the second image area determined by the first target point is made closer to the image area to be cut out, that is, the cut out image area is made more accurate.
  • Step S132 Determine a closed area enclosed by the first target point as the second image area.
  • step S131 specifically includes:
  • Step S1311 Select the initial point closest to the marked point from the feature points.
  • the distance between each feature point and the labeled point is calculated, for example, it can be cosine distance, Euclidean distance, etc.; the feature point with the closest distance to the labeled point is selected as the distance from the labeled point. The closest feature point to the point.
  • Step S1312 Determine the closed area enclosed by the initial point as the third image area.
  • the closed area formed by them is a polygon, and the closed area formed by the polygon is the third image area.
  • the closed area enclosed by the three initial points is a triangle
  • the area enclosed by the triangle is the third image area.
  • Step S1313 Determine the center position of the third image area as the first target point corresponding to the marked point.
  • the center position of the polygon is determined as the first target point corresponding to the labeled point.
  • the center position can be the geometric center or the geometric center of gravity of the polygon.
  • the polygon is a regular geometric figure, such as a regular triangle, a regular quadrilateral, or a regular pentagon
  • the corresponding center position is the geometric center or the intersection of the diagonals.
  • the corresponding center position is the geometric center of gravity, which is the intersection of the center lines of the sides of the polygon.
  • the above scenario is a corresponding method for determining the first target point when the selected closest initial points are at least three.
  • a feature point closest to the labeled point may be selected from the feature points as the first target point.
  • two feature points closest to the marked point are selected from the feature points, and the midpoint of the line of the two feature points is used as the first target point.
  • step S14 specifically includes:
  • Step S141 Determine the edge of the second image area as the initial edge.
  • the image edge is the intersection of the image attribute area and another attribute area, and is the place where the area attribute changes suddenly.
  • the existing image edge extraction method can be used to determine the edge of the second image region.
  • the image edge extraction methods that can be used are as follows: differential operator method, Laplacian Gaussian operator method, Canny operator, and fitting method , Relaxation method, neural network analysis method, wavelet transform method, etc.
  • Step S142 Expand the initial edge to a direction outside the second image area to obtain a target edge.
  • the target edge is the edge of the expanded image area.
  • Step S143 Cut out the fourth image area enclosed by the target edge to obtain a cut out image.
  • the fourth image area may be directly cut out as the target image, and the pixel values of the pixels in the cut out image are the pixel values in the image, that is, the pixel values remain unchanged.
  • edge transparency transition processing can be performed on the image region enclosed by the initial edge and the target edge.
  • step S142 specifically includes:
  • Step S1421 Obtain the pixel points on the initial edge as the initial edge point.
  • any pixel point on the initial edge can be selected as the initial edge point.
  • the arbitrary pixel point can be a characteristic point or a non-characteristic point.
  • Step S1422 Determine an extension point corresponding to the initial edge point according to the reference points on both sides of the initial edge point, where the extension point is located outside the second image area.
  • the reference point may be pixel points or feature points on both sides of the initial edge point.
  • An initial edge point can correspond to one external expansion point, or it can correspond to multiple external expansion points. As shown in Figure 1d, the white point outside the enclosed area is the expanded point.
  • Step S1423 Connect the external expansion points to form the target edge.
  • step S1422 specifically includes:
  • Step A Determine the type of the initial edge point according to the reference points on both sides of the initial edge point.
  • the initial edge point and the reference points on both sides are connected to obtain two line segments, as shown in Figures 1e and 1f, the two line segments form a certain included angle, and the initial edge point is determined according to the included angle.
  • Types of For example, if the included angle is an obtuse angle, the type of the initial edge point is determined to be a convex point, and if the included angle is an acute angle, the type of the initial edge point is determined to be a concave point.
  • Step B Determine the extension point corresponding to the initial edge point according to the type.
  • step B specifically includes:
  • the outer end point of the normal is obtained by extending the predetermined length outward according to the normal direction of the line segment formed by the initial edge point and the reference point, and the outer end point of the normal is obtained according to the angle between the normal Interpolate smoothly between the outer end points to obtain the corresponding outer expansion point;
  • the type is a concave point, it is obtained by extending the predetermined length outward according to the bisector of the angle formed by the initial edge point and the reference point
  • the outer end point of the angle bisector is taken as the corresponding outer expansion point.
  • the preset length can be customized.
  • two outer endpoints can be determined according to the normal direction of the two line segments. When the two outer endpoints are far apart, the resulting image area is not smooth enough.
  • a series of outer expansion points are obtained by interpolation and smoothing between two outer end points, which are used as the outer expansion points of the initial edge point.
  • the outer end point is determined according to the bisector of the angle between the two line segments. At this time, there is only one outer end point, so the outer end point is directly used as the initial edge point The expansion point.
  • step S143 specifically includes:
  • Step S1431 Determine the product of the preset first weight and the pixel value of the pixel on the initial edge in the image as the pixel value of the pixel on the initial edge line in the matted image.
  • the preset first weight can be customized by the user, for example, it can be set to 1.
  • Step S1432 Determine the product of the preset second weight and the pixel value of the pixel on the target edge in the image as the pixel value of the pixel on the target edge in the matting image.
  • the preset second weight can be customized by the user, for example, it can be set to 0. And when setting the preset first weight and the preset second weight, in order to make the image area composed of the initial edge and the target edge achieve the effect that the transparency gradually decreases with the degree of expansion, the preset first weight is greater than the preset weight. Set the second weight.
  • Step S1433 Determine the pixel value of each pixel in the fifth image area according to the initial edge and the target edge; wherein, the fifth image area is the image area between the initial edge and the target edge .
  • step S1433 includes:
  • Step C Select a first pixel on the initial edge and a second pixel on the target edge to form a polygon.
  • the first pixel point may be any pixel point, any feature point or any initial edge point on the initial edge.
  • the second pixel point may be any pixel point, any feature point or any extension point on the target edge.
  • first pixel and the second pixel may form a polygon, and the polygon may be a triangle, a quadrilateral, a pentagon, or the like.
  • Step D Determine the third weight of the third pixel according to the coordinates of the vertices of the polygon and the coordinates of the third pixel located in the polygon.
  • the weights of the pixels in the polygon can also be set to a preset first weight and a preset first weight.
  • a value between two weights such as a value between 0 and 1.
  • Step E Determine the product of the third weight and the pixel value of the third pixel in the image as the pixel value of the third pixel in the matting image.
  • step D specifically includes:
  • Step D1 Determine the weight coefficient of each vertex according to the coordinates of the vertices of the polygon and the coordinates of the third pixel point.
  • Step D2 Use the weighted sum of the weight coefficients of all vertices and the set weight parameters as the third weight.
  • the set weight parameter can be determined according to the edge where the vertex is located. Specifically, if the vertex is the first pixel on the initial edge, its corresponding weight parameter is the preset first weight; if the vertex is the extension point on the target edge, its corresponding weight parameter is the preset The second weight.
  • the three vertices of the triangle are composed of the first pixel point on the initial edge and the expanded point on the target edge. For example, it is composed of 2 first pixel points on the initial edge and 1 extension point on the target edge, or composed of 1 first pixel point on the initial edge and 2 extension points on the target edge. Therefore, the coordinates of the three vertices P1, P2 and P3 of the triangle are known, u and v are used as the weighting coefficients of P2 and P3, and (1-uv) is used as the weighting coefficient of P1. For any point P in the triangle, (u,v) must meet the conditions u ⁇ 0, v ⁇ 0, u+v ⁇ 1. Now that the coordinates of P1, P2, P3 and P are known, the values of u and v can be obtained by solving the following equations:
  • Px is P abscissa
  • Py is P ordinate
  • P1.x is P1 abscissa
  • P1.y is P ordinate
  • P2.x is P2 abscissa
  • P2.y is P2 ordinate
  • P3.x is P3 abscissa
  • P3.y is P3 ordinate.
  • the device embodiments of the present disclosure can be used to perform the steps implemented by the method embodiments of the present disclosure.
  • an embodiment of the present disclosure provides a matting device.
  • the device can execute the steps in the embodiment of the matting method described in the first embodiment.
  • the device mainly includes: a feature point detection module 21, a marked area acquisition module 22, an area determination module 23, and a matting module 24; among them,
  • the feature point detection module 21 is used to perform feature point detection on the image to obtain multiple feature points;
  • the marked area acquisition module 22 is configured to acquire the first image area manually marked on the image
  • the area determining module 23 is configured to adjust the first image area according to the feature points to obtain a second image area
  • the matting module 24 is used for matting the image according to the second image area.
  • the labeling area acquiring module 22 includes: a labeling point acquiring unit 221 and a labeling area determining unit 222; wherein,
  • the annotation point acquiring unit 221 is configured to acquire manually annotated annotation points on the image
  • the marking area determining unit 222 is configured to determine the marking point as an edge point of the first image area.
  • the labeling area determining unit 222 is specifically configured to: adjust the position of the labeling point according to the feature point, and determine the first target point corresponding to the labeling point; and enclose the first target point The closed area of is determined as the second image area.
  • the labeling area determining unit 222 is specifically configured to: select an initial point closest to the labeling point from the feature points; determine the closed area enclosed by the initial point as the third image area; The center position of the third image area is determined as the first target point corresponding to the marked point.
  • the matting module 24 includes: an initial edge determining unit 241, a target edge determining unit 242, and a matting unit 243; wherein,
  • the initial edge determining unit 241 is configured to determine the edge of the second image area as the initial edge
  • the target edge determination unit 242 is configured to expand the initial edge to a direction outside the second image area to obtain a target edge
  • the matting unit 243 is configured to cut out the fourth image area enclosed by the target edge to obtain the matted image.
  • the target edge determination unit 242 is specifically configured to: acquire pixel points on the initial edge as initial edge points; and determine the extension corresponding to the initial edge point according to the reference points on both sides of the initial edge point. Point, the extended point is located outside the second image area; connecting the extended points to form the target edge.
  • target edge determining unit 242 is specifically configured to: determine the type of the initial edge point according to the reference points on both sides of the initial edge point; and determine the extension point corresponding to the initial edge point according to the type.
  • the target edge determination unit 242 is specifically configured to: if the type is a convex point, then extend a predetermined length outward according to the normal direction of the line segment formed by the initial edge point and the reference point to obtain the The outer end point of the normal line, and interpolate smoothly between the outer end points according to the included angle of the normal line to obtain the corresponding outer expansion point; if the type is a concave point, it is formed according to the initial edge point and the reference point The angle bisector of the included angle extends outward by a preset length to obtain the outer end point of the angle bisector, and the outer end point of the angle bisector is used as the corresponding outer expansion point.
  • the matting unit 243 is specifically configured to: determine the product of the preset first weight and the pixel value of the pixel on the initial edge in the image as the pixel on the initial edge line.
  • the pixel value in the matted image; the product of the preset second weight and the pixel value of the pixel on the target edge in the image is determined as the pixel of the pixel on the target edge in the matted image Value; the pixel value of each pixel in the fifth image area is determined according to the initial edge and the target edge; wherein, the fifth image area is the image area between the initial edge and the target edge.
  • the matting unit 243 is specifically configured to: select a first pixel point located on the initial edge and a second pixel point located on the target edge to form a polygon; The coordinates of the third pixel in the polygon determine the third weight of the third pixel; the product of the third weight and the pixel value of the third pixel in the image is determined as the The pixel value of the third pixel in the matting image.
  • the matting unit 243 is specifically configured to: determine the weight coefficient of each vertex according to the coordinates of the vertices of the polygon and the coordinates of the third pixel; combine the weight coefficients of all vertices with the set weight parameters The weighted sum of is used as the third weight.
  • Terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc.
  • the electronic device shown in FIG. 3 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
  • the electronic device 300 may include a processing device (such as a central processing unit, a graphics processor, etc.) 301, which can be loaded into a random access device according to a program stored in a read-only memory (ROM) 302 or from a storage device 306.
  • the program in the memory (RAM) 303 executes various appropriate actions and processing.
  • various programs and data required for the operation of the electronic device 300 are also stored.
  • the processing device 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304.
  • An input/output (I/O) interface 305 is also connected to the bus 304.
  • the following devices can be connected to the I/O interface 305: including input devices 306 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; including, for example, liquid crystal displays (LCD), speakers, vibrations
  • input devices 306 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.
  • LCD liquid crystal displays
  • An output device 307 such as a device
  • a storage device 306 such as a magnetic tape and a hard disk
  • the communication device 309 may allow the electronic device 300 to perform wireless or wired communication with other devices to exchange data.
  • Fig. 3 shows an electronic device 300 with various devices, it should be understood that it is not required to implement or have all of the illustrated devices. It may alternatively be implemented or provided with more or fewer devices.
  • the process described above with reference to the flowchart can be implemented as a computer software program.
  • the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, and the computer program contains program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 309, or installed from the storage device 306, or installed from the ROM 302.
  • the processing device 301 the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
  • the aforementioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable removable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
  • the client and server can communicate with any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium.
  • Communication e.g., communication network
  • Examples of communication networks include local area networks (“LAN”), wide area networks (“WAN”), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future research and development network of.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
  • the aforementioned computer-readable medium carries one or more programs, and when the aforementioned one or more programs are executed by the electronic device, the electronic device is caused to perform feature point detection on the image to obtain feature points;
  • the computer program code used to perform the operations of the present disclosure may be written in one or more programming languages or a combination thereof.
  • the above-mentioned programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and Including conventional procedural programming languages-such as "C" language or similar programming languages.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
  • LAN local area network
  • WAN wide area network
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions.
  • the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, or they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the units involved in the embodiments described in the present disclosure can be implemented in software or hardware. Wherein, the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
  • the first obtaining unit can also be described as "a unit for obtaining at least two Internet Protocol addresses.”
  • exemplary types of hardware logic components include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logical device (CPLD) and so on.
  • FPGA Field Programmable Gate Array
  • ASIC Application Specific Integrated Circuit
  • ASSP Application Specific Standard Product
  • SOC System on Chip
  • CPLD Complex Programmable Logical device
  • a machine-readable medium may be a tangible medium, which may contain or store a program for use by the instruction execution system, apparatus, or device or in combination with the instruction execution system, apparatus, or device.
  • the machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • the machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing.
  • machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • RAM random access memory
  • ROM read-only memory
  • EPROM or flash memory erasable programmable read-only memory
  • CD-ROM compact disk read only memory
  • magnetic storage device or any suitable combination of the foregoing.
  • a matting method including:
  • the acquiring the first image area manually marked on the image includes:
  • the label point is determined as an edge point of the first image area.
  • the adjusting the first image area according to the characteristic points to obtain a second image area includes:
  • the closed area enclosed by the first target point is determined as the second image area.
  • the adjusting the position of the marking point according to the characteristic point and determining the first target point corresponding to the marking point includes:
  • the center position of the third image area is determined as the first target point corresponding to the marked point.
  • the matting the image according to the second image area includes:
  • the externally expanding the initial edge to a direction outside the second image area to obtain a target edge includes:
  • the determining the extension point corresponding to the initial edge point according to the reference points on both sides of the initial edge point includes:
  • the outward expansion point corresponding to the initial edge point is determined according to the type.
  • the determining the extension point corresponding to the initial edge point according to the type includes:
  • the outer end point of the normal line is obtained by extending the predetermined length outward according to the normal direction of the line segment formed by the initial edge point and the reference point, and the outer end point of the normal line is obtained according to the angle between the normal line. Perform interpolation and smoothing between the outer endpoints to obtain the corresponding outer expansion point;
  • the outer end point of the angle bisector is obtained by extending the predetermined length of the angle bisector of the angle formed by the initial edge point and the reference point, and the angle bisector is The outer end point of is used as the corresponding outer expansion point.
  • the cutting out the fourth image area enclosed by the target edge to obtain the cut out image includes:
  • the pixel value of each pixel in the fifth image area is determined according to the initial edge and the target edge; wherein the fifth image area is an image area between the initial edge and the target edge.
  • the determining the pixel value of each pixel in the fifth image area according to the initial edge and the target edge includes:
  • the product of the third weight and the pixel value of the third pixel in the image is determined as the pixel value of the third pixel in the matting image.
  • the determining the third weight of the third pixel based on the coordinates of the vertices of the polygon and the coordinates of the third pixel located in the polygon includes:
  • the weighted sum of the weight coefficients of all vertices and the set weight parameters is used as the third weight.
  • a matting device including:
  • the feature point detection module is used to perform feature point detection on the image to obtain multiple feature points
  • a marked area acquisition module configured to acquire the first image area manually marked on the image
  • An area determination module configured to adjust the first image area according to the feature points to obtain a second image area
  • the matting module is used for matting the image according to the second image area.
  • the marking area acquisition module includes:
  • An annotation point acquiring unit configured to acquire an annotation point manually annotated on the image
  • the marking area determining unit is configured to determine the marking point as an edge point of the first image area.
  • the labeling area determining unit is specifically configured to: adjust the position of the labeling point according to the feature point to determine the first target point corresponding to the labeling point; and to enclose the first target point The closed area is determined as the second image area.
  • the labeling area determining unit is specifically configured to: select an initial point closest to the labeling point from the feature points; determine the closed area enclosed by the initial point as the third image area; The center position of the third image area is determined as the first target point corresponding to the marked point.
  • the image matting module includes:
  • An initial edge determining unit configured to determine an edge of the second image area as an initial edge
  • a target edge determination unit configured to expand the initial edge to a direction outside the second image area to obtain a target edge
  • the matting unit is used to cut out the fourth image area enclosed by the target edge to obtain the matted image.
  • the target edge determining unit is specifically configured to: acquire pixel points on the initial edge as initial edge points; and determine the extension point corresponding to the initial edge point according to the reference points on both sides of the initial edge point , The expansion point is located outside the second image area; connecting the expansion points to form the target edge.
  • the target edge determining unit is specifically configured to: determine the type of the initial edge point according to the reference points on both sides of the initial edge point; and determine the extension point corresponding to the initial edge point according to the type.
  • the target edge determination unit is specifically configured to: if the type is a convex point, obtain the method according to the normal direction of the line segment formed by the initial edge point and the reference point and extend a predetermined length outward. The outer end point of the line, and interpolate smoothly between the outer end points according to the included angle of the normal line to obtain the corresponding outer expansion point; if the type is a concave point, it is formed according to the initial edge point and the reference point The angle bisector of the included angle extends outward by a preset length to obtain the outer end point of the angle bisector, and the outer end point of the angle bisector is used as the corresponding outer expansion point.
  • the matting unit is specifically configured to: determine the product of the preset first weight and the pixel value of the pixel on the initial edge in the image as the pixel on the initial edge line on the matting The pixel value in the image; the product of the preset second weight and the pixel value of the pixel on the target edge in the image is determined as the pixel value of the pixel on the target edge in the matting image Determine the pixel value of each pixel in the fifth image area according to the initial edge and the target edge; wherein, the fifth image area is the image area between the initial edge and the target edge.
  • the matting unit is specifically configured to: select a first pixel point located on the initial edge and a second pixel point located on the target edge to form a polygon; The coordinates of the third pixel in the polygon determine the third weight of the third pixel; the product of the third weight and the pixel value of the third pixel in the image is determined as the first The pixel values of three pixels in the matting image.
  • the matting unit is specifically configured to: determine the weight coefficient of each vertex according to the coordinates of the vertices of the polygon and the coordinates of the third pixel; combine the weight coefficients of all vertices with the set weight parameters The weighted sum serves as the third weight.

Abstract

一种抠图方法、装置、电子设备和计算机可读存储介质。其中方法包括:对图像进行特征点检测,得到特征点;获取所述图像上人工标注的第一图像区域;根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;根据所述第二图像区域对所述图像进行抠图。通过人工标注的第一图像区域,根据所述特征点对所述第一图像区域进行调整,使得第二图像区域定位更为精确,进而根据第二图像区域进行抠图,能够精确的抠出所需要的区域。

Description

抠图方法及装置
相关申请的交叉引用
本申请要求于2019年10月24日提交的,申请号为201911014880.7、发明名称为“抠图方法及装置”的中国专利申请的优先权,该申请的全文通过引用结合在本申请中。
技术领域
本公开涉及信息处理技术领域,特别是涉及一种抠图方法、装置和计算机可读存储介质。
背景技术
抠图是图像处理中最常做的操作之一,是把图片或影像的某一部分从原始图片或影像中分离出来成为单独的图层。主要是为了后期的合成做准备。
在现有技术中,通常采用固定形状的带透明度的抠图模版进行抠图。以抠出人眼为例,需要预先根据标准人脸设计出抠图模版,该抠图模版中的人眼部位为透明状,其余部位为掩盖色(例如黑色)。在抠图时,首先从图像中检测出人脸区域,然后将抠图模版叠加在人脸区域的图像上,从而得到人眼区域。
但在实际情况中,图像与抠图模板往往是不完全匹配的。以抠出人眼为例,抠图模板通常是根据标准人脸设计的,但图像中的人脸往往与标准人脸不完全一致。例如,当图像中包含的人脸相对于标准人脸偏大时,使用抠图模板抠出的图像可能只包括部分人眼,而不能抠出完整的人眼图像。又如,当图像中包含的人脸相对于标准人脸偏小时,使用抠图模板抠出的图像区域相对于人眼过大,即抠出的图像包含了非人眼部分的图像。又如,当图像中人脸的角度与标准人脸不同时,如标准人脸为正脸而图像中的人脸为侧脸,则图像中人脸中的人 眼位置与标准人脸中人眼的位置是不同的,这导致使用抠图模板抠出的图像根本不包括人眼部分。可见,使用采用的抠图模板往往很难从图像中精确的抠出所需要的区域。
发明内容
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。
本公开解决的技术问题是提供一种抠图方法,以至少部分地解决现有技术中使用抠图模板很难从图像中精确的抠出所需要的区域的技术问题。此外,还提供一种抠图装置、抠图硬件装置、计算机可读存储介质和抠图终端。
为了实现上述目的,根据本公开的一个方面,提供以下技术方案:
一种抠图方法,包括:
对图像进行特征点检测,得到特征点;
获取所述图像上人工标注的第一图像区域;
根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
根据所述第二图像区域对所述图像进行抠图。
为了实现上述目的,根据本公开的一个方面,提供以下技术方案:
一种抠图装置,包括:
特征点检测模块,用于对图像进行特征点检测,得到多个特征点;
标注区域获取模块,用于获取所述图像上人工标注的第一图像区域;
区域确定模块,用于根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
抠图模块,用于根据所述第二图像区域对所述图像进行抠图。
为了实现上述目的,根据本公开的一个方面,提供以下技术方案:
一种电子设备,包括:
存储器,用于存储非暂时性计算机可读指令;以及
处理器,用于运行所述计算机可读指令,使得所述处理器执行时实现上述任一项所述的抠图方法。
为了实现上述目的,根据本公开的一个方面,提供以下技术方案:
一种计算机可读存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时,使得所述计算机执行上述任一项所述的抠图方法。
为了实现上述目的,根据本公开的又一个方面,还提供以下技术方案:
一种抠图终端,包括上述任一抠图装置。
本公开实施例可以通过人工标注的方式使得图像中所要抠出的部分被标注在第一图像区域中,然后根据所述特征点对所述第一图像区域进行调整,使得第二图像区域能够更精确地定位出图像中所要抠出的部分,进而根据第二图像区域进行抠图,就能够精确的抠出所需要的区域。这样,由于使用人工标注的方式替代了抠图模板,即使图像与抠图模板不匹配,也能够精确地抠出所需要的图像部分。
上述说明仅是本公开技术方案的概述,为了能更清楚了解本公开的技术手段,而可依照说明书的内容予以实施,并且为让本公开的上述和其他目的、特征和优点能够更明显易懂,以下特举较佳实施例,并配合附图,详细说明如下。
附图说明
结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、
优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或
相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。
图1a为根据本公开一个实施例的抠图方法的流程示意图;
图1b为根据本公开一个实施例的抠图方法中的人脸特征点示意 图;
图1c为根据本公开一个实施例的抠图方法中的人工标注点示意图;
图1d为根据本公开一个实施例的抠图方法中的第二图像区域和外扩点示意图;
图1e为根据本公开一个实施例的抠图方法中的顶点为凸点的示意图;
图1f为根据本公开一个实施例的抠图方法中的顶点为凹点的示意图;
图1g为根据本公开一个实施例的抠图方法中的顶点为凸点的外扩点的示意图;
图1h为根据本公开一个实施例的抠图方法中的顶点为凹点的外扩点的示意图;
图1i为根据本公开一个实施例的抠图方法中的抠出的图像区域示意图;
图2为根据本公开一个实施例的抠图装置的结构示意图;
图3为根据本公开一个实施例的电子设备的结构示意图。
具体实施方式
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。
应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表 示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。
实施例一
为了解决现有技术中使用抠图模板很难从图像中精确的抠出所需要的区域的技术问题,本公开实施例提供一种抠图方法。如图1a所示,该抠图方法主要包括如下步骤S11至步骤S14。
步骤S11:对图像进行特征点检测,得到多个特征点。
其中,图像可以为人脸图像、动物图像等。
其中,特征点为所述图像灰度值发生剧烈变化的点或者在图像边缘上曲率较大的点(即两个边缘的交点),其具有鲜明特性、能够有效反映图像本质特征、并能够标识图像中目标对象。例如,如图1b所示,如果所述图像为人脸图像,对人脸图像进行特征点检测,即可得到人脸上的特征点,其中,图1b中白色的点即为人脸上的特征点,包括眼睛及周围的像素点、鼻子及周围的像素点等。
具体的,可以采用特征点检测算法得到图像中的特征点。当图像为人脸图像时,还可以采用模板脸检测出图像的特征点。
步骤S12:获取所述图像上人工标注的第一图像区域。
具体的,用户可以根据自己的需求,自定义标注图像区域。具体的,由用户在即将抠出的图像区域的周围标注点或划线的方式确定第一图像区域。该第一图像区域为人工确定的初始图像区域,通常是一个包含抠出图像区域的大致范围。
例如,如果用户想要抠出眼睛区域,则可以在图像的眼睛区域即眼睛四周标注点或通过划圆圈的方式确定抠出眼睛区域的大致范围。如图1c所示的黑点为人工标注的标注点,白点为特征点。
步骤S13:根据所述特征点对所述第一图像区域进行调整,得到第二图像区域。
由于第一图像区域为人工标注的图像区域,并不能很精确的匹配到所需要抠出的图像区域。因此需要根据特征点对其进行调整。这里 的特征点为位于第一图像区域内部、边缘及周围邻近的特征点。由于这些特征点能够最大限度的表征图像特征,因此采用这些特征点对其进行调整,使得确定的第二图像区域的范围更加接近于即将抠出的图像区域,即使得抠出的图像区域更为精确。
步骤S14:根据所述第二图像区域对所述图像进行抠图。
具体的,可以直接将所述第二图像区域作为抠出区域抠出;也可以在第二图像区域的基础上进一步进行调整重新确定图像区域后再抠出,具体参见下述第四个可选实施例的相关描述。
本实施例通过人工标注的第一图像区域,根据所述特征点对所述第一图像区域进行调整,由于所述特征点能够最大限度的表征图像特征,因此采用所述特征点对其进行调整,使得确定的第二图像区域的范围更加接近于即将抠出的图像区域,进而使得抠出的图像区域更为精确。此外,由于特征点和标注的第一图像区域是根据图像确定的,对于不同的图像,针对图像所检测出的特征点及所标注的第一图像区域都能够与图像本身所需要抠出的部分相匹配,因此本实施例针对不同的图像均可以精确的抠出目标区域,这样就可以适用于各种图像的抠图。
在第一个可选的实施例中,步骤S12具体包括:
步骤S121:获取所述图像上人工标注的标注点。
具体的,用户可以根据自己的需求,自定义标注出标注点。例如,如果用户想要抠出眼睛区域,则可以在图像的眼睛区域即眼睛四周标注出标注点。如图1c所示的黑点为人工标注的标注点,从所述图像上获取人工标注的标注点。
步骤S122:将所述标注点确定为所述第一图像区域的边缘点。
具体的,将标注点所围成的图像区域作为所述第一图像区域,即所述标注点成为所述第一图像区域的边缘点。
在第二个可选的实施例中,步骤S13具体包括:
步骤S131:根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点。
由于标注点为人工标注,由其确定的图像区域并不能很精确的匹 配到所需要抠出的图像区域。因此需要根据特征点对其进行调整。由于所述特征点能够最大限度的表征图像特征,因此采用所述特征点对其进行调整,得到第一目标点。使得由第一目标点确定的第二图像区域的范围更加接近于即将抠出的图像区域,即使得抠出的图像区域更为精确。
步骤S132:将所述第一目标点围成的闭合区域确定为所述第二图像区域。
在第三个可选的实施例中,步骤S131具体包括:
步骤S1311:从所述特征点中选取与所述标注点最接近的初始点。
具体的,针对多个特征点,分别计算每个特征点与所述标注点的距离,例如,可以为余弦距离、欧式距离等;选取与所述标注点距离最近的特征点作为与所述标注点最接近的特征点。步骤S1312:将所述初始点围成的闭合区域确定为第三图像区域。
当选取的初始点的个数为多个时,其形成的闭合区域为多边形,由该多边形组成的闭合区域即为第三图像区域。例如,当选取的初始点的个数为3个时,则这3个初始点围成的闭合区域为一个三角形,该三角形所围成的区域即为第三图像区域。
步骤S1313:将所述第三图像区域的中心位置确定为所述标注点对应的第一目标点。
当第三图像区域的形状为多边形时,则将该多边形的中心位置确定为所述标注点对应的第一目标点。其中,中心位置可以为该多边形的几何中心或几何重心。例如,如果该多边形为规则的几何图形,例如正三角形、正四边形、或正五边形等,其对应的中心位置即为几何中心即对角线的交点,如果该多边形为不规则的几何图形,则其对应的中心位置即为几何重心,即为该多边形各边中线的交点。
上述场景为选取的最接近的初始点至少为3个时对应的确定第一目标点的方法。此外,还可以从所述特征点中选取一个与所述标注点最接近的特征点作为所述第一目标点。或者,从所述特征点中选取两个与所述标注点最接近的特征点,将该两个特征点的连线的中点作为所述第一目标点。
在第四个可选的实施例中,步骤S14具体包括:
步骤S141:确定所述第二图像区域的边缘,作为初始边缘。
其中,图像边缘为是图像属性区域和另一个属性区域的交接处,是区域属性发生突变的地方。具体可以采用现有的图像边缘提取方法确定所述第二图像区域的边缘,例如可以采用的图像边缘提取方法如下:微分算子法、拉普拉斯高斯算子法、Canny算子、拟合法、松驰法、神经网络分析法、小波变换法等。
步骤S142:对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘。
其中,目标边缘为外扩后的图像区域的边缘。
步骤S143:抠出由所述目标边缘围成的第四图像区域,得到抠图图像。
具体的,可以将第四图像区域直接作为目标图像抠出,抠出的图像中像素点的像素值为在所述图像中的像素值,即像素值保持不变。另外,为了使抠出的图像边缘区域更为平滑,可以对初始边缘与目标边缘围成的图像区域进行边缘透明过渡处理,具体参见下述第八个可选实施例的描述。
在第五个可选的实施例中,步骤S142具体包括:
步骤S1421:获取所述初始边缘上的像素点,作为初始边缘点。
具体的,可以选取所述初始边缘上的任意像素点作为初始边缘点。该任意像素点可以是特征点,也可以是非特征点。
步骤S1422:根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,所述外扩点位于所述第二图像区域之外。
其中,参考点可以为所述初始边缘点两侧的像素点或者特征点。一个初始边缘点可以对应一个外扩点,也可以对应多个外扩点。如图1d所示,封闭区域之外的白色点即为外扩点。
步骤S1423:连接所述外扩点,形成所述目标边缘。
在第六个可选的实施例中,步骤S1422具体包括:
步骤A:根据所述初始边缘点两侧的参考点确定所述初始边缘点的类型。
具体的,将初始边缘点与两侧的参考点进行连线得到两条线段,如图1e和1f所示,该两条线段形成一定的夹角,根据该夹角确定所述初始边缘点的类型。例如,如果该夹角为钝角,则确定所述初始边缘点的类型为凸点,如果该夹角为锐角,则确定所述初始边缘点的类型为凹点。
步骤B:根据所述类型确定所述初始边缘点对应的外扩点。
针对不同类型的初始边缘点,确定其对应的外扩点的方法也不同,具体参见下述第七个可选实施例的描述。
在第七个可选的实施例中,步骤B具体包括:
若所述类型为凸点,则根据所述初始边缘点与所述参考点构成的线段的法线方向向外延伸预设长度得到所述法线的外端点,并根据法线夹角在所述外端点间进行内插平滑得到对应的外扩点;若所述类型为凹点,则根据所述初始边缘点与所述参考点构成的夹角的角平分线向外延伸预设长度得到所述角平分线的外端点,将所述角平分线的外端点作为对应的外扩点。
其中,预设长度可以自定义设置。
例如,如图1g所示,当所述类型为凸点时,则根据两条线段的法线方向可以确定两个外端点,当两个外端点距离较远时,得到的图像区域不够平滑,本实施例采用在两个外端点间进行内插平滑的方式得到一系列外扩点,作为该初始边缘点的外扩点。如图1h所示,当所述类型为凹点时,则根据两条线段的夹角的角平分线确定外端点,此时只对应一个外端点,因此直接将该外端点作为该初始边缘点的外扩点。
在第八个可选的实施例中,步骤S143具体包括:
步骤S1431:将预设第一权重与所述初始边缘上像素点在所述图像中的像素值的乘积确定为所述初始边缘线上像素点在所述抠图图像中的像素值。
其中,预设第一权重可以由用户自定义设置,例如可以设为1。
步骤S1432:将预设第二权重与所述目标边缘上像素点在所述图像中的像素值的乘积确定为所述目标边缘上像素点在所述抠图图像中的像素值。
其中,预设第二权重可以由用户自定义设置,例如可以设为0。且在设置预设第一权重和预设第二权重时,为了使所述初始边缘与所述目标边缘组成的图像区域实现透明度随外扩程度逐渐递减的效果,使预设第一权重大于预设第二权重。
步骤S1433:根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值;其中,所述第五图像区域为所述初始边缘和所述目标边缘之间的图像区域。
在第九个可选的实施例中,步骤S1433包括:
步骤C:选取位于所述初始边缘上的第一像素点和位于所述目标边缘上的第二像素点组成多边形。
其中,所述第一像素点可以是所述初始边缘上的任意像素点、任意特征点或任意初始边缘点。所述第二像素点可以是所述目标边缘上的任意像素点、任意特征点或任意外扩点。
且所述第一像素点和所述第二像素点可以组成多边形,该多边形可以为三角形、四边形或五边形等。
步骤D:根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重。
关于本步骤实现确定所述第三像素点的第三权重的方法具体可参见下述第十可选实施例的描述。
除了本步骤确定所述第三像素点的第三权重之外,为了实现透明度随外扩程度逐渐递减,还可以将所述多边形内的像素点的权重设为预设第一权重和预设第二权重之间的值,例如0和1之间的数值。
步骤E:将所述第三权重与所述第三像素点在所述图像中的像素值的乘积确定为所述第三像素点在所述抠图图像中的像素值。
在第十个可选的实施例中,步骤D具体包括:
步骤D1:根据所述多边形的顶点的坐标和所述第三像素点的坐标确定每个顶点的权重系数。
步骤D2:将所有顶点的权重系数与设定的权重参数的加权和作为所述第三权重。
其中,设定的权重参数可以根据顶点所在的边缘确定。具体的, 如果该顶点为初始边缘上的第一像素点,则其对应的权重参数为预设第一权重,如果该顶点为目标边缘上的外扩点,则其对应的权重参数为预设第二权重。
以所述多边形为三角形为例,对本实施例进行说明。该三角形的三个顶点由初始边缘上的第一像素点和目标边缘上的外扩点组成。例如,由初始边缘上的2个第一像素点点和目标边缘上的1个外扩点组成,或者,由初始边缘上的1个第一像素点和目标边缘上的2个外扩点组成。因此,已知三角形的三个顶点P1、P2、P3的坐标,将u和v作为P2和P3的权重系数,且将(1-u-v)作为P1的权重系数,对于三角形内的任意点P,(u,v)必须满足条件u≥0,v≥0,u+v≤1。现在已知P1、P2、P3和P的坐标,通过求解下述方程即可得到u、v值:
P.x=(1-u-v)ⅹP1.x+uⅹP2.x+vⅹP3.x
P.y=(1-u-v)ⅹP1.y+uⅹP2.y+vⅹP3.y
其中,P.x为P横坐标,P.y为P纵坐标,P1.x为P1横坐标,P1.y为P纵坐标,P2.x为P2横坐标,P2.y为P2纵坐标,P3.x为P3横坐标,P3.y为P3纵坐标。有了上述u、v值,即可得到P1、P2、P3的权重系数。且P1、P2、P3对应的权重参数W1、W2、W3已知,因此可以将P1、P2、P3对应的权重系数与权重参数的加权和作为像素点P的权重,即通过公式W=(1-u-v)ⅹW1+uⅹW2+WⅹP3计算得到P的权重。
本领域技术人员应能理解,在上述各个实施例的基础上,还可以进行明显变型(例如,对所列举的模式进行组合)或等同替换。
在上文中,虽然按照上述的顺序描述了抠图方法实施例中的各个步骤,本领域技术人员应清楚,本公开实施例中的步骤并不必然按照上述顺序执行,其也可以倒序、并行、交叉等其他顺序执行,而且,在上述步骤的基础上,本领域技术人员也可以再加入其他步骤,这些明显变型或等同替换的方式也应包含在本公开的保护范围之内,在此不再赘述。
下面为本公开装置实施例,本公开装置实施例可用于执行本公开 方法实施例实现的步骤,为了便于说明,仅示出了与本公开实施例相关的部分,具体技术细节未揭示的,请参照本公开方法实施例。
实施例二
为了解决现有技术中使用抠图模板很难从图像中精确的抠出所需要的区域的技术问题,本公开实施例提供一种抠图装置。该装置可以执行上述实施例一所述的抠图方法实施例中的步骤。如图2所示,该装置主要包括:特征点检测模块21、标注区域获取模块22、区域确定模块23和抠图模块24;其中,
特征点检测模块21用于对图像进行特征点检测,得到多个特征点;
标注区域获取模块22用于获取所述图像上人工标注的第一图像区域;
区域确定模块23用于根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
抠图模块24用于根据所述第二图像区域对所述图像进行抠图。
进一步的,所述标注区域获取模块22包括:标注点获取单元221和标注区域确定单元222;其中,
标注点获取单元221用于获取所述图像上人工标注的标注点;
标注区域确定单元222用于将所述标注点确定为所述第一图像区域的边缘点。
进一步的,所述标注区域确定单元222具体用于:根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点;将所述第一目标点围成的闭合区域确定为所述第二图像区域。
进一步的,所述标注区域确定单元222具体用于:从所述特征点中选取与所述标注点最接近的初始点;将所述初始点围成的闭合区域确定为第三图像区域;将所述第三图像区域的中心位置确定为所述标注点对应的第一目标点。
进一步的,所述抠图模块24包括:初始边缘确定单元241、目标边缘确定单元242和抠图单元243;其中,
初始边缘确定单元241用于确定所述第二图像区域的边缘,作为初始边缘;
目标边缘确定单元242用于对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘;
抠图单元243用于抠出由所述目标边缘围成的第四图像区域,得到抠图图像。
进一步的,所述目标边缘确定单元242具体用于:获取所述初始边缘上的像素点,作为初始边缘点;根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,所述外扩点位于所述第二图像区域之外;连接所述外扩点,形成所述目标边缘。
进一步的,所述目标边缘确定单元242具体用于:根据所述初始边缘点两侧的参考点确定所述初始边缘点的类型;根据所述类型确定所述初始边缘点对应的外扩点。
进一步的,所述目标边缘确定单元242具体用于:若所述类型为凸点,则根据所述初始边缘点与所述参考点构成的线段的法线方向向外延伸预设长度得到所述法线的外端点,并根据法线夹角在所述外端点间进行内插平滑得到对应的外扩点;若所述类型为凹点,则根据所述初始边缘点与所述参考点构成的夹角的角平分线向外延伸预设长度得到所述角平分线的外端点,将所述角平分线的外端点作为对应的外扩点。
进一步的,所述抠图单元243具体用于:将预设第一权重与所述初始边缘上像素点在所述图像中的像素值的乘积确定为所述初始边缘线上像素点在所述抠图图像中的像素值;将预设第二权重与所述目标边缘上像素点在所述图像中的像素值的乘积确定为所述目标边缘上像素点在所述抠图图像中的像素值;根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值;其中,所述第五图像区域为所述初始边缘和所述目标边缘之间的图像区域。
进一步的,所述抠图单元243具体用于:选取位于所述初始边缘上的第一像素点和位于所述目标边缘上的第二像素点组成多边形;根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标 确定所述第三像素点的第三权重;将所述第三权重与所述第三像素点在所述图像中的像素值的乘积确定为所述第三像素点在所述抠图图像中的像素值。
进一步的,所述抠图单元243具体用于:根据所述多边形的顶点的坐标和所述第三像素点的坐标确定每个顶点的权重系数;将所有顶点的权重系数与设定的权重参数的加权和作为所述第三权重。
有关抠图装置实施例的工作原理、实现的技术效果等详细说明可以参考前述抠图方法实施例中的相关说明,在此不再赘述。
实施例三
下面参考图3,其示出了适于用来实现本公开实施例的电子设备300的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图3示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图3所示,电子设备300可以包括处理装置(例如中央处理器、图形处理器等)301,其可以根据存储在只读存储器(ROM)302中的程序或者从存储装置306加载到随机访问存储器(RAM)303中的程序而执行各种适当的动作和处理。在RAM 303中,还存储有电子设备300操作所需的各种程序和数据。处理装置301、ROM 302以及RAM 303通过总线304彼此相连。输入/输出(I/O)接口305也连接至总线304。
通常,以下装置可以连接至I/O接口305:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置306;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置307;包括例如磁带、硬盘等的存储装置306;以及通信装置309。通信装置309可以允许电子设备300与其他设备进行无线或有线通信以交换数据。虽然图3示出了具有各种装置的电子设备300,但是应 理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置309从网络上被下载和安装,或者从存储装置306被安装,或者从ROM 302被安装。在该计算机程序被处理装置301执行时,执行本公开实施例的方法中限定的上述功能。
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
在一些实施方式中,客户端、服务器可以利用诸如HTTP (HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:对图像进行特征点检测,得到特征点;
获取所述图像上人工标注的第一图像区域;根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;根据所述第二图像区域对所述图像进行抠图。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时 也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定,例如,第一获取单元还可以被描述为“获取至少两个网际协议地址的单元”。
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
根据本公开的一个或多个实施例,提供了一种抠图方法,包括:
对图像进行特征点检测,得到特征点;
获取所述图像上人工标注的第一图像区域;
根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
根据所述第二图像区域对所述图像进行抠图。
进一步的,所述获取所述图像上人工标注的第一图像区域,包括:
获取所述图像上人工标注的标注点;
将所述标注点确定为所述第一图像区域的边缘点。
进一步的,所述根据所述特征点对所述第一图像区域进行调整,得到第二图像区域,包括:
根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点;
将所述第一目标点围成的闭合区域确定为所述第二图像区域。
进一步的,所述根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点,包括:
从所述特征点中选取与所述标注点最接近的初始点;
将所述初始点围成的闭合区域确定为第三图像区域;
将所述第三图像区域的中心位置确定为所述标注点对应的第一目标点。
进一步的,所述根据所述第二图像区域对所述图像进行抠图,包括:
确定所述第二图像区域的边缘,作为初始边缘;
对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘;
抠出由所述目标边缘围成的第四图像区域,得到抠图图像。
进一步的,所述对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘,包括:
获取所述初始边缘上的像素点,作为初始边缘点;
根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,所述外扩点位于所述第二图像区域之外;
连接所述外扩点,形成所述目标边缘。
进一步的,所述根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,包括:
根据所述初始边缘点两侧的参考点确定所述初始边缘点的类型;
根据所述类型确定所述初始边缘点对应的外扩点。
进一步的,所述根据所述类型确定所述初始边缘点对应的外扩点,包括:
若所述类型为凸点,则根据所述初始边缘点与所述参考点构成的线段的法线方向向外延伸预设长度得到所述法线的外端点,并根据法线夹角在所述外端点间进行内插平滑得到对应的外扩点;
若所述类型为凹点,则根据所述初始边缘点与所述参考点构成的夹角的角平分线向外延伸预设长度得到所述角平分线的外端点,将所述角平分线的外端点作为对应的外扩点。
进一步的,所述抠出由所述目标边缘围成的第四图像区域,得到抠图图像,包括:
将预设第一权重与所述初始边缘上像素点在所述图像中的像素值的乘积确定为所述初始边缘线上像素点在所述抠图图像中的像素值;
将预设第二权重与所述目标边缘上像素点在所述图像中的像素值的乘积确定为所述目标边缘上像素点在所述抠图图像中的像素值;
根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值;其中,所述第五图像区域为所述初始边缘和所述目标边缘之间的图像区域。
进一步的,所述根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值,包括:
选取位于所述初始边缘上的第一像素点和位于所述目标边缘上的第二像素点组成多边形;
根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重;
将所述第三权重与所述第三像素点在所述图像中的像素值的乘积确定为所述第三像素点在所述抠图图像中的像素值。
进一步的,所述根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重,包括:
根据所述多边形的顶点的坐标和所述第三像素点的坐标确定每个顶点的权重系数;
将所有顶点的权重系数与设定的权重参数的加权和作为所述第三权重。
根据本公开的一个或多个实施例,提供了抠图装置,包括:
特征点检测模块,用于对图像进行特征点检测,得到多个特征点;
标注区域获取模块,用于获取所述图像上人工标注的第一图像区域;
区域确定模块,用于根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
抠图模块,用于根据所述第二图像区域对所述图像进行抠图。
进一步的,所述标注区域获取模块包括:
标注点获取单元,用于获取所述图像上人工标注的标注点;
标注区域确定单元,用于将所述标注点确定为所述第一图像区域的边缘点。
进一步的,所述标注区域确定单元具体用于:根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点;将所述第一目标点围成的闭合区域确定为所述第二图像区域。
进一步的,所述标注区域确定单元具体用于:从所述特征点中选取与所述标注点最接近的初始点;将所述初始点围成的闭合区域确定为第三图像区域;将所述第三图像区域的中心位置确定为所述标注点对应的第一目标点。
进一步的,所述抠图模块包括:
初始边缘确定单元,用于确定所述第二图像区域的边缘,作为初始边缘;
目标边缘确定单元,用于对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘;
抠图单元,用于抠出由所述目标边缘围成的第四图像区域,得到抠图图像。
进一步的,所述目标边缘确定单元具体用于:获取所述初始边缘上的像素点,作为初始边缘点;根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,所述外扩点位于所述第二图像区域之外;连接所述外扩点,形成所述目标边缘。
进一步的,所述目标边缘确定单元具体用于:根据所述初始边缘点两侧的参考点确定所述初始边缘点的类型;根据所述类型确定所述 初始边缘点对应的外扩点。
进一步的,所述目标边缘确定单元具体用于:若所述类型为凸点,则根据所述初始边缘点与所述参考点构成的线段的法线方向向外延伸预设长度得到所述法线的外端点,并根据法线夹角在所述外端点间进行内插平滑得到对应的外扩点;若所述类型为凹点,则根据所述初始边缘点与所述参考点构成的夹角的角平分线向外延伸预设长度得到所述角平分线的外端点,将所述角平分线的外端点作为对应的外扩点。
进一步的,所述抠图单元具体用于:将预设第一权重与所述初始边缘上像素点在所述图像中的像素值的乘积确定为所述初始边缘线上像素点在所述抠图图像中的像素值;将预设第二权重与所述目标边缘上像素点在所述图像中的像素值的乘积确定为所述目标边缘上像素点在所述抠图图像中的像素值;根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值;其中,所述第五图像区域为所述初始边缘和所述目标边缘之间的图像区域。
进一步的,所述抠图单元具体用于:选取位于所述初始边缘上的第一像素点和位于所述目标边缘上的第二像素点组成多边形;根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重;将所述第三权重与所述第三像素点在所述图像中的像素值的乘积确定为所述第三像素点在所述抠图图像中的像素值。
进一步的,所述抠图单元具体用于:根据所述多边形的顶点的坐标和所述第三像素点的坐标确定每个顶点的权重系数;将所有顶点的权重系数与设定的权重参数的加权和作为所述第三权重。
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要 求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。

Claims (14)

  1. 一种抠图方法,其特征在于,包括:
    对图像进行特征点检测,得到特征点;
    获取所述图像上人工标注的第一图像区域;
    根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
    根据所述第二图像区域对所述图像进行抠图。
  2. 根据权利要求1所述的方法,其特征在于,所述获取所述图像上人工标注的第一图像区域,包括:
    获取所述图像上人工标注的标注点;
    将所述标注点确定为所述第一图像区域的边缘点。
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述特征点对所述第一图像区域进行调整,得到第二图像区域,包括:
    根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点;
    将所述第一目标点围成的闭合区域确定为所述第二图像区域。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述特征点对所述标注点的位置进行调整,确定所述标注点对应的第一目标点,包括:
    从所述特征点中选取与所述标注点最接近的初始点;
    将所述初始点围成的闭合区域确定为第三图像区域;
    将所述第三图像区域的中心位置确定为所述标注点对应的第一目标点。
  5. 根据权利要求1所述的方法,其特征在于,所述根据所述第二图像区域对所述图像进行抠图,包括:
    确定所述第二图像区域的边缘,作为初始边缘;
    对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘;
    抠出由所述目标边缘围成的第四图像区域,得到抠图图像。
  6. 根据权利要求5所述的方法,其特征在于,所述对所述初始边缘向所述第二图像区域之外的方向进行外扩,得到目标边缘,包括:
    获取所述初始边缘上的像素点,作为初始边缘点;
    根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,所述外扩点位于所述第二图像区域之外;
    连接所述外扩点,形成所述目标边缘。
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述初始边缘点两侧的参考点确定所述初始边缘点对应的外扩点,包括:
    根据所述初始边缘点两侧的参考点确定所述初始边缘点的类型;
    根据所述类型确定所述初始边缘点对应的外扩点。
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述类型确定所述初始边缘点对应的外扩点,包括:
    若所述类型为凸点,则根据所述初始边缘点与所述参考点构成的线段的法线方向向外延伸预设长度得到所述法线的外端点,并根据法线夹角在所述外端点间进行内插平滑得到对应的外扩点;
    若所述类型为凹点,则根据所述初始边缘点与所述参考点构成的夹角的角平分线向外延伸预设长度得到所述角平分线的外端点,将所述角 平分线的外端点作为对应的外扩点。
  9. 根据权利要求5-8任一项所述的方法,其特征在于,所述抠出由所述目标边缘围成的第四图像区域,得到抠图图像,包括:
    将预设第一权重与所述初始边缘上像素点在所述图像中的像素值的乘积确定为所述初始边缘线上像素点在所述抠图图像中的像素值;
    将预设第二权重与所述目标边缘上像素点在所述图像中的像素值的乘积确定为所述目标边缘上像素点在所述抠图图像中的像素值;
    根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值;其中,所述第五图像区域为所述初始边缘和所述目标边缘之间的图像区域。
  10. 根据权利要求9所述的方法,其特征在于,所述根据所述初始边缘和所述目标边缘确定第五图像区域中每个像素点的像素值,包括:
    选取位于所述初始边缘上的第一像素点和位于所述目标边缘上的第二像素点组成多边形;
    根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重;
    将所述第三权重与所述第三像素点在所述图像中的像素值的乘积确定为所述第三像素点在所述抠图图像中的像素值。
  11. 根据权利要求10所述的方法,其特征在于,所述根据所述多边形的顶点的坐标和位于所述多边形内的第三像素点的坐标确定所述第三像素点的第三权重,包括:
    根据所述多边形的顶点的坐标和所述第三像素点的坐标确定每个顶点的权重系数;
    将所有顶点的权重系数与设定的权重参数的加权和作为所述第三权重。
  12. 一种抠图装置,其特征在于,包括:
    特征点检测模块,用于对图像进行特征点检测,得到多个特征点;
    标注区域获取模块,用于获取所述图像上人工标注的第一图像区域;
    区域确定模块,用于根据所述特征点对所述第一图像区域进行调整,得到第二图像区域;
    抠图模块,用于根据所述第二图像区域对所述图像进行抠图。
  13. 一种电子设备,包括:
    存储器,用于存储非暂时性计算机可读指令;以及
    处理器,用于运行所述计算机可读指令,使得所述处理器执行时实现根据权利要求1-11任一项所述的抠图方法。
  14. 一种计算机可读存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时,使得所述计算机执行权利要求1-11任一项所述的抠图方法。
PCT/CN2020/105441 2019-10-24 2020-07-29 抠图方法及装置 WO2021077836A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/770,983 US20220375098A1 (en) 2019-10-24 2020-07-29 Image matting method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911014880.7 2019-10-24
CN201911014880.7A CN112712459B (zh) 2019-10-24 2019-10-24 抠图方法及装置

Publications (1)

Publication Number Publication Date
WO2021077836A1 true WO2021077836A1 (zh) 2021-04-29

Family

ID=75540206

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/105441 WO2021077836A1 (zh) 2019-10-24 2020-07-29 抠图方法及装置

Country Status (3)

Country Link
US (1) US20220375098A1 (zh)
CN (1) CN112712459B (zh)
WO (1) WO2021077836A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150193939A1 (en) * 2012-10-30 2015-07-09 Apple Inc. Depth mapping with enhanced resolution
CN109389611A (zh) * 2018-08-29 2019-02-26 稿定(厦门)科技有限公司 交互式抠图方法、介质及计算机设备
CN109388725A (zh) * 2018-10-30 2019-02-26 百度在线网络技术(北京)有限公司 通过视频内容进行搜索的方法及装置
CN109934843A (zh) * 2019-01-28 2019-06-25 北京华捷艾米科技有限公司 一种实时的轮廓精细化抠像方法及存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657974A (zh) * 2013-11-25 2015-05-27 腾讯科技(上海)有限公司 一种图像处理方法及装置
CN104820990A (zh) * 2015-05-15 2015-08-05 北京理工大学 一种交互式图像抠图系统
CN110097560A (zh) * 2019-04-30 2019-08-06 上海艾麒信息科技有限公司 抠图方法以及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150193939A1 (en) * 2012-10-30 2015-07-09 Apple Inc. Depth mapping with enhanced resolution
CN109389611A (zh) * 2018-08-29 2019-02-26 稿定(厦门)科技有限公司 交互式抠图方法、介质及计算机设备
CN109388725A (zh) * 2018-10-30 2019-02-26 百度在线网络技术(北京)有限公司 通过视频内容进行搜索的方法及装置
CN109934843A (zh) * 2019-01-28 2019-06-25 北京华捷艾米科技有限公司 一种实时的轮廓精细化抠像方法及存储介质

Also Published As

Publication number Publication date
CN112712459A (zh) 2021-04-27
US20220375098A1 (en) 2022-11-24
CN112712459B (zh) 2023-09-19

Similar Documents

Publication Publication Date Title
CN108594997B (zh) 手势骨架构建方法、装置、设备及存储介质
WO2019101021A1 (zh) 图像识别方法、装置及电子设备
WO2020024483A1 (zh) 用于处理图像的方法和装置
US20130243351A1 (en) Methods and Apparatus for Interfacing Panoramic Image Stitching with Post-Processors
WO2020082731A1 (zh) 电子装置、证件识别方法及存储介质
WO2020248900A1 (zh) 全景视频的处理方法、装置及存储介质
WO2021139382A1 (zh) 人脸图像的处理方法、装置、可读介质和电子设备
CN111325699B (zh) 图像修复方法和图像修复模型的训练方法
CN110211195B (zh) 生成图像集合的方法、装置、电子设备和计算机可读存储介质
US9070345B2 (en) Integrating street view with live video data
US20210335391A1 (en) Resource display method, device, apparatus, and storage medium
CN111325220B (zh) 图像生成方法、装置、设备及存储介质
CN110248197B (zh) 语音增强方法及装置
CN110991457A (zh) 二维码处理方法、装置、电子设备及存储介质
CN112990440B (zh) 用于神经网络模型的数据量化方法、可读介质和电子设备
WO2021077836A1 (zh) 抠图方法及装置
CN112508959A (zh) 视频目标分割方法、装置、电子设备及存储介质
CN111754435A (zh) 图像处理方法、装置、终端设备及计算机可读存储介质
CN112801997B (zh) 图像增强质量评估方法、装置、电子设备及存储介质
WO2021073204A1 (zh) 对象的显示方法、装置、电子设备及计算机可读存储介质
WO2020215854A1 (zh) 渲染图像的方法、装置、电子设备和计算机可读存储介质
CN111461964B (zh) 图片处理方法、装置、电子设备和计算机可读介质
US10902265B2 (en) Imaging effect based on object depth information
CN114154520A (zh) 机器翻译模型的训练方法、机器翻译方法、装置及设备
CN111784607A (zh) 图像色调映射方法、装置、终端设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20879154

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20879154

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 30.08.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20879154

Country of ref document: EP

Kind code of ref document: A1