WO2020043063A1 - 交互式抠图方法、介质及计算机设备 - Google Patents

交互式抠图方法、介质及计算机设备 Download PDF

Info

Publication number
WO2020043063A1
WO2020043063A1 PCT/CN2019/102621 CN2019102621W WO2020043063A1 WO 2020043063 A1 WO2020043063 A1 WO 2020043063A1 CN 2019102621 W CN2019102621 W CN 2019102621W WO 2020043063 A1 WO2020043063 A1 WO 2020043063A1
Authority
WO
WIPO (PCT)
Prior art keywords
pixel
unknown region
sampling
alpha
foreground
Prior art date
Application number
PCT/CN2019/102621
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 稿定(厦门)科技有限公司
Publication of WO2020043063A1 publication Critical patent/WO2020043063A1/zh
Priority to US16/929,139 priority Critical patent/US11443436B2/en

Links

Images

Classifications

    • 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/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • 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
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/272Means for inserting a foreground image in a background image, i.e. inlay, outlay
    • 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/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • 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

Definitions

  • the invention relates to the technical field of image processing, and in particular, to an interactive matting method, a medium, and a computer device.
  • Matting is one of the most common operations in image processing. It refers to the operation process of extracting the required part of the image from the screen.
  • an object of the present invention is to propose an interactive matting method, which can realize the determination of the sampling pair and the unknown region through a simple interaction with the user, and then calculate the alpha value of the pixels of the unknown region according to the sampling pair, so that Users can complete accurate matting of hair edges without mastering rich PS technology and color channel knowledge.
  • a second object of the present invention is to provide a computer-readable storage medium.
  • a third object of the present invention is to provide a computer device.
  • an embodiment of the first aspect of the present invention proposes an interactive matting method, which includes the following steps: obtaining an original image; and using a human-computer interaction method to separately perform foreground samples on a hair edge foreground region of the original image Point collection and background sample point collection on the hair edge background area of the original image to obtain foreground sample space and background sample space respectively, wherein the foreground sample points in the foreground sample space and the background sample space
  • the background sample points constitute a sampling pair; receive a mark operation instruction input by the user, and smear the hair area of the original image to mark the unknown area according to the mark operation instruction; traverse the unknown area to obtain each unknown area pixel , And traverse all sampling pairs according to each unknown region pixel to select the sampling pair with the smallest overall cost function value for each unknown region pixel, and calculate the alpha value corresponding to each unknown region pixel according to the selected sampling pair; according to each unknown Obtain an alpha mask image with the alpha value corresponding to the area pixel And processing
  • an original image is obtained; then, a human-computer interaction method is used to collect foreground sample points on a hair edge foreground region of the original image and perform a hair edge background region on the original image.
  • the background sample points are collected to obtain the foreground sample space and the background sample space, wherein the foreground sample point in the foreground sample space and the background sample point in the background sample space constitute a sampling pair; then, a label operation instruction input by the user is received, and Smear the hair region of the original image according to the marking operation instruction to mark the unknown region; then, traverse the unknown region to obtain each unknown region pixel, and traverse all the sampling pairs according to each unknown region pixel to select the total for each unknown region pixel
  • the sampling pair with the smallest cost function value, and the alpha value corresponding to each unknown region pixel is calculated according to the selected sampling pair; then, an alpha mask image is obtained according to the alpha value corresponding to each pixel in the unknown region, and according to each unknown Alpha value pair a corresponding to the area pixel
  • the lpha mask image is processed to obtain the final alpha mask image; thus, the sample pair and the unknown region are determined through a simple interaction with the user, and the alpha value of the pixel in
  • the interactive matting method provided by the foregoing embodiment of the present invention may also have the following additional technical features:
  • obtaining the foreground sample space and the background sample space includes: receiving a first sample point acquisition instruction input by a user, and foregrounding a hair edge foreground region of the original image according to the first sample point acquisition instruction.
  • Sample points are collected to obtain multiple foreground sample points, where the multiple foreground sample points constitute the foreground sample space; a second sample point collection instruction input by a user is received, and all samples are received according to the second sample point collection instruction.
  • the background region of the hair edge background of the original image is collected to obtain a plurality of background sample points, wherein the plurality of background sample points constitute the background sample space.
  • traversing all the sampling pairs according to each unknown region pixel to select the sampling pair with the lowest overall cost function value for each unknown region pixel including: S1, giving an estimated alpha to the current unknown region pixel I according to any one sampling pair value S2, according to the estimated alpha value Calculate the coincidence between the sampling pair and the current unknown region pixel I; S3, calculate the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, and calculate the current unknown region pixel I and the sampling The spatial distance of the background sample point in the alignment; S4.
  • the current unknown calculates the overall cost function value of the spatial distance between the regional pixel I and the background sample point in the sampling pair; repeat steps S1-S4 to obtain the overall cost function values of all the sampling pairs corresponding to the current unknown regional pixel I, as the current The pixels in the unknown region select the sampling pair with the smallest overall cost function.
  • the coincidence between the sampling pair and the pixel I in the current unknown region is obtained according to the following formula: Where ⁇ c (F i , B j ) is the degree of coincidence between the sampling pair and the pixel I in the current unknown region.
  • the spatial distance between the pixel I of the current unknown region and the foreground sample point in the sampling pair is obtained according to the following formula: Where ⁇ s (F i ) is the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, Is the spatial position of the foreground sample point in the sampling pair, and X I is the spatial position of the pixel I of the current unknown region.
  • the spatial distance between the current unknown region pixel I and the background sample point in the sampling pair is obtained according to the following formula: Where ⁇ s (B j ) is the spatial distance between the current unknown region pixel I and the background sample point in the sampling pair, The spatial position of the background sample points for this sampling pair.
  • processing the alpha mask image according to the alpha value corresponding to each unknown region pixel to obtain a final alpha mask image includes: according to the alpha value corresponding to each unknown region pixel, the alpha mask is processed. The image is denoised to obtain the final alpha mask image.
  • processing the alpha mask image to obtain a final alpha mask image according to an alpha value corresponding to each unknown region pixel includes: traversing the unknown region pixel, and judging that each unknown region pixel corresponds to Whether the alpha value of the pixel in the unknown region and the four neighboring pixels of the pixel in the unknown region are greater than a preset threshold; if so, the pixel in the unknown region is regarded as a pixel to be processed; the pixels to be processed are traversed, and The processed pixels are enhanced with alpha values, and a final mask image is generated according to the alpha values corresponding to the enhanced pixels to be processed.
  • the alpha value corresponding to each pixel to be processed is enhanced according to the following formula:
  • represents an enhanced alpha value corresponding to the pixel to be processed
  • the method further includes: traversing the pixels to be processed and color rendering the pixels to be processed to generate a color channel image corresponding to the original image; and according to the final mask image and the color channel image Generate final matte results.
  • an embodiment of the second aspect of the present invention provides a computer-readable storage medium on which an interactive matting program is stored.
  • the interactive matting program is executed by a processor, the interactive matting program is implemented. method.
  • an embodiment of the third aspect of the present invention provides a computer device including a memory, a processor, and an interactive matting program stored on the memory and executable on the processor, where the processor executes In the interactive matting program, the above-mentioned interactive matting method is implemented.
  • FIG. 1 is a schematic flowchart of an interactive matting method according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of an interactive matting method according to another embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of an interactive matting method according to another embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a method for selecting a sampling pair with a minimum overall cost function value for each unknown region pixel according to an embodiment of the present invention.
  • the interactive matting method proposed by the embodiment of the present invention First, obtain the original image; then, use human-computer interaction to collect foreground sample points on the hair edge foreground area of the original image and background sample point collection on the hair edge background area of the original image to obtain the foreground sample space accordingly.
  • FIG. 1 is a schematic flowchart of an interactive matting method according to an embodiment of the present invention. As shown in FIG. 1, the interactive matting method includes the following steps:
  • the raw image data to be processed is obtained.
  • human-computer interaction is used to collect foreground sample points in the foreground area at the edge of the hair in the original image to obtain the foreground sample space; background sample points are collected in the background area at the edge of the hair in the original image to obtain Background sample space; wherein the foreground sample point in the foreground sample space and the background sample point in the background sample space constitute a sampling pair.
  • obtaining the foreground sample space and the background sample space may specifically include: receiving a first sample point acquisition instruction input by a user, and performing foreground sample points on a hair edge foreground region of the original image according to the first sample point acquisition instruction. Collect to obtain multiple foreground sample points, where multiple foreground sample points constitute the foreground sample space; receive a second sample point collection instruction input by the user, and perform background processing on the hair edge background area of the original image according to the second sample point collection instruction Sample points are collected to obtain multiple background sample points, where multiple background sample points constitute a background sample space.
  • a foreground sample point is used to form the foreground sample space F;
  • the user's background sample point acquisition instruction is obtained through human-computer interaction to obtain the background sample points B 1 , B 2 , and B 3 in the background area of the hair edge in the original image ..., B b , and the background sample space B is formed by b background sample points; then, any one of the foreground sample points and any one of the background sample points are used to form a sampling pair (F i , B j ).
  • S103 Receive a marking operation instruction input by a user, and smear a hair region of the original image according to the marking operation instruction to mark an unknown area.
  • a mark operation instruction for the original image input by the user is received, and the original image is processed according to the mark operation instruction. Hair areas are smeared to mark unknown areas.
  • the unknown region refers to a region in which hair or animal hair is difficult to be separated from the background image due to the thinness and chaos of the hair or animal hair.
  • S104 Traverse the unknown region to obtain pixels of each unknown region, and traverse all sampling pairs according to each unknown region pixel to select the sampling pair with the lowest overall cost function value for each unknown region pixel, and calculate each unknown according to the selected sampling pair.
  • the unknown region is traversed to obtain each unknown region pixel in the unknown region, and according to each unknown region pixel, all sampling pairs composed of foreground sample collection points and background sample collection points are traversed.
  • the sampling pair that minimizes the overall cost function value is selected, and the alpha value of the corresponding unknown region pixel is calculated according to the selected sample to obtain the alpha value corresponding to each unknown region pixel.
  • S105 Obtain an alpha mask image according to an alpha value corresponding to each unknown region pixel, and process the alpha mask image according to an alpha value corresponding to each unknown region pixel to obtain a final alpha mask image.
  • the interactive matting method includes the following steps:
  • S203 Receive a marking operation instruction input by the user, and smear the hair area of the original image according to the marking operation instruction to mark the unknown area.
  • S204 Traverse the unknown region to obtain pixels of each unknown region, and traverse all sampling pairs according to each unknown region pixel to select a sampling pair with the lowest overall cost function value for each unknown region pixel, and calculate each unknown according to the selected sampling pair.
  • steps S201 to S204 are consistent with steps S101 to S104, and details are not described herein.
  • S205 Obtain an alpha mask image according to the alpha value corresponding to the pixels of each unknown region, and perform denoising processing on the alpha mask image to obtain a final alpha mask image.
  • an alpha mask image is generated according to the alpha value corresponding to each unknown region pixel; then, the alpha mask image is denoised to obtain the final Alpha mask image.
  • a guide image G corresponding to the alpha mask image Q is obtained, and an auto-correlation mean corr G and a cross-correlation mean corr GQ of a square filter with r as a radius are calculated; then, for a mask The autocorrelation variance var G and cross-correlation covariance cov GQ of the image Q and the guidance image G; then, calculate a window linear transformation coefficient, and calculate the average of each linear transformation coefficient based on the linear transformation coefficient, and then, according to the guidance image G and each linear The mean of the coefficient of variation generates the final alpha mask image.
  • the interactive matting method provided by the embodiment of the present invention includes the following steps:
  • S303 Receive a marking operation instruction input by the user, and smear the hair area of the original image according to the marking operation instruction to mark the unknown area.
  • S304 Traverse the unknown region to obtain pixels of each unknown region, and traverse all sampling pairs according to each unknown region pixel to select the sampling pair with the lowest overall cost function value for each unknown region pixel, and calculate each unknown according to the selected sampling pair.
  • steps S301 to S304 are consistent with steps S101 to S104, and details are not described herein.
  • S305 Iterate through the pixels in the unknown area, and determine whether the alpha value corresponding to each unknown area pixel and the alpha value corresponding to the four neighboring pixels of the unknown area pixel are greater than a preset threshold.
  • the following formula is used to determine whether the alpha value corresponding to each unknown region pixel and the alpha value corresponding to the four neighboring pixels of the unknown region pixel are greater than a preset threshold:
  • S307 Iterate through the pixels to be processed, perform alpha value enhancement on each to-be-processed pixel, and generate a final mask image according to the enhanced alpha value corresponding to the to-be-processed pixel.
  • the alpha value corresponding to each pixel to be processed is enhanced according to the following formula:
  • represents an enhanced alpha value corresponding to the pixel to be processed
  • S308 Iterate through the pixels to be processed and perform color rendering on the pixels to be processed to generate a color channel image corresponding to the original image.
  • the color channel image corresponding to the original image is generated according to the following formula:
  • I_g F i _g
  • F i represents a cost function such that the overall area of the pixel values of the unknown sample smallest foreground color
  • F i _b denotes blue channel values F i contained
  • F i _g F i represents a green channel value contained
  • F i _r Indicates the red channel value contained in F i
  • I_b indicates the blue channel value of the pixel of the unknown region in the color channel image
  • I_g indicates the green channel value of the pixel of the unknown region in the color channel image
  • I_r indicates the pixel of the unknown region in the color channel image The red channel value in.
  • the interactive matting method according to the embodiment of the present invention, first, the original image is obtained; then, the foreground edge points of the hair edge foreground area of the original image are collected and the original image is obtained by using human-computer interaction. Background sample points are collected at the hair edge background area to obtain the foreground sample space and the background sample space, wherein the foreground sample point in the foreground sample space and the background sample point in the background sample space form a sampling pair; then, the user input is received.
  • Mark operation instructions, and smear hair regions of the original image to mark unknown areas according to the mark operation instructions then, traverse the unknown areas to obtain each unknown area pixel, and traverse all sampling pairs according to each unknown area pixel to each The unknown region pixels select the sampling pair with the smallest overall cost function value, and calculate the alpha value corresponding to each unknown region pixel according to the selected sampling pair; then, obtain an alpha mask image according to the alpha value corresponding to each unknown region pixel, And denoising the alpha mask image Obtain the final alpha mask image; thus, through simple interaction with the user to determine the sampling pair and the unknown region, and then calculate the alpha value of the pixels in the unknown region based on the sampling pair, so that the user does not need to master the rich PS technology and color channels Knowledge, you can complete accurate cutouts of hair edges.
  • all sampling pairs are traversed according to each unknown region pixel to select the sampling pair with the lowest overall cost function value for each unknown region pixel. , Including the following steps:
  • an alpha value is performed on the pixel I of the current unknown region Estimate.
  • F i is a foreground sample point in the sample pair
  • B j is a background sample point in the sample pair.
  • the alpha value of pixel I in the current unknown region After making an estimate, based on the estimated alpha value Calculate the coincidence between the sampling pair and the pixel I in the current unknown region.
  • the coincidence between the sampling pair and the pixel I in the current unknown region is obtained according to the following formula:
  • ⁇ c (F i , B j ) is the degree of coincidence between the sampling pair and the pixel I in the current unknown region.
  • the spatial distance between the pixel I of the current unknown region and the foreground sample point in the sampling pair is obtained according to the following formula:
  • ⁇ s (F i ) is the spatial distance between the pixel I of the current unknown region and the foreground sample point in the sampling pair
  • X I is the spatial position of the pixel I in the current unknown region
  • the spatial distance between the pixel I of the current unknown region and the background sample point in the sampling pair is obtained according to the following formula:
  • ⁇ s (B j ) is the spatial distance between the pixel I in the current unknown region and the background sample point in the sampling pair, The spatial position of the background sample points for this sampling pair.
  • the coincidence between the sampling pair and the current unknown region pixel I, the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, and the space between the current unknown region pixel I and the background sample point in the sampling pair are calculated.
  • the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, the current unknown region pixel I and the background sample point in the sampling pair is used to calculate the value of the overall cost function.
  • the overall cost function value of the sampling pair is obtained according to the following formula:
  • ⁇ (F i , B j ) ⁇ c (F i , B j ) + w 1 * ⁇ s (F i ) + w 2 * ⁇ s (B j )
  • ⁇ (F i , B j ) is the value of the overall cost function of the sampling pair
  • w 1 is the weight of the spatial distance cost function ⁇ s (F i )
  • w 2 is the value of the spatial distance cost function ⁇ s (B j ) Weights.
  • steps S1-S4 are repeatedly performed to obtain the total cost function values of all sampling pairs corresponding to the current unknown region pixel I, and according to the total cost function values of all sampling pairs, selecting the current unknown region pixel I to correspond to The sample cost of the minimum value of the overall cost function.
  • an estimated alpha value is given to the pixel I of the current unknown region according to any one of the samplings. Then, based on the estimated alpha value Calculate the coincidence between the sampling pair and the current unknown region pixel I; then, calculate the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, and calculate the current unknown region pixel I and the background sample point in the sampling pair.
  • the spatial distance between the current unknown region pixel I and the foreground sample point in the sampling pair, the current unknown region pixel I and the background sample point in the sampling pair Calculate the overall cost function value from the spatial distance; then, iteratively perform the above steps to obtain the overall cost function values of all sampling pairs corresponding to the pixel I in the current unknown region, so as to select the sampling pair with the lowest overall cost function value for the pixels in the current unknown region;
  • the determination of the sampling pair corresponding to the minimum overall cost function value of the sampling pair consisting of the foreground sampling point and the background sampling point and the pixels in the unknown region provides a basis for subsequent calculation of the alpha value corresponding to the pixels in the unknown region.
  • an embodiment of the present invention further provides a computer-readable storage medium on which an interactive matting program is stored.
  • an interactive matting program is executed by a processor, the foregoing interactive matting method is implemented. .
  • an interactive matting program is stored, so that the processor can implement the interactive matting method as described above when the program is executed, so as to implement the sampling points based on the foreground and the background.
  • the determination of the sampling pair corresponding to the minimum overall cost function value of the formed sampling pair and the pixels in the unknown region provides a basis for subsequent calculation of the alpha value corresponding to the pixels in the unknown region.
  • an embodiment of the present invention provides a computer device including a memory, a processor, and an interactive matting program stored on the memory and executable on the processor, wherein the processor executes the In the interactive matting program, the above-mentioned interactive matting method is implemented.
  • an interactive matting program that can be run on a processor is stored in a memory, so that when the processor executes the interactive matting program, the interactive matting method described above can be implemented, Therefore, the determination of the sampling pair corresponding to the minimum overall cost function value of the sampling pair composed of the foreground sampling point and the background sampling point and the pixels in the unknown region is realized, and the basis for subsequent calculation of the alpha value corresponding to the pixels in the unknown region is provided.
  • the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a particular manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions
  • the device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
  • any reference signs placed between parentheses shall not be construed as limiting the claim.
  • the word “comprising” does not exclude the presence of elements or steps not listed in a claim.
  • the word “a” or “an” preceding a part does not exclude the presence of a plurality of such parts.
  • the invention can be implemented by means of hardware comprising several distinct parts, and by means of a suitably programmed computer. In the unit claim listing several devices, several of these devices may be embodied by the same hardware item.
  • the use of the words first, second, and third does not indicate any order. These words can be interpreted as names.
  • first and second are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as “first” and “second” may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality” is two or more, unless specifically defined otherwise.
  • the terms “installation”, “connected”, “connected”, “fixed” and other terms shall be understood in a broad sense unless otherwise specified and defined, for example, they may be fixed connections or removable connections , Or integrated; it can be mechanical or electrical connection; it can be directly connected, or it can be indirectly connected through an intermediate medium, it can be the internal connection of the two elements or the interaction between the two elements.
  • the specific meanings of the above terms in the present invention can be understood according to specific situations.
  • the first feature "on” or “down” of the second feature may be the first and second features in direct contact, or the first and second features indirectly through an intermediate medium. contact.
  • the first feature is “above”, “above”, and “above” the second feature.
  • the first feature is directly above or obliquely above the second feature, or only indicates that the first feature is higher in level than the second feature.
  • the first feature is “below”, “below”, and “below” of the second feature.
  • the first feature may be directly below or obliquely below the second feature, or it may simply indicate that the first feature is less horizontal than the second feature.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computer Graphics (AREA)
  • Multimedia (AREA)
  • Image Processing (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)

Abstract

本发明公开了一种交互式抠图方法、介质及计算机设备,该方法包括:获取原始图像;采用人机交互的方式获得前景样本空间和背景样本空间;根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域;获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并对alpha蒙版图像进行处理以获得最终alpha蒙版图像;从而实现通过简单交互进行采样对和未知区域的确定,进而根据采样对计算未知区域像素的alpha值,使得用户可无需掌握丰富的PS技术和颜色通道知识,即可完成对头发边缘的精确抠图。

Description

交互式抠图方法、介质及计算机设备 技术领域
本发明涉及图像处理技术领域,特别涉及一种交互式抠图方法、介质及计算机设备。
背景技术
抠图,是图像处理中最常做的操作之一,其指的是将图像中需要的部分从画面中提取出来的操作过程。
在实际的抠图操作过程中,当遇到包含人物头发、动物毛发等图像的处理时,如果不借助工具纯粹通过人工手动抠取的话,每幅图都需要花费操作人员大量时间和精力;因而,为了解决此类图像的抠取困难的问题,现有的抠图技术提出了诸如Knockout、Robust Matting等采样方法,以提高操作人员抠取目标图像的效率;然而,这些采样方法大多非常复杂,需要操作人员掌握丰富的PS技术和颜色通道知识,对于初学者而言难以操作。
发明内容
本发明旨在至少在一定程度上解决上述技术中的技术问题之一。为此,本发明的一个目的在于提出一种交互式抠图方法,能够实现通过与用户之间的简单交互进行采样对和未知区域的确定,进而根据采样对计算未知区域像素的alpha值,使得用户可无需掌握丰富的PS技术和颜色通道知识,即可完成对头发边缘的精确抠图。
本发明的第二个目的在于提出一种计算机可读存储介质。
本发明的第三个目的在于提出一种计算机设备。
为达到上述目的,本发明第一方面实施例提出了一种交互式抠图方法,包括以下步骤:获取原始图像;采用人机交互的方式分别对所述原始图像的头发边缘前景区域进行前景样本点采集和对所述原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,所述前景样本空间中的前景样本点和所述背景样本空间中的背景样本点构成采样对;接收用户输入的标记操作指令,并根据所述标记操作指令对所述原始图像的头发区域进行涂抹以标记出未知区域;遍历所述未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像。
根据本发明实施例的交互式抠图方法,首先,获取原始图像;接着,采用人机交互的 方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对;然后,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域;接着,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;然后,根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并根据每个未知区域像素所对应的alpha值对alpha蒙版图像进行处理以获得最终alpha蒙版图像;从而实现通过与用户之间的简单交互进行采样对和未知区域的确定,进而根据采样对计算未知区域像素的alpha值,使得用户可无需掌握丰富的PS技术和颜色通道知识,即可完成对头发边缘的精确抠图。
另外,根据本发明上述实施例提出的交互式抠图方法还可以具有如下附加的技术特征:
可选地,获得前景样本空间和背景样本空间,包括:接收用户输入的第一样本点采集指令,并根据所述第一样本点采集指令对所述原始图像的头发边缘前景区域进行前景样本点采集以获得多个前景样本点,其中,所述多个前景样本点构成所述前景样本空间;接收用户输入的第二样本点采集指令,并根据所述第二样本点采集指令对所述原始图像的头发边缘背景区域进行背景样本点采集以获得多个背景样本点,其中,所述多个背景样本点构成所述背景样本空间。
可选地,根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,包括:S1,根据任意一个采样对对当前未知区域像素I给出预估alpha值
Figure PCTCN2019102621-appb-000001
S2,根据所述预估alpha值
Figure PCTCN2019102621-appb-000002
计算该采样对与所述当前未知区域像素I的符合度;S3,计算所述当前未知区域像素I与该采样对中前景样本点的空间距离,并计算所述当前未知区域像素I与该采样对中背景样本点的空间距离;S4,根据该采样对与所述当前未知区域像素I的符合度、所述当前未知区域像素I与该采样对中前景样本点的空间距离、所述当前未知区域像素I与该采样对中背景样本点的空间距离计算总体代价函数值;重复执行步骤S1-S4,获得所述当前未知区域像素I对应的所有采样对的总体代价函数值,以为所述当前未知区域像素选取总体代价函数值最小的采样对。
可选地,所述预估alpha值
Figure PCTCN2019102621-appb-000003
根据以下公式获得:
Figure PCTCN2019102621-appb-000004
其中,F i为该样本对中的前景样本点,B j为该样本对中的背景样本点。
可选地,该采样对与所述当前未知区域像素I的符合度根据以下公式获得:
Figure PCTCN2019102621-appb-000005
Figure PCTCN2019102621-appb-000006
其中,ε c(F i,B j)为该采样对与所述当前未知区域像素I的符合度。
可选地,所述当前未知区域像素I与该采样对中前景样本点的空间距离根据以下公式获得:
Figure PCTCN2019102621-appb-000007
其中,ε s(F i)为所述当前未知区域像素I与该采样对中前景样本点的空间距离,
Figure PCTCN2019102621-appb-000008
为该采样对中前景样本点的空间位置,X I为所述当前未知区域像素I的空间位置。
可选地,所述当前未知区域像素I与该采样对中背景样本点的空间距离根据以下公式获得:
Figure PCTCN2019102621-appb-000009
其中,ε s(B j)为所述当前未知区域像素I与该采样对中背景样本点的空间距离,
Figure PCTCN2019102621-appb-000010
为该采样对中背景样本点的空间位置。
可选地,该采样对的总体代价函数值根据以下公式获得:ε(F i,B j)=ε c(F i,B j)+w 1s(F i)+w 2s(B j),其中,ε(F i,B j)为该采样对的总体代价函数值,w 1为空间距离代价函数ε s(F i)的权重,w 2为空间距离代价函数ε s(B j)的权重。
可选地,根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像,包括:根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行去噪处理以获得最终alpha蒙版图像。
可选地,根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像,包括:遍历所述未知区域像素,并判断每个未知区域像素所对应的alpha值和该未知区域像素四邻域像素所对应的alpha值是否均大于预设的阈值;如果是,则将该未知区域像素作为待处理像素;遍历所述待处理像素,并对每个待处理像素进行alpha值增强,以及根据增强后的待处理像素对应的alpha值生成最终蒙版图像。
可选地,根据以下公式进行每个待处理像素对应的alpha值的增强:
Figure PCTCN2019102621-appb-000011
其中,α表示所述待处理像素对应的alpha值增强后的值,
Figure PCTCN2019102621-appb-000012
表示所述待处理像素的原始alpha值。
可选地,还包括:遍历所述待处理像素,并对所述待处理像素进行颜色渲染,以生成对应所述原始图像的彩色通道图像;根据所述最终蒙版图像和所述彩色通道图像生成最终抠图结果。
为达到上述目的,本发明第二方面实施例提出了一种计算机可读存储介质,其上存储有交互式抠图程序,该交互式抠图程序被处理器执行时实现上述的交互式抠图方法。
为达到上述目的,本发明第三方面实施例提出了一种计算机设备,包括存储器、处理 器及存储在存储器上并可在处理器上运行的交互式抠图程序,其中,所述处理器执行所述交互式抠图程序时,实现上述的交互式抠图方法。
附图说明
图1为根据本发明实施例的交互式抠图方法的流程示意图;
图2为根据本发明另一实施例的交互式抠图方法的流程示意图;
图3为根据本发明又一实施例的交互式抠图方法的流程示意图;
图4为根据本发明实施例的为每个未知区域像素选取总体代价函数值最小的采样对的方法的流程示意图。
具体实施方式
下面详细描述本发明的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,旨在用于解释本发明,而不能理解为对本发明的限制。
在现有的抠图方法中,其使用的采样方法大多非常复杂,需要操作人员掌握丰富的PS技术和颜色通道知识,对于初学者而言难以操作;本发明实施例提出的交互式抠图方法,首先,获取原始图像;接着,采用人机交互的方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对;然后,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域;接着,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;然后,根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并根据每个未知区域像素所对应的alpha值对alpha蒙版图像进行处理以获得最终alpha蒙版图像;从而实现通过与用户之间的简单交互进行采样对和未知区域的确定,进而根据采样对计算未知区域像素的alpha值,使得用户可无需掌握丰富的PS技术和颜色通道知识,即可完成对头发边缘的精确抠图。
为了更好的理解上述技术方案,下面将参照附图更详细地描述本发明的示例性实施例。虽然附图中显示了本发明的示例性实施例,然而应当理解,可以以各种形式实现本发明而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本发明,并且能够将本发明的范围完整的传达给本领域的技术人员。
为了更好的理解上述技术方案,下面将结合说明书附图以及具体的实施方式对上述技术方案进行详细的说明。
图1为根据本发明实施例提出的交互式抠图方法的流程示意图,如图1所示,该交互式抠图方法包括以下步骤:
S101,获取原始图像。
也就是说,获取待处理的原始图像数据。
S102,采用人机交互的方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对。
也就是说,采用人机交互的方式对原始图像中处于头发边缘的前景区域进行前景样本点采集,以获得前景样本空间;对原始图像中处于头发边缘的背景区域进行背景样本点采集,以获得背景样本空间;其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对。
作为一种示例,获得前景样本空间和背景样本空间具体可包括:接收用户输入的第一样本点采集指令,并根据第一样本点采集指令对原始图像的头发边缘前景区域进行前景样本点采集以获得多个前景样本点,其中,多个前景样本点构成前景样本空间;接收用户输入的第二样本点采集指令,并根据第二样本点采集指令对原始图像的头发边缘背景区域进行背景样本点采集以获得多个背景样本点,其中多个背景样本点构成背景样本空间。
以实际场景进行举例说明,通过人机交互的方式获取用户的前景样本点采集指令,以获取原始图像中处于头发边缘前景区域的前景样本点F 1、F 2、F 3、……F a,并以a个前景样本点构成前景样本空间F;通过人机交互的方式获取用户的背景样本点采集指令,以获取原始图像中处于头发边缘背景区域的背景样本点B 1、B 2、B 3、……B b,并以b个背景样本点构成背景样本空间B;然后,以任意一个前景样本点以及任意一个背景样本点构成采样对(F i,B j)。
S103,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域。
也就是说,在获得前景样本空间和背景样本空间,并根据前景样本点和背景样本点构成采样对之后,接收用户输入的针对原始图像的标记操作指令,并根据该标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域。
其中,未知区域指的是因头发或者动物毛发的纤细、混乱,在抠图过程中难以将头发或者动物毛发与背景图像剥离的区域。
S104,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值。
也就是说,在标记出未知区域之后,遍历未知区域,以获得未知区域中的每个未知区域像素,并根据每个未知区域像素遍历所有前景样本采集点与背景样本采集点构成的采样对,以选取使得总体代价函数值最小的采样对,以及根据选取的采样对对应的未知区域像素的alpha值进行计算,以获得每个未知区域像素所对应的alpha值。
S105,根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并根据每个未知区域像素所对应的alpha值对alpha蒙版图像进行处理以获得最终alpha蒙版图像。
也就是说,在根据每个未知区域像素所对应的alpha值获得alpha蒙版图像之后,进一步地,根据每个未知区域像素所对应的alpha值对alpha蒙版图像进行处理,以对该alpha蒙版图像进行调整,以获得最终alpha蒙版图像,以使得根据最终alpha蒙版图像进行抠图的抠图结果更加的清晰。在一些实施例中,如图2所示,本发明实施例提出的交互式抠图方法包括以下步骤:
S201,获取原始图像。
S202,采用人机交互的方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对。
S203,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域。
S204,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值。
其中,上述步骤S201-步骤S204与步骤S101-步骤S104一致,在此不做赘述。
S205,根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并对alpha蒙版图像进行去噪处理以获得最终alpha蒙版图像。
也就是说,在获取到每个未知区域像素所对应的alpha值之后,根据每个未知区域像素所对应的alpha值生成alpha蒙版图像;然后,对alpha蒙版图像进行去噪,以获得最终的alpha蒙版图像。
其中,对alpha蒙版图像进行去噪的方式有多种。
作为一种示例,首先,获取与alpha蒙版图像Q对应的引导图像G,并计算以r为半径 的方型滤波器的自相关均值corr G和互相关均值corr GQ;接着,计算对于蒙版图像Q和引导图像G的自相关方差var G及互相关协方差cov GQ;然后,计算窗口线性变换系数,并根据该线性变换系数计算各线性变换系数均值,接着,根据引导图像G以及各线性变化系数均值生成最终的alpha蒙版图像。
在一些实施例中,如图3所示,本发明实施例提出的交互式抠图方法包括以下步骤:
S301,获取原始图像。
S302,采用人机交互的方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对。
S303,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域。
S304,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值。
其中,上述步骤S301-步骤S304与步骤S101-步骤S104一致,在此不做赘述。
S305,遍历未知区域像素,并判断每个未知区域像素所对应的alpha值和该未知区域像素四邻域像素所对应的alpha值是否均大于预设的阈值。
S306,如果是,则将该未知区域像素作为待处理像素。
作为一种示例,根据以下公式进行每个未知区域像素所对应的alpha值和该未知区域像素四邻域像素所对应的alpha值是否大于预设的阈值的判断:
Figure PCTCN2019102621-appb-000013
其中,
Figure PCTCN2019102621-appb-000014
表示任意一个未知区域像素对应的alpha值,或者该未知区域像素的四邻域像素所对应的alpha值,优选地,threshold的取值为0.8。
以此完成待处理像素的选取,以便后续对待处理像素所对应的alpha值进行调整,以提高最终蒙版图像的合理性。
S307,遍历待处理像素,并对每个待处理像素进行alpha值增强,以及根据增强后的待处理像素对应的alpha值生成最终蒙版图像。
也就是说,遍历待处理像素,并对每个待处理像素进行alpha值增强,以及根据增强后的待处理像素对应的alpha值生成最终蒙版图像;从而,可以降低待处理像素区域所对应的最终蒙版图像对于图像的影响程度,提高该区域最终抠图结果的清晰度。
其中,对每个待处理像素进行alpha值增强的方式可以有多种。
作为一种示例,根据以下公式进行每个待处理像素对应的alpha值的增强:
Figure PCTCN2019102621-appb-000015
其中,α表示所述待处理像素对应的alpha值增强后的值,
Figure PCTCN2019102621-appb-000016
表示所述待处理像素的原始alpha值。
S308,遍历待处理像素,并对待处理像素进行颜色渲染,以生成对应原始图像的彩色通道图像。
作为一种示例,根据以下公式进行对应原始图像的彩色通道图像的生成:
I_b=F i_b
I_g=F i_g
I_r=F i_r
其中,F i表示使得未知区域像素的总体代价函数值最小的前景样本颜色,F i_b表示F i中包含的蓝色通道值,F i_g表示F i中包含的绿色通道值,F i_r表示F i中包含的红色通道值,I_b表示未知区域像素在彩色通道图像中的蓝色通道值,I_g表示未知区域像素在彩色通道图像中的绿色通道值,I_r表示未知区域像素在彩色通道图像中的红色通道值。
S309,根据最终蒙版图像和彩色通道图像生成最终抠图结果。
综上所述,根据本发明实施例的交互式抠图方法,首先,获取原始图像;接着,采用人机交互的方式分别对原始图像的头发边缘前景区域进行前景样本点采集和对原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,前景样本空间中的前景样本点和背景样本空间中的背景样本点构成采样对;然后,接收用户输入的标记操作指令,并根据标记操作指令对原始图像的头发区域进行涂抹以标记出未知区域;接着,遍历未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;然后,根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并对alpha蒙版图像进行去噪处理以获得最终alpha蒙版图像;从而实现通过与用户之间的简单交互进行采样对和未知区域的确定,进而根据采样对计算未知区域像素的alpha值,使得用户可无需掌握丰富的PS技术和颜色通道知识,即可完成对头发边缘的精确抠图。
如图4所示,在一些实施例中,本发明实施例提出的交互式抠图方法中,根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,具体包括以下步骤:
S1,根据任意一个采样对对当前未知区域像素I给出预估alpha值
Figure PCTCN2019102621-appb-000017
也就是说,根据任意一个前景采样点和任意一个背景采样点构成的采样对对当前未知区域像素I进行alpha值
Figure PCTCN2019102621-appb-000018
的预估。
作为一种示例,该alpha值
Figure PCTCN2019102621-appb-000019
根据以下公式获得:
Figure PCTCN2019102621-appb-000020
其中,F i为该样本对中的前景样本点,B j为该样本对中的背景样本点。
S2,根据预估alpha值
Figure PCTCN2019102621-appb-000021
计算该采样对与当前未知区域像素I的符合度。
也就是说,在对当前未知区域像素I的alpha值
Figure PCTCN2019102621-appb-000022
进行预估之后,根据预估得到的alpha值
Figure PCTCN2019102621-appb-000023
计算该采样对与当前未知区域像素I的符合度。
作为一种示例,采样对与当前未知区域像素I的符合度根据以下公式获得:
Figure PCTCN2019102621-appb-000024
其中,ε c(F i,B j)为该采样对与当前未知区域像素I的符合度。
S3,计算当前未知区域像素I与该采样对中前景样本点的空间距离,并计算当前未知区域像素I与该采样对中背景样本点的空间距离。
也就是说,在计算采样对与当前未知区域像素I的符合度之后,计算当前未知区域像素I与该采样对中前景样本点F i的空间距离,并计算当前未知区域像素I与该采样对中背景样本点B j的空间距离。
作为一种示例,当前未知区域像素I与该采样对中前景样本点的空间距离根据以下公式获得:
Figure PCTCN2019102621-appb-000025
其中,ε s(F i)为当前未知区域像素I与该采样对中前景样本点的空间距离,
Figure PCTCN2019102621-appb-000026
为该采样对中前景样本点的空间位置,X I为当前未知区域像素I的空间位置。
作为一种示例,当前未知区域像素I与该采样对中背景样本点的空间距离根据以下公式获得:
Figure PCTCN2019102621-appb-000027
其中,ε s(B j)为当前未知区域像素I与该采样对中背景样本点的空间距离,
Figure PCTCN2019102621-appb-000028
为该采样对中背景样本点的空间位置。
S4,根据该采样对与当前未知区域像素I的符合度、当前未知区域像素I与该采样对中前 景样本点的空间距离、当前未知区域像素I与该采样对中背景样本点的空间距离计算总体代价函数值。
也就是说,计算出采样对与当前未知区域像素I的符合度、当前未知区域像素I与该采样对中前景样本点的空间距离、当前未知区域像素I与该采样对中背景样本点的空间距离之后;根据计算得到的采样对与当前未知区域像素I的符合度、当前未知区域像素I与该采样对中前景样本点的空间距离、当前未知区域像素I与该采样对中背景样本点的空间距离进行总体代价函数值的计算。
作为一种示例,该采样对的总体代价函数值根据以下公式获得:
ε(F i,B j)=ε c(F i,B j)+w 1s(F i)+w 2s(B j)
其中,ε(F i,B j)为该采样对的总体代价函数值,w 1为空间距离代价函数ε s(F i)的权重,w 2为空间距离代价函数ε s(B j)的权重。
S5,重复执行步骤S1-S4,获得当前未知区域像素I对应的所有采样对的总体代价函数值,以为当前未知区域像素选取总体代价函数值最小的采样对。
也就是说,对步骤S1-S4进行重复执行,以获得当前未知区域像素I所对应的所有采样对的总体代价函数值,并根据所有采样对的总体代价函数值选取令当前未知区域像素I对应的总体代价函数值为最小值的采样对。
综上所述,根据本发明实施例提出的交互式抠图方法,首先,根据任意一个采样对对当前未知区域像素I给出预估alpha值
Figure PCTCN2019102621-appb-000029
接着,根据预估alpha值
Figure PCTCN2019102621-appb-000030
计算该采样对与当前未知区域像素I的符合度;然后,计算当前未知区域像素I与该采样对中前景样本点的空间距离,并计算当前未知区域像素I与该采样对中背景样本点的空间距离;接着,根据该采样对与当前未知区域像素I的符合度、当前未知区域像素I与该采样对中前景样本点的空间距离、当前未知区域像素I与该采样对中背景样本点的空间距离计算总体代价函数值;然后,迭代执行上述步骤,获得当前未知区域像素I对应的所有采样对的总体代价函数值,以为当前未知区域像素选取总体代价函数值最小的采样对;从而实现根据前景采样点和背景采样点构成的采样对和未知区域像素进行最小总体代价函数值对应的采样对的确定,为后续计算未知区域像素对应的alpha值提供依据。
为了实现上述实施例,本发明实施例还提出了一种计算机可读存储介质,其上存储有交互式抠图程序,该交互式抠图程序被处理器执行时实现上述的交互式抠图方法。
根据本发明实施例的计算机可读存储介质,通过存储交互式抠图程序,以使得处理器在执行该程序时能够实现如上述的交互式抠图方法,从而实现根据前景采样点和背景采样点构成的采样对和未知区域像素进行最小总体代价函数值对应的采样对的确定,为后续计 算未知区域像素对应的alpha值提供依据。
为了实现上述实施例,本发明实施例提出了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的交互式抠图程序,其中,所述处理器执行所述交互式抠图程序时,实现上述的交互式抠图方法。
根据本发明实施例的计算机设备,通过存储器存储可在处理器上运行的交互式抠图程序,从而,处理器在执行该交互式抠图程序时,可实现如上述的交互式抠图方法,从而实现根据前景采样点和背景采样点构成的采样对和未知区域像素进行最小总体代价函数值对应的采样对的确定,为后续计算未知区域像素对应的alpha值提供依据。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
应当注意的是,在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的部件或步骤。位于部件之前的单词“一”或“一个”不排除存在多个这样的部件。本发明可以借助于包括有若干不同部件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使 用不表示任何顺序。可将这些单词解释为名称。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。
在本发明的描述中,需要理解的是,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本发明的描述中,“多个”的含义是两个或两个以上,除非另有明确具体的限定。
在本发明中,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”、“固定”等术语应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或成一体;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。
在本发明中,除非另有明确的规定和限定,第一特征在第二特征“上”或“下”可以是第一和第二特征直接接触,或第一和第二特征通过中间媒介间接接触。而且,第一特征在第二特征“之上”、“上方”和“上面”可是第一特征在第二特征正上方或斜上方,或仅仅表示第一特征水平高度高于第二特征。第一特征在第二特征“之下”、“下方”和“下面”可以是第一特征在第二特征正下方或斜下方,或仅仅表示第一特征水平高度小于第二特征。
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不应理解为必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。
尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。

Claims (14)

  1. 一种交互式抠图方法,其特征在于,包括以下步骤:
    获取原始图像;
    采用人机交互的方式分别对所述原始图像的头发边缘前景区域进行前景样本点采集和对所述原始图像的头发边缘背景区域进行背景样本点采集,以相应获得前景样本空间和背景样本空间,其中,所述前景样本空间中的前景样本点和所述背景样本空间中的背景样本点构成采样对;
    接收用户输入的标记操作指令,并根据所述标记操作指令对所述原始图像的头发区域进行涂抹以标记出未知区域;
    遍历所述未知区域以获得每个未知区域像素,并根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,以及根据选取的采样对计算每个未知区域像素所对应的alpha值;
    根据每个未知区域像素所对应的alpha值获得alpha蒙版图像,并根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像。
  2. 如权利要求1所述的交互式抠图方法,其特征在于,获得前景样本空间和背景样本空间,包括:
    接收用户输入的第一样本点采集指令,并根据所述第一样本点采集指令对所述原始图像的头发边缘前景区域进行前景样本点采集以获得多个前景样本点,其中,所述多个前景样本点构成所述前景样本空间;
    接收用户输入的第二样本点采集指令,并根据所述第二样本点采集指令对所述原始图像的头发边缘背景区域进行背景样本点采集以获得多个背景样本点,其中,所述多个背景样本点构成所述背景样本空间。
  3. 如权利要求1或2所述的交互式抠图方法,其特征在于,根据每个未知区域像素遍历所有采样对以为每个未知区域像素选取总体代价函数值最小的采样对,包括:
    S1,根据任意一个采样对对当前未知区域像素I给出预估alpha值
    Figure PCTCN2019102621-appb-100001
    S2,根据所述预估alpha值
    Figure PCTCN2019102621-appb-100002
    计算该采样对与所述当前未知区域像素I的符合度;
    S3,计算所述当前未知区域像素I与该采样对中前景样本点的空间距离,并计算所述当前未知区域像素I与该采样对中背景样本点的空间距离;
    S4,根据该采样对与所述当前未知区域像素I的符合度、所述当前未知区域像素I与该采样对中前景样本点的空间距离、所述当前未知区域像素I与该采样对中背景样本点的空间距离计算总体代价函数值;
    重复执行步骤S1-S4,获得所述当前未知区域像素I对应的所有采样对的总体代价函数值,以为所述当前未知区域像素选取总体代价函数值最小的采样对。
  4. 如权利要求3所述的交互式抠图方法,其特征在于,所述预估alpha值
    Figure PCTCN2019102621-appb-100003
    根据以下公式获得:
    Figure PCTCN2019102621-appb-100004
    其中,F i为该样本对中的前景样本点,B j为该样本对中的背景样本点。
  5. 如权利要求4所述的交互式抠图方法,其特征在于,该采样对与所述当前未知区域像素I的符合度根据以下公式获得:
    Figure PCTCN2019102621-appb-100005
    其中,ε c(F i,B j)为该采样对与所述当前未知区域像素I的符合度。
  6. 如权利要求5所述的交互式抠图方法,其特征在于,所述当前未知区域像素I与该采样对中前景样本点的空间距离根据以下公式获得:
    Figure PCTCN2019102621-appb-100006
    其中,ε s(F i)为所述当前未知区域像素I与该采样对中前景样本点的空间距离,
    Figure PCTCN2019102621-appb-100007
    为该采样对中前景样本点的空间位置,X I为所述当前未知区域像素I的空间位置。
  7. 如权利要求6所述的交互式抠图方法,其特征在于,所述当前未知区域像素I与该采样对中背景样本点的空间距离根据以下公式获得:
    Figure PCTCN2019102621-appb-100008
    其中,ε s(B j)为所述当前未知区域像素I与该采样对中背景样本点的空间距离,
    Figure PCTCN2019102621-appb-100009
    为该采样对中背景样本点的空间位置。
  8. 如权利要求7所述的交互式抠图方法,其特征在于,该采样对的总体代价函数值根据以下公式获得:
    ε(F i,B j)=ε c(F i,B j)+w 1s(F i)+w 2s(B j)
    其中,ε(F i,B j)为该采样对的总体代价函数值,w 1为空间距离代价函数ε s(F i)的权重,w 2为空间距离代价函数ε s(B j)的权重。
  9. 如权利要求1所述的交互式抠图方法,其特征在于,根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像,包括:
    根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行去噪处理以获得最终alpha蒙版图像。
  10. 如权利要求1所述的交互式抠图方法,其特征在于,根据每个未知区域像素所对应的alpha值对所述alpha蒙版图像进行处理以获得最终alpha蒙版图像,包括:
    遍历所述未知区域像素,并判断每个未知区域像素所对应的alpha值和该未知区域像素四邻域像素所对应的alpha值是否均大于预设的阈值;
    如果是,则将该未知区域像素作为待处理像素;
    遍历所述待处理像素,并对每个待处理像素进行alpha值增强,以及根据增强后的待处理像素对应的alpha值生成最终蒙版图像。
  11. 如权利要求10所述的交互式抠图方法,其特征在于,根据以下公式进行每个待处理像素对应的alpha值的增强:
    Figure PCTCN2019102621-appb-100010
    其中,α表示所述待处理像素对应的alpha值增强后的值,
    Figure PCTCN2019102621-appb-100011
    表示所述待处理像素的原始alpha值。
  12. 如权利要求10所述的交互式抠图方法,其特征在于,还包括:
    遍历所述待处理像素,并对所述待处理像素进行颜色渲染,以生成对应所述原始图像的彩色通道图像;
    根据所述最终蒙版图像和所述彩色通道图像生成最终抠图结果。
  13. 一种计算机可读存储介质,其特征在于,其上存储有交互式抠图程序,该交互式抠图程序被处理器执行时实现如权利要求1-12中任一项所述的交互式抠图方法。
  14. 一种计算机设备,其特征在于,包括存储器、处理器及存储在存储器上并可在处理器上运行的交互式抠图程序,其中,所述处理器执行所述交互式抠图程序时,实现如权利要求1-12中任一项所述的交互式抠图方法。
PCT/CN2019/102621 2018-08-26 2019-08-26 交互式抠图方法、介质及计算机设备 WO2020043063A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/929,139 US11443436B2 (en) 2018-08-26 2020-07-15 Interactive image matting method, computer readable memory medium, and computer device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810997105.7 2018-08-26
CN201810997105.7A CN109389611A (zh) 2018-08-29 2018-08-29 交互式抠图方法、介质及计算机设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/929,139 Continuation US11443436B2 (en) 2018-08-26 2020-07-15 Interactive image matting method, computer readable memory medium, and computer device

Publications (1)

Publication Number Publication Date
WO2020043063A1 true WO2020043063A1 (zh) 2020-03-05

Family

ID=65418427

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/102621 WO2020043063A1 (zh) 2018-08-26 2019-08-26 交互式抠图方法、介质及计算机设备

Country Status (3)

Country Link
US (1) US11443436B2 (zh)
CN (1) CN109389611A (zh)
WO (1) WO2020043063A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109389611A (zh) 2018-08-29 2019-02-26 稿定(厦门)科技有限公司 交互式抠图方法、介质及计算机设备
CN112740263A (zh) * 2018-09-25 2021-04-30 索尼公司 图像处理装置、图像处理方法和程序
CN110400323B (zh) * 2019-07-30 2020-11-24 上海艾麒信息科技股份有限公司 一种自动抠图系统、方法以及装置
CN110689488B (zh) * 2019-08-22 2022-03-04 稿定(厦门)科技有限公司 图像调色方法、介质、设备及装置
CN110751654B (zh) * 2019-08-30 2022-06-28 稿定(厦门)科技有限公司 图像抠图方法、介质、设备及装置
CN112712459B (zh) * 2019-10-24 2023-09-19 抖音视界有限公司 抠图方法及装置
CN111161288B (zh) * 2019-12-26 2023-04-14 郑州阿帕斯数云信息科技有限公司 图像处理方法和装置
CN113961854B (zh) * 2021-09-14 2022-10-14 稿定(厦门)科技有限公司 页面着色方法及装置以及计算机可读存储介质
CN114677394B (zh) * 2022-05-27 2022-09-30 珠海视熙科技有限公司 抠图方法、装置、摄像设备、会议系统、电子设备及介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103177446A (zh) * 2013-03-13 2013-06-26 北京航空航天大学 基于邻域和非邻域平滑先验的图像前景精准提取方法
CN104504745A (zh) * 2015-01-16 2015-04-08 成都品果科技有限公司 一种基于图像分割和抠图的证件照生成方法
CN105809666A (zh) * 2014-12-30 2016-07-27 联芯科技有限公司 图像抠图方法及装置
CN106846336A (zh) * 2017-02-06 2017-06-13 腾讯科技(上海)有限公司 提取前景图像、替换图像背景的方法及装置
US20170278246A1 (en) * 2016-03-22 2017-09-28 Electronics And Telecommunications Research Institute Apparatus and method for extracting object
CN107516319A (zh) * 2017-09-05 2017-12-26 中北大学 一种高精度简易交互式抠图方法、存储设备及终端
CN109389611A (zh) * 2018-08-29 2019-02-26 稿定(厦门)科技有限公司 交互式抠图方法、介质及计算机设备

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060239548A1 (en) * 2005-03-03 2006-10-26 George Gallafent William F Segmentation of digital images
CN102147852B (zh) * 2010-02-04 2016-01-27 三星电子株式会社 检测头发区域的方法
US8386964B2 (en) * 2010-07-21 2013-02-26 Microsoft Corporation Interactive image matting
US8884980B2 (en) * 2010-09-24 2014-11-11 Taaz, Inc. System and method for changing hair color in digital images
US8855411B2 (en) * 2011-05-16 2014-10-07 Microsoft Corporation Opacity measurement using a global pixel set
CN102651135B (zh) * 2012-04-10 2015-06-17 电子科技大学 一种基于优化方向采样的自然图像抠图方法
US10089740B2 (en) * 2014-03-07 2018-10-02 Fotonation Limited System and methods for depth regularization and semiautomatic interactive matting using RGB-D images
CN104820990A (zh) * 2015-05-15 2015-08-05 北京理工大学 一种交互式图像抠图系统
US10607318B2 (en) * 2016-12-30 2020-03-31 Facebook, Inc. Systems and methods for image matting
US10650524B2 (en) * 2017-02-03 2020-05-12 Disney Enterprises, Inc. Designing effective inter-pixel information flow for natural image matting
US10380723B2 (en) * 2017-06-19 2019-08-13 Adobe Inc. Editing dynamically selected portions of target images in a mask-based editing interface

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103177446A (zh) * 2013-03-13 2013-06-26 北京航空航天大学 基于邻域和非邻域平滑先验的图像前景精准提取方法
CN105809666A (zh) * 2014-12-30 2016-07-27 联芯科技有限公司 图像抠图方法及装置
CN104504745A (zh) * 2015-01-16 2015-04-08 成都品果科技有限公司 一种基于图像分割和抠图的证件照生成方法
US20170278246A1 (en) * 2016-03-22 2017-09-28 Electronics And Telecommunications Research Institute Apparatus and method for extracting object
CN106846336A (zh) * 2017-02-06 2017-06-13 腾讯科技(上海)有限公司 提取前景图像、替换图像背景的方法及装置
CN107516319A (zh) * 2017-09-05 2017-12-26 中北大学 一种高精度简易交互式抠图方法、存储设备及终端
CN109389611A (zh) * 2018-08-29 2019-02-26 稿定(厦门)科技有限公司 交互式抠图方法、介质及计算机设备

Also Published As

Publication number Publication date
US20200349716A1 (en) 2020-11-05
CN109389611A (zh) 2019-02-26
US11443436B2 (en) 2022-09-13

Similar Documents

Publication Publication Date Title
WO2020043063A1 (zh) 交互式抠图方法、介质及计算机设备
KR101854554B1 (ko) 건축물 높이 산출 방법, 장치 및 저장 매체
JP2018514024A5 (zh)
WO2020258899A1 (zh) 一种基于高分遥感影像的山地景观建筑提取方法和设备
CN102722891B (zh) 一种图像显著度检测的方法
JP5333635B1 (ja) 画像処理装置、プログラム及び画像処理システム
CN108510491B (zh) 虚化背景下人体骨骼关键点检测结果的过滤方法
CN104504745B (zh) 一种基于图像分割和抠图的证件照生成方法
KR20120069331A (ko) 영상의 전경과 배경을 분리하는 방법
CN109410171B (zh) 一种用于雨天图像的目标显著性检测方法
CN101710418B (zh) 基于测地距离的交互方式图象分割方法
CN111414954B (zh) 一种岩石图像检索方法及其系统
WO2018090355A1 (zh) 图像自动裁剪方法
WO2016062259A1 (zh) 基于透明度的抠图方法和装置
CN105809673B (zh) 基于surf算法和合并最大相似区域的视频前景分割方法
US9715729B2 (en) Method and apparatus for processing block to be processed of urine sediment image
Sadiq et al. Edge detection: A collection of pixel based approach for colored images
CN110598795A (zh) 图像差异检测方法及装置、存储介质、终端
CN110111342B (zh) 一种抠图算法的优化选取方法及装置
CN104392209B (zh) 一种目标与背景的图像复杂度评价方法
CN110751654A (zh) 图像抠图方法、介质、设备及装置
CN106204596B (zh) 一种基于高斯拟合函数与模糊混合估计的全色波段遥感影像云检测方法
CN109472785B (zh) 基于多结构元素震害受损建筑物快速识别方法
CN103985113A (zh) 舌像分割方法
CN105956559B (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: 19855251

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: 19855251

Country of ref document: EP

Kind code of ref document: A1