WO2016062259A1 - 基于透明度的抠图方法和装置 - Google Patents

基于透明度的抠图方法和装置 Download PDF

Info

Publication number
WO2016062259A1
WO2016062259A1 PCT/CN2015/092537 CN2015092537W WO2016062259A1 WO 2016062259 A1 WO2016062259 A1 WO 2016062259A1 CN 2015092537 W CN2015092537 W CN 2015092537W WO 2016062259 A1 WO2016062259 A1 WO 2016062259A1
Authority
WO
WIPO (PCT)
Prior art keywords
pixel
original image
image
target pixel
transparency
Prior art date
Application number
PCT/CN2015/092537
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 WO2016062259A1 publication Critical patent/WO2016062259A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis

Definitions

  • Embodiments of the present invention relate to image processing technologies, and in particular, to a transparency-based mapping method and apparatus.
  • the mapping technique is an image processing technique that separates the foreground portion of an arbitrary image from the background. It has extensive and in-depth applications in magazine cover, illustration design, advertising and film creation. There are many ways to map, among which the most widely used is alpha map technology.
  • the color of each pixel in a natural image is a linear combination of the foreground color and the background color of the point, and the linear coefficient represents the proportion of the foreground color in the color of the point.
  • the value varies between [0, 1].
  • the specific relationship is shown in formula (1.1):
  • I represents the color value of the point
  • F and B represent the foreground color value and the background color value of the point, respectively
  • is a coefficient of linear combination, indicating the transparency of the point.
  • the alpha value calculated according to formula (1.1) is not unique to any point on the image. Therefore, it is very important to find the most reasonable solution from the innumerable solution.
  • the most reasonable alpha value is generally determined by a color-clustering mapping algorithm.
  • the color-clustering algorithm by using the K Nearest Neighbor (KNN) algorithm for each pixel in the image, the most relevant pixel is found, and the "color ball model” is used to build the model.
  • KNN K Nearest Neighbor
  • Embodiments of the present invention provide a method and apparatus for mapping based on transparency, which are used to reduce the error of the map and improve the effect of the map.
  • an embodiment of the present invention provides a transparency-based mapping method, including:
  • a global pixel or a local pixel as a neighboring pixel of a target pixel in the original image; wherein the global pixel is a pixel obtained according to a global search algorithm in an original image, where the local pixel is in original a pixel obtained from a local search algorithm in an image;
  • the performing edge detection on the original image includes:
  • the global pixel or the local pixel is used as a target in the original image according to the detection result
  • the neighboring pixels of the pixel include:
  • the global pixel is used as the neighboring pixel of the target pixel in the original image
  • a local pixel is used as the neighboring pixel of the target pixel in the original image.
  • the global pixel or the local pixel is used as a target in the original image according to the detection result
  • the neighboring pixels of the pixel include:
  • the destination neighbor pixel is a local pixel
  • the second preset number of neighbor pixels is a global pixel
  • the The neighboring pixel obtains the transparency value ⁇ of the target pixel in the original image, which specifically includes:
  • the obtaining the Laplacian matrix L according to the original image and the neighboring pixels includes:
  • I is the original image
  • k is the target pixel
  • i and j are two different pixel points in the set of neighboring pixels
  • N k is a set of the neighboring pixels
  • u k is the neighboring pixel
  • ⁇ k is the covariance matrix of all pixels in the set of neighboring pixels
  • auxiliary image Obtaining the auxiliary image, and marking the background of the auxiliary image with black, the foreground is marked with white, and the other portions are marked with gray to obtain the labeled auxiliary image;
  • the method further includes:
  • an embodiment of the present invention provides a transparency-based mapping device, including:
  • a detection module configured to acquire an original image to be mapped, perform edge detection on the original image, and obtain a detection result
  • a processing module configured to use a global pixel or a local pixel as a neighboring pixel of a target pixel in the original image according to the detection result; wherein the global pixel is a pixel obtained according to a global search algorithm in an original image, the local part The pixel is a pixel obtained according to a local search algorithm in the original image;
  • a first acquiring module configured to obtain, according to the original image and the neighboring pixel, a transparency value ⁇ of a target pixel in the original image, and extract a target object in the original image according to the transparency value.
  • the detecting module includes:
  • an acquiring unit configured to convert the original image into a grayscale image, perform Laplacian filtering and mean filtering processing on the grayscale image, to obtain an edge detection image.
  • the processing module further includes:
  • a determining unit configured to determine whether a pixel value of the target pixel in the edge detection image is greater than a preset threshold; wherein, the target pixel in the edge detection image is in the original image Corresponding to the target pixel;
  • the global pixel is used as the neighboring pixel of the target pixel in the original image
  • a local pixel is used as the neighboring pixel of the target pixel in the original image.
  • the processing module further includes:
  • a determining unit configured to determine, in the plurality of neighboring pixels of the target pixel in the original image, that the first preset number of neighboring pixels are local pixels, and the second predetermined number of neighboring pixels are global pixels.
  • the first acquiring module includes:
  • a Laplacian matrix L acquiring unit configured to obtain a Laplacian matrix L according to the original image and the neighboring pixels;
  • a first objective function acquisition unit configured to construct a first objective function regarding transparency of the target pixel according to the Laplacian matrix L and the acquired auxiliary image:
  • J( ⁇ ) ⁇ T L ⁇ + ⁇ ( ⁇ -b s ) T D s ( ⁇ -b s );
  • is the transparency value
  • is the preset parameter
  • D s is the matrix of N*N
  • N is The number of pixels in the auxiliary image
  • b s is a vector of N*1
  • N is an integer greater than 0;
  • a transparency value obtaining unit configured to obtain a transparency value ⁇ of the target pixel according to the first objective function.
  • the Laplacian matrix L acquiring unit is specifically configured to:
  • I is the original image
  • k is the target pixel
  • i and j are two different pixel points in the set of neighboring pixels
  • N k is a set of the neighboring pixels
  • u k is the neighboring pixel
  • ⁇ k is the covariance matrix of all pixels in the set of neighboring pixels
  • the first target function acquiring unit Specifically for:
  • auxiliary image Obtaining the auxiliary image, and marking the background of the auxiliary image with black, the foreground is marked with white, and the other portions are marked with gray to obtain the labeled auxiliary image;
  • the transparency-based mapping method and device obtains a detection result by performing edge detection on an original image by acquiring an original image to be mapped; and using a global pixel or a local pixel as a neighbor of a target pixel in the original image according to the detection result.
  • a pixel wherein the global pixel is a pixel obtained according to a global search algorithm in the original image, the local pixel is a pixel obtained according to a local search algorithm in the original image; and a transparency value ⁇ of the target pixel in the original image is obtained according to the original image and the neighbor pixel , according to the obtained transparency value, the target object is extracted in the original image. Because the edge detection is performed on the original image, the neighboring pixels of the target pixel in the original image are obtained by the global search mode or the local search according to the detection result, thereby reducing the mapping error and improving the mapping effect.
  • Embodiment 1 is a schematic flow chart of Embodiment 1 of a transparency-based mapping method according to the present invention
  • Embodiment 2 is a schematic flow chart of Embodiment 2 of a transparency-based mapping method according to the present invention
  • Embodiment 3 is a schematic flow chart of Embodiment 3 of a transparency-based mapping method according to the present invention.
  • Embodiment 4 is a schematic structural view of Embodiment 1 of a transparency-based mapping device according to the present invention.
  • FIG. 5 is a schematic structural diagram of Embodiment 2 of a transparency-based mapping device according to the present invention.
  • Embodiment 1 is a schematic flowchart of Embodiment 1 of a transparency-based mapping method according to the present invention.
  • the embodiment of the present invention provides a transparency-based mapping method, which may be performed by any device that performs a transparency-based mapping method.
  • the device may be a variety of terminal devices, such as a personal computer (PC), a mobile phone, a PAD, various servers, etc., and may be implemented by software and/or hardware.
  • the method in this embodiment may include:
  • Step 101 Acquire an original image to be mapped, perform edge detection on the original image, and obtain a detection result.
  • an edge detection image is obtained.
  • the edge detection image is characterized in that if some edge portions in the original image are more complicated, the pixel points of the corresponding edge portion in the edge detection image are grayish white; if some regions in the original image are Smoother, then in the edge detection image The pixel of this partial area should be black.
  • Step 102 Depending on the detection result, the global pixel or the local pixel is a neighbor pixel of the target pixel in the original image; wherein, the global pixel is a pixel obtained according to a global search algorithm in the original image, and the local pixel is a local search in the original image.
  • the pixels obtained by the algorithm are a global search algorithm in the original image.
  • edge detection is performed on the original image.
  • a global search algorithm or a local search algorithm may be selected according to the characteristics of the edge detection image to obtain a global pixel or a local pixel as a neighbor pixel of the target pixel.
  • the global search algorithm may be, for example, a KNN algorithm
  • the local search algorithm may be, for example, a variable neighborhood search algorithm.
  • the embodiment does not particularly limit this.
  • Step 103 Obtain a transparency value ⁇ of the target pixel in the original image according to the original image and the neighboring pixels, and extract the target object in the original image according to the transparency value.
  • the transparency value of the target pixel in the original image is calculated according to the original image and the acquired neighboring pixels, and then the target object can be extracted in the original image according to the obtained transparency value.
  • the target object can be obtained by multiplying the transparency value ⁇ by the input image.
  • different methods may be selected according to actual needs, and this embodiment does not particularly limit this.
  • the transparency-based mapping method obtains the detection result by performing edge detection on the original image by acquiring the original image to be mapped; and using the global pixel or the local pixel as the neighboring pixel of the target pixel according to the detection result, wherein
  • the global pixel is a pixel obtained according to a global search algorithm in the original image
  • the local pixel is a pixel obtained according to a local search algorithm in the original image
  • the transparency value ⁇ of the target pixel in the original image is obtained according to the original image and the neighbor pixel, according to the obtained The transparency value of the target object in the original image. Because the edge detection is performed on the original image, whether the neighboring pixels of the target pixel in the original image are acquired by the global search mode or the local search mode is selected according to the detection result, thereby reducing the mapping error and improving the mapping effect.
  • FIG. 2 is a schematic flowchart of a second embodiment of a transparency-based mapping method according to the present invention.
  • the edge detection is performed on the original image, and the global pixel is detected according to the detection result.
  • the local pixel as an embodiment of the neighboring pixel of the target pixel in the original image will be described in detail.
  • the method of this embodiment may include:
  • Step 201 Convert the original image into a grayscale image, perform Laplacian filtering and mean filtering processing on the grayscale image, and obtain an edge detection image.
  • a 3*3 Laplacian filtering is performed on the grayscale image, and an edge detection result of the original image can be obtained. Specifically, by convolving the grayscale image and the Laplacian, That is, an image showing the edge information of the original image can be obtained. In order to remove the noise that may be contained in the detection result, a 3*3 mean filtering of the obtained edge detection result may also be performed.
  • Step 202 Determine whether a pixel value of the target pixel in the edge detection image is greater than a preset threshold; wherein the target pixel in the edge detection image corresponds to the target pixel in the original image.
  • step 203 if the pixel value is greater than the preset threshold, step 203 is performed; otherwise, step 204 is performed.
  • the size of the preset threshold may be selected according to actual experience, for example, 0.001 or the like.
  • the embodiment is not particularly limited herein.
  • the original image is subjected to edge detection processing, and after the edge detection image is obtained, the target pixel in the original image becomes the target pixel in the edge detection image.
  • the target pixel in the edge detection image becomes the target pixel in the edge detection image.
  • R is red
  • G is green
  • B is blue
  • x is the abscissa of the target pixel in the original image
  • y is the ordinate of the target pixel in the original image
  • d R is the gradient value of the red channel
  • d G For the gradient value of the green channel
  • d B is the gradient value of the blue channel
  • ctr is the pixel value of the target pixel in the edge detection image.
  • Step 203 Adopt global pixels as neighbor pixels of target pixels in the original image.
  • the pixel value of the target pixel in the edge detection image is greater than a preset threshold, it indicates that the color of the target pixel is grayish white, indicating that the target image is in the original image.
  • the image around the prime is more complicated or may contain various textures.
  • the global search algorithm is needed to find the relevant pixel that is the most similar to the target pixel as the neighboring pixel of the target pixel, so as to better process the image.
  • the KNN algorithm is taken as an example for detailed description.
  • the KNN algorithm After obtaining the original image, performing edge detection on the original image to obtain a pixel value of the target pixel in the edge detection image. If the pixel value is greater than a preset threshold, the KNN algorithm is used to compare the original image in the predefined F s feature space. Search and sort, select the first K pixels as the neighbor pixels of the target pixel in the original image.
  • Step 204 Using a local pixel as a neighboring pixel of a target pixel in the original image.
  • the pixel value of the target pixel in the edge detection image is not greater than the preset threshold, it indicates that the color of the target pixel is black, indicating that the image around the target pixel is simple or smooth in the original image. It is considered that the pixel around the target pixel is the pixel most similar to the target pixel, so the neighboring pixel of the target pixel is selected by a local search algorithm to better process the image.
  • the original image After acquiring the original image, performing edge detection on the original image to obtain a pixel value of the target pixel in the edge detection image, and if the pixel value is less than a preset threshold, the original image is in the predefined F t feature space. Search and select the neighbor pixels of the target pixel in the original image.
  • the transparency-based mapping method performs edge detection on the original image, and determines whether the pixel value of the target pixel in the edge detection image is greater than a preset threshold, and selects a global pixel or a partial pixel as the original image according to the determination result.
  • the neighboring pixels of the target pixel thereby reducing the mapping error, thereby improving the effect of the map.
  • the first preset number of neighboring pixels may also be determined as a local pixel
  • the second preset number of neighboring pixels Is a global pixel.
  • the local pixel and the global pixel may be used as their neighboring pixels.
  • 9 local pixels and 9 global pixels may be simultaneously selected as neighbor pixels of the target pixel according to actual needs.
  • appropriate neighbor pixels can be selected according to experience or the complexity of an area of the image.
  • the embodiment is not particularly limited herein.
  • Embodiment 3 is a schematic flow chart of Embodiment 3 of a transparency-based mapping method according to the present invention.
  • the present embodiment is based on a transparency-based mapping method embodiment 1 and a transparency-based mapping method embodiment 2, based on an original image and An embodiment in which the neighboring pixels obtain the transparency value ⁇ of the target pixel will be described in detail.
  • the method in this embodiment may include:
  • Step 301 Acquire an original image to be mapped, perform edge detection on the original image, and obtain a detection result.
  • Step 302 Depending on the detection result, the global pixel or the local pixel is a neighboring pixel of the target pixel in the original image; wherein, the global pixel is a pixel obtained according to a global search algorithm in the original image, and the local pixel is a local search in the original image.
  • the pixels obtained by the algorithm are a global search algorithm in the original image.
  • Step 301 - Step 302 is similar to Step 101 - Step 102, and details are not described herein again.
  • Step 303 Obtain a Laplacian matrix L according to the original image and the neighboring pixels.
  • the adjacency matrix is first obtained according to the obtained original image and the selected neighboring pixels.
  • the adjacency matrix is a matrix representing the adjacent relationship between the vertices.
  • the adjacency matrix W can be obtained according to formula (1):
  • I is the original image
  • k is the target pixel
  • i and j are two different pixel points in the set of neighboring pixels
  • N k is the set of neighboring pixels
  • u k is the mean of all pixels in the set of neighboring pixels
  • ⁇ k is The covariance matrix of all pixels in the set of neighboring pixels.
  • the Laplacian matrix L can be calculated according to the formula (2):
  • a second objective function regarding the transparency of the target pixel is constructed based on the obtained Laplacian matrix L:
  • the auxiliary image is a grayscale image, which is a rough division of the original image, that is, the original image is divided into a foreground, a background and an unknown region, and the purpose thereof It is used to provide some prior knowledge about the foreground and background basic information in the original image.
  • the background of the auxiliary image is marked with black, the foreground is marked with white, and the other parts are marked with gray.
  • a first objective function for the transparency of the target pixel in the original image is constructed according to the constructed second objective function and the labeled auxiliary image:
  • ⁇ in the first objective function is a parameter for balancing ⁇ T L ⁇ and ( ⁇ -b s ) T D s ( ⁇ -b s ), and the value of ⁇ in this embodiment may be 1000 or 1500 according to actual needs. Wait.
  • an appropriate value of ⁇ can be selected according to experience.
  • D s is an N*N matrix with only 0 and 1 in the matrix, where 0 represents the pixel of the unknown region in the auxiliary image, and 1 represents the background and foreground pixels in the auxiliary image.
  • b s is a vector of N*1, and the vector only contains 0 and 1, where 0 represents the pixel of the background in the auxiliary image, and 1 represents the pixel of the foreground in the auxiliary image.
  • Step 305 Obtain a transparency value ⁇ of the target pixel in the original image according to the first objective function.
  • the transparency-based mapping method obtaineds the detection result by performing edge detection on the original image by acquiring the original image to be mapped; and using the global pixel or the local pixel as the target pixel in the original image according to the detection result.
  • the global pixel is a pixel obtained according to a global search algorithm in the original image
  • the local pixel is a pixel obtained according to a local search algorithm in the original image
  • the adjacency matrix W when constructing the Laplacian matrix L, may also be designed according to actual needs, and the principle of design is: the more similar two pixels in the original image, The larger the value in the adjacency matrix W, and the more unrelated the pixel, the smaller the value in the adjacency matrix W, and the Laplacian matrix L is constructed according to the designed adjacency matrix W.
  • the transparency-based mapping device provided by the embodiment of the present invention includes a detection module 401, a processing module 402, and a first acquisition module 403. .
  • the detecting module 401 is configured to obtain an original image to be mapped, perform edge detection on the original image, and obtain a detection result.
  • the processing module 402 is configured to use a global pixel or a local pixel as the original image according to the detection result. a neighboring pixel of the target pixel; wherein the global pixel is a pixel obtained according to a global search algorithm in the original image, the local pixel being a pixel obtained according to a local search algorithm in the original image; the first obtaining module 403 is configured to Obtaining a transparency value ⁇ of the target pixel in the original image according to the original image and the neighboring pixel, and extracting a target object in the original image according to the transparency value.
  • the transparency-based mapping device of the embodiment can be used for transparency-based mapping
  • the technical solution of the first embodiment is similar to the technical solution, and details are not described herein again.
  • FIG. 5 is a schematic structural diagram of a second embodiment of a transparency-based mapping device according to the present invention.
  • the detection module 401 includes:
  • the obtaining unit 4011 is configured to convert the original image into a grayscale image, perform Laplacian filtering and average filtering processing on the grayscale image, and obtain an edge detection image.
  • processing module 402 includes:
  • the determining unit 4021 is configured to determine whether a pixel value of the target pixel in the edge detection image is greater than a preset threshold
  • the global pixel is used as the neighboring pixel of the target pixel in the original image
  • a local pixel is used as the neighboring pixel of the target pixel in the original image.
  • processing module 402 further includes:
  • the determining unit 4022 is configured to determine, in the plurality of neighboring pixels of the target pixel in the original image, that the first preset number of neighboring pixels are local pixels, and the second predetermined number of neighboring pixels are global pixels.
  • the first obtaining module 403 includes:
  • a Laplacian matrix L acquiring unit 4031 is configured to obtain a Laplacian matrix L according to the original image and the neighboring pixels;
  • the Laplacian matrix L acquiring unit 4031 is specifically configured to:
  • I is the original image
  • k is the target pixel
  • i and j are two different pixel points in the set of neighboring pixels
  • N k is a set of the neighboring pixels
  • u k is the neighboring pixel
  • ⁇ k is the covariance matrix of all pixels in the set of neighboring pixels
  • the first target function acquiring unit 4032 is specifically configured to:
  • auxiliary image Obtaining the auxiliary image, and marking the background of the auxiliary image with black, the foreground is marked with white, and the other portions are marked with gray to obtain the labeled auxiliary image;
  • the device further includes:
  • the transparency-based mapping device of the present embodiment can be used to implement the technical solution of the transparency-based mapping method provided by any embodiment of the present invention, and the implementation principle and technical effects are similar, and details are not described herein again.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

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

Abstract

提供一种基于透明度的抠图方法和装置,该方法包括:获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果(101);根据检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素;其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素(102);根据原始图像和邻居像素获得原始图像中的目标像素的透明度值α,根据透明度值,在原始图像中抠出目标物体(103)。基于透明度的抠图方法和装置减小了抠图误差,提高了抠图效果。

Description

基于透明度的抠图方法和装置 技术领域
本发明实施例涉及图像处理技术,尤其涉及一种基于透明度的抠图方法和装置。
背景技术
抠图技术是一种把任意图像中的前景部分从背景中分离出来的一种图像处理技术。在杂志封面、插图设计,广告和影视创作等方面有着广泛而深入的应用。抠图的方式有多种,其中,应用最广泛的是alpha抠图技术。
采用alpha抠图技术进行抠图时,一般认为一幅自然图像中的各个像素点的颜色是该点前景颜色和背景颜色的线性组合,线性系数表示前景颜色在该点颜色中所占的比重,数值在[0,1]之间变化。具体的关系如公式(1.1)所示:
I=αF+(1-α)B    (1.1)
其中,I表示该点的颜色值,F和B分别表示该点的前景颜色值和背景颜色值,α为线性组合的系数,表示该点的透明度。对于alpha抠图问题,对图像上的任一点,根据公式(1.1)计算出的α值并不唯一,因此,如何从无数对解中找出最合理的解是非常重要的。
现有技术中,一般通过color-clustering抠图算法,确定出最合理的α值。在color-clustering算法中,通过对图像中的每个像素点,采用K最近邻(K Nearest Neighbor,简称:KNN)算法找到与其最相似的相关像素,用“color ball model”来建立模型,再结合公式(1.1)得到α的解。
然而,现有技术中,在通过color-clustering算法确定α值的过程中,若对相对简单且包含光滑区域较多的图像进行抠图时,由于是在图像的所有像素点中查找最相似的相关像素,使得抠图结果容易产生误差,导致抠图效果较差。
发明内容
本发明实施例提供一种基于透明度的抠图方法和装置,用以减小抠图误差,提高抠图效果。
第一方面,本发明实施例提供一种基于透明度的抠图方法,包括:
获取待抠图的原始图像,对所述原始图像进行边缘检测,获得检测结果;
根据所述检测结果将全局像素或局部像素作为所述原始图像中的目标像素的邻居像素;其中,所述全局像素为在原始图像中根据全局搜索算法获得的像素,所述局部像素为在原始图像中根据局部搜索算法获得的像素;
根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,根据所述透明度值,在所述原始图像中抠出目标物体。
结合第一方面,在第一方面的第一种可能的实现方式中,所述对所述原始图像进行边缘检测,具体包括:
将所述原始图像转换成灰度图像,对所述灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
结合第一方面、第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述根据所述检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素,具体包括:
判断所述边缘检测图像中目标像素的像素值是否大于预设阈值;其中,所述边缘检测图像中的目标像素与所述原始图像中的目标像素相对应;
若是,则采用全局像素作为所述原始图像中的目标像素的邻居像素;
若否,则采用局部像素作为所述原始图像中的目标像素的邻居像素。
结合第一方面、第一方面的第一种可能的实现方式,在第一方面的第三种可能的实现方式中,所述根据所述检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素,具体包括:
在所述原始图像中的目标像素的多个邻居像素中,确定第一预设数 目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。
结合第一方面、第一方面的第一种至第一方面的第三种任一种可能的实现方式,在第一方面的第四种可能的实现方式中,所述根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,具体包括:
根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L;
根据拉普拉斯矩阵L和获取的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为所述辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数;
根据所述第一目标函数获得所述原始图像中的目标像素的透明度值α。
结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L,具体包括:
根据公式(1)计算邻接矩阵W:
Figure PCTCN2015092537-appb-000001
其中,I为所述原始图像,k为所述目标像素,i和j为所述邻居像素集合中两个不同的像素点,Nk为所述邻居像素的集合,uk为所述邻居像素集合中所有像素的均值,∑k为所述邻居像素集合中所有像素的协方差矩阵;
根据公式(2)计算获得拉普拉斯矩阵L:
L=D-W    (2)
其中,D为度矩阵,通过公式Dii=∑jWij获得。
结合第一方面、第一方面的第一种至第一方面的第五种任一种可能的实现方式,在第一方面的第六种可能的实现方式中,所述根据所述拉普拉斯矩阵L和获取的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs),具体包括:
根据所述拉普拉斯矩阵L构建关于目标像素的透明度的第二目标函 数:
f(α)=αTLα;
获取所述辅助图像,并将所述辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记,以获取标记后的辅助图像;
根据所述第二目标函数和所述标记后的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:
J(α)=αTLα+λ(α-bs)TDs(α-bs)。
结合第一方面、第一方面的第一种至第一方面的第六种任一种可能的实现方式,在第一方面的第七种可能的实现方式中,所述根据所述第一目标函数获得所述原始图像中目标像素的透明度值α之前,还包括:
根据所述第一目标函数获得alpha图像:(L+λDs)α=λbs
第二方面,本发明实施例提供一种基于透明度的抠图装置,包括:
检测模块,用于获取待抠图的原始图像,对所述原始图像进行边缘检测,获得检测结果;
处理模块,用于根据所述检测结果将全局像素或局部像素作为所述原始图像中目标像素的邻居像素;其中,所述全局像素为在原始图像中根据全局搜索算法获得的像素,所述局部像素为在原始图像中根据局部搜索算法获得的像素;
第一获取模块,用于根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,根据所述透明度值,在所述原始图像中抠出目标物体。
结合第二方面,在第二方面的第一种可能的实现方式中,所述检测模块包括:
获取单元,用于将所述原始图像转换成灰度图像,对所述灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
结合第二方面、第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述处理模块还包括:
判断单元,用于判断所述边缘检测图像中目标像素的像素值是否大于预设阈值;其中,所述边缘检测图像中的目标像素与所述原始图像中 的目标像素相对应;
若是,则采用全局像素作为所述原始图像中的目标像素的邻居像素;
若否,则采用局部像素作为所述原始图像中的目标像素的邻居像素。
结合第二方面、第二方面的第一种可能的实现方式,在第二方面的第三种可能的实现方式中,所述处理模块还包括:
确定单元,用于在所述原始图像中的目标像素的多个邻居像素中,确定第一预设数目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。
结合第二方面、第二方面的第一种至第二方面的第三种任一种可能的实现方式,在第二方面的第四种可能的实现方式中,所述第一获取模块包括:
拉普拉斯矩阵L获取单元,用于根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L;
第一目标函数获取单元,用于根据拉普拉斯矩阵L和获取的辅助图像构建关于目标像素的透明度的第一目标函数:
J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为所述辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数;
透明度值获取单元,用于根据所述第一目标函数获得所述目标像素的透明度值α。
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,所述拉普拉斯矩阵L获取单元,具体用于:
根据公式(1)计算邻接矩阵W:
Figure PCTCN2015092537-appb-000002
其中,I为所述原始图像,k为所述目标像素,i和j为所述邻居像素集合中两个不同的像素点,Nk为所述邻居像素的集合,uk为所述邻居像素集合中所有像素的均值,∑k为所述邻居像素集合中所有像素的协方 差矩阵;
根据公式(2)计算获得拉普拉斯矩阵L:
L=D-W    (2)
其中,D为度矩阵,通过公式Dii=∑jWij获得。
结合第二方面、第二方面的第一种至第二方面的第五种任一种可能的实现方式,在第二方面的第六种可能的实现方式中,所述第一目标函数获取单元,具体用于:
根据所述拉普拉斯矩阵L构建关于所述原始图像中目标像素的透明度的第二目标函数:
f(α)=αTLα;
获取所述辅助图像,并将所述辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记,以获取标记后的辅助图像;
根据所述第二目标函数和所述标记后的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:
J(α)=αTLα+λ(α-bs)TDs(α-bs)。
结合第二方面、第二方面的第一种至第二方面的第六种任一种可能的实现方式,在第二方面的第七种可能的实现方式中,还包括:
alpha图像获取模块,用于根据所述第一目标函数获得alpha图像:(L+λDs)α=λbs
本发明提供的基于透明度的抠图方法和装置,通过获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果;根据检测结果将全局像素或局部像素作为原始图像中目标像素的邻居像素,其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素;根据原始图像和邻居像素获得原始图像中目标像素的透明度值α,根据获得的透明度值,在原始图像中抠出目标物体。由于,通过对原始图像进行边缘检测,根据该检测结果选择通过全局搜索方式还是局部搜索的方式来获取原始图像中目标像素的邻居像素,由此可以减小抠图误差,从而提高抠图效果。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明基于透明度的抠图方法实施例一的流程示意图;
图2为本发明基于透明度的抠图方法实施例二的流程示意图;
图3为本发明基于透明度的抠图方法实施例三的流程示意图;
图4为本发明基于透明度的抠图装置实施例一的结构示意图;
图5为本发明基于透明度的抠图装置实施例二的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
图1为本发明基于透明度的抠图方法实施例一的流程示意图,本发明实施例提供了一种基于透明度的抠图方法,该方法可以由任意执行基于透明度的抠图方法的装置来执行,该装置可以是各种终端设备,例如:个人电脑(personal computer;简称PC),手机,PAD,各种服务器等,具体可以通过软件和/或硬件来实现。如图1所示,本实施例的方法可以包括:
步骤101:获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果。
在本实施例中,对原始图像进行边缘检测处理之后,获得边缘检测图像。本领域技术人员可以理解,该边缘检测图像的特点是:若原始图像中某些边缘部分较复杂,则在边缘检测图像中对应的该边缘部分的像素点偏灰白色;若原始图像中某些区域较光滑,则在边缘检测图像中对 应的该部分区域的像素点偏黑色。
步骤102、根据检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素;其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素。
在本实施例中,对原始图像进行边缘检测,获得边缘检测图像之后,可以根据边缘检测图像的特点,选择采用全局搜索算法或局部搜索算法,得到全局像素或局部像素作为目标像素的邻居像素。本领域技术人员可以理解,全局搜索算法例如可以是KNN算法,局部搜索算法例如可以是变邻域搜索算法,对于全局搜索算法和局部搜算算法的类型,本实施例对此不作特别限制。
步骤103:根据原始图像和邻居像素获得原始图像中的目标像素的透明度值α,根据透明度值,在原始图像中抠出目标物体。
具体地,根据原始图像和获取的邻居像素,计算获得原始图像中目标像素的透明度值,继而根据获得的透明度值,可以在原始图像中抠出目标物体。例如:在具体的实现过程中,可以利用透明度值α乘以输入图像的方式获得目标物体。对于抠出目标物体的方法,可以根据实际需要选择不同的方法,本实施例对此不作特别限制。
本发明实施例提供的基于透明度的抠图方法,通过获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果;根据检测结果将全局像素或局部像素作为目标像素的邻居像素,其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素;根据原始图像和邻居像素获得原始图像中目标像素的透明度值α,根据获得的透明度值,在原始图像中抠出目标物体。由于,通过对原始图像进行边缘检测,根据该检测结果选择通过全局搜索方式还是局部搜索方式来获取原始图像中目标像素的邻居像素,由此可以减小抠图误差,从而提高抠图效果。
图2为本发明基于透明度的抠图方法实施例二的流程示意图,本实施例在基于透明度的抠图方法实施例一的基础上,对对原始图像进行边缘检测,并根据检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素的实施例,做详细说明。如图2所示,本实施例的方法可以 包括:
步骤201、将原始图像转换成灰度图像,对灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
在本实施例中,对灰度图像进行一次3*3的拉普拉斯滤波,可以得到原始图像的边缘检测结果,具体地,通过对灰度图像和拉普拉斯算子做卷积,即可以得到一幅显示原始图像边缘信息的图像。为了去除检测结果中可能含有的噪声,还可以对获得的边缘检测结果进行一次3*3的均值滤波。
步骤202、判断边缘检测图像中目标像素的像素值是否大于预设阈值;其中,边缘检测图像中的目标像素与原始图像中的目标像素相对应。
在本步骤中,若像素值大于预设阈值,则执行步骤203,否则,执行步骤204。
在本实施例中,预设阈值的大小可以根据实际经验进行选取,例如可以是0.001等,对于预设阈值的具体值的选取,本实施例在此不作特别限制。
另外,将原始图像进行边缘检测处理,获得边缘检测图像之后,原始图像中的目标像素即成为边缘检测图像中的目标像素。通过判断边缘检测图像中目标像素的像素值是否大于预设阈值,根据判断结果选择是在预先定义的特征空间Fs中选取邻居像素,还是在特征空间Ft中选取邻居像素,其中,Fs和Ft分别为:
Fs=[R,G,B,x,y,dR,dG,dB,ctr]
Ft=[R,G,B,x,y,dR,dG,dB]
其中,R为红色,G为绿色,B为蓝色,x为目标像素在原始图像中的横坐标,y为目标像素在原始图像中的纵坐标,dR为红色通道的梯度值,dG为绿色通道的梯度值,dB为蓝色通道的梯度值,ctr为在边缘检测图像中目标像素的像素值。
步骤203、采用全局像素作为原始图像中的目标像素的邻居像素。
在本实施例中,若边缘检测图像中目标像素的像素值大于预设阈值,则表示该目标像素的颜色偏灰白色,说明在原始图像中,该目标像 素周围的图像较复杂或可能包含有各种纹理等,此时,需要通过全局搜索算法寻找与目标像素最相似的相关像素作为目标像素的邻居像素,以便更好地对图像进行处理。在本实施例中,以KNN算法为例进行详细说明。
当获取到原始图像后,对原始图像进行边缘检测,获得边缘检测图像中目标像素的像素值,若该像素值大于预设阈值,则使用KNN算法在预先定义的Fs特征空间中对原始图像进行搜索并进行排序,选取前K个像素作为原始图像中目标像素的邻居像素。
步骤204、采用局部像素作为原始图像中的目标像素的邻居像素。
在本实施例中,若边缘检测图像中目标像素的像素值不大于预设阈值,则表示该目标像素的颜色偏黑色,说明在原始图像中该目标像素周围的图像较简单或平滑,此时,认为目标像素周围的像素即为与该目标像素最相似的像素,故通过局部搜索算法选取该目标像素的邻居像素,以更好地对图像进行处理。
具体地,当获取到原始图像后,对原始图像进行边缘检测,获得边缘检测图像中目标像素的像素值,若该像素值小于预设阈值,则在预先定义的Ft特征空间中对原始图像进行搜索,并选取原始图像中目标像素的邻居像素。
本发明实施例提供的基于透明度的抠图方法,通过对原始图像进行边缘检测,并判断边缘检测图像中目标像素的像素值是否大于预设阈值,根据判断结果选取全局像素或者局部像素作为原始图像中目标像素的邻居像素,由此减小了抠图误差,从而提高了抠图的效果。
可选地,如上所述的方法实施例中,在原始图像中的目标像素的多个邻居像素中,也可以确定第一预设数目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。具体地,对于原始图像中的某个目标像素,可以同时使用局部像素和全局像素作为其邻居像素,例如可以根据实际需要同时选取9个局部像素和9个全局像素作为该目标像素的邻居像素。在具体的实现过程中,可根据经验或者图像某一区域的复杂度选取合适的邻居像素,例如对于相对纹理较多或者较复杂的区域来说,可以选取4个局部像素和14个全局像素作为目标像素的邻居像素;对于相 对平滑或者较简单的区域来说,可以选取13个局部像素和5个全局像素作为目标像素的邻居像素。对于第一预设数目和第二预设数目的具体值的选取,本实施例在此不作特别限制。
图3为本发明基于透明度的抠图方法实施例三的流程示意图,本实施例在基于透明度的抠图方法实施例一和基于透明度的抠图方法实施例二的基础上,对根据原始图像和邻居像素获得目标像素的透明度值α的实施例,做详细说明。如图3所示,本实施例的方法可以包括:
步骤301、获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果。
步骤302、根据检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素;其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素。
步骤301-步骤302与步骤101-步骤102类似,此处不再赘述。
步骤303、根据原始图像和邻居像素获得拉普拉斯矩阵L。
在本实施例中,首先根据获取到的原始图像和选取的邻居像素计算获得邻接矩阵,本领域技术人员可以理解,邻接矩阵是表示顶点之间相邻关系的矩阵。在具体的实现过程中,可以根据公式(1)计算获得邻接矩阵W:
Figure PCTCN2015092537-appb-000003
其中,I为原始图像,k为目标像素,i和j为邻居像素集合中两个不同的像素点,Nk为邻居像素的集合,uk为邻居像素集合中所有像素的均值,∑k为邻居像素集合中所有像素的协方差矩阵。
获取到邻接矩阵W之后,根据公式(2)可以计算获得拉普拉斯矩阵L:
L=D-W    (2)
其中,D为度矩阵,通过公式Dii=∑jWij获得。
步骤304、根据拉普拉斯矩阵L和获取的辅助图像构建关于原始图像中目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数。
在本实施例中,首先,根据获得的拉普拉斯矩阵L构建关于目标像素的透明度的第二目标函数:
f(α)=αTLα。
其次,获取由用户提供的带有辅助标记的辅助图像,该辅助图像是一幅灰度图像,是对原始图像的一种粗略的划分,即将原始图像划分为前景、背景和未知区域,其目的是用于提供关于原始图像中前景和背景基本信息的一些先验知识。其中,辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记。
最后,根据构建的第二目标函数和标记后的辅助图像构建关于原始图像中目标像素的透明度的第一目标函数:
J(α)=αTLα+λ(α-bs)TDs(α-bs)。
其中,第一目标函数中的λ是用于平衡αTLα和(α-bs)TDs(α-bs)的参数,本实施例中λ的值可以根据实际需要选取1000或1500等。在具体的实现过程中,可根据经验选取合适的λ值,对于λ的具体值的选取,本实施例在此不作特别限制。Ds是一个N*N的矩阵,矩阵中只有0和1,其中,0代表辅助图像中未知区域的像素点,1代表辅助图像中背景和前景的像素点。bs是一个N*1的向量,向量中也只包含0和1,其中,0代表辅助图像中背景的像素点,1代表辅助图像中前景的像素点。
在构建出关于目标像素的透明度的第一目标函数J(α)=αTLα+λ(α-bs)TDs(α-bs)之后,为使第一目标函数值最小,可以将第一目标函数转化为方程
Figure PCTCN2015092537-appb-000004
经过计算获得alpha图像(L+λDs)α=λbs
步骤305、根据第一目标函数获得原始图像中的目标像素的透明度值α。
具体地,可以根据第一目标函数获得alpha图像(L+λDs)α=λbs,其中,Ds是一个只包含有0和1的N*N的矩阵,其中,0代表辅助图像中为未知区域的像素点,1代表辅助图像中为背景和前景的像素点。bs为只包含0和1的N*1的向量,其中,0代表辅助图像中为背景的像素点,1代 表辅助图像中为前景的像素点,故通过求解(L+λDs)α=λbs方程,即可获得目标像素的透明度值α,根据得到的透明度值,继而可以在原始图像中抠出目标物体。
本发明实施例提供的基于透明度的抠图方法,通过获取待抠图的原始图像,对原始图像进行边缘检测,获得检测结果;根据检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素,其中,全局像素为在原始图像中根据全局搜索算法获得的像素,局部像素为在原始图像中根据局部搜索算法获得的像素;根据原始图像和邻居像素获得拉普拉斯矩阵L,根据拉普拉斯矩阵L和获取的辅助图像构建关于目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs),继而获得目标像素的透明度值α,通过获得的透明度值,在原始图像中抠出目标物体。通过对原始图像进行边缘检测,根据该检测结果选取原始图像中目标像素的邻居像素是全局像素还是局部像素,由此可以减小抠图误差,提高抠图效果。另外,通过构建拉普拉斯矩阵L和第一目标函数计算获得目标像素的透明度值α,可以简化透明度值的计算,同时提高计算的准确度。
可选地,如上所述的方法实施例中,在构建拉普拉斯矩阵L时,也可以先根据实际需要设计邻接矩阵W,其设计的原则是:原始图像中越相似的两个像素,在邻接矩阵W中的数值越大,而越无关的像素,在邻接矩阵W中的数值越小,根据设计的邻接矩阵W来构建拉普拉斯矩阵L。
图4为本发明基于透明度的抠图装置实施例一的结构示意图,如图4所示,本发明实施例提供的基于透明度的抠图装置包括检测模块401,处理模块402和第一获取模块403。
其中,检测模块401用于获取待抠图的原始图像,对所述原始图像进行边缘检测,获得检测结果;处理模块402用于根据所述检测结果将全局像素或局部像素作为所述原始图像中的目标像素的邻居像素;其中,所述全局像素为在原始图像中根据全局搜索算法获得的像素,所述局部像素为在原始图像中根据局部搜索算法获得的像素;第一获取模块403用于根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,根据所述透明度值,在所述原始图像中抠出目标物体。
本实施例的基于透明度的抠图装置,可以用于基于透明度的抠图方 法实施例一的技术方案,其实现原理和技术效果类似,此处不再赘述。
图5为本发明基于透明度的抠图装置实施例二的结构示意图,如图5所示,本实施例在图4所示实施例的基础上,所述检测模块401包括:
获取单元4011,用于将所述原始图像转换成灰度图像,对所述灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
可选地,所述处理模块402包括:
判断单元4021,用于判断所述边缘检测图像中目标像素的像素值是否大于预设阈值;
若是,则采用全局像素作为所述原始图像中的目标像素的邻居像素;
若否,则采用局部像素作为所述原始图像中的目标像素的邻居像素。
可选地,所述处理模块402还包括:
确定单元4022,用于在所述原始图像中的目标像素的多个邻居像素中,确定第一预设数目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。
可选地,所述第一获取模块403包括:
拉普拉斯矩阵L获取单元4031用于根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L;第一目标函数获取单元4032用于根据拉普拉斯矩阵L和获取的辅助图像构建关于目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为所述辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数;透明度值获取单元4033用于根据所述第一目标函数获得所述目标像素的透明度值α。
可选地,所述拉普拉斯矩阵L获取单元4031,具体用于:
根据公式(1)计算邻接矩阵W:
Figure PCTCN2015092537-appb-000005
其中,I为所述原始图像,k为所述目标像素,i和j为所述邻居像素集合中两个不同的像素点,Nk为所述邻居像素的集合,uk为所述邻居像素集合中所有像素的均值,∑k为所述邻居像素集合中所有像素的协方 差矩阵;
根据公式(2)计算获得拉普拉斯矩阵L:
L=D-W    (2)
其中,D为度矩阵,通过公式Dii=∑jWij获得。
可选地,所述第一目标函数获取单元4032,具体用于:
根据所述拉普拉斯矩阵L构建关于所述原始图像中目标像素的透明度的第二目标函数:
f(α)=αTLα;
获取所述辅助图像,并将所述辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记,以获取标记后的辅助图像;
根据所述第二目标函数和所述标记后的辅助图像构建关于所述所述原始图像中目标像素的透明度的第一目标函数:
J(α)=αTLα+λ(α-bs)TDs(α-bs)。
可选地,所述装置还包括:
alpha图像获取模块404,用于根据所述第一目标函数获得alpha图像:(L+λDs)α=λbs
本实施例的基于透明度的抠图装置,可以用于执行本发明任意实施例所提供的基于透明度的抠图方法的技术方案,其实现原理和技术效果类似,此处不再赘述。
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (16)

  1. 一种基于透明度的抠图方法,其特征在于,包括:
    获取待抠图的原始图像,对所述原始图像进行边缘检测,获得检测结果;
    根据所述检测结果将全局像素或局部像素作为所述原始图像中的目标像素的邻居像素;其中,所述全局像素为在原始图像中根据全局搜索算法获得的像素,所述局部像素为在原始图像中根据局部搜索算法获得的像素;
    根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,根据所述透明度值,在所述原始图像中抠出目标物体。
  2. 根据权利要求1所述的方法,其特征在于,所述对所述原始图像进行边缘检测,具体包括:
    将所述原始图像转换成灰度图像,对所述灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
  3. 根据权利要求1或2所述的方法,其特征在于,所述根据所述检测结果将全局像素或局部像素作为所述原始图像中的目标像素的邻居像素,具体包括:
    判断所述边缘检测图像中目标像素的像素值是否大于预设阈值;其中,所述边缘检测图像中的目标像素与所述原始图像中的目标像素相对应;
    若是,则采用全局像素作为所述原始图像中的目标像素的邻居像素;
    若否,则采用局部像素作为所述原始图像中的目标像素的邻居像素。
  4. 根据权利要求1或2所述的方法,其特征在于,所述根据所述检测结果将全局像素或局部像素作为原始图像中的目标像素的邻居像素,具体包括:
    在所述原始图像中的目标像素的多个邻居像素中,确定第一预设数目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述根据所 述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,具体包括:
    根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L;
    根据所述拉普拉斯矩阵L和获取的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为所述辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数;
    根据所述第一目标函数获得所述原始图像中的目标像素的透明度值α。
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L,具体包括:
    根据公式(1)计算邻接矩阵W:
    Figure PCTCN2015092537-appb-100001
    其中,I为所述原始图像,k为所述目标像素,i和j为所述邻居像素集合中两个不同的像素点,Nk为所述邻居像素的集合,uk为所述邻居像素集合中所有像素的均值,∑k为所述邻居像素集合中所有像素的协方差矩阵;
    根据公式(2)计算获得拉普拉斯矩阵L:
    L=D-W   (2)
    其中,D为度矩阵,通过公式Dii=jWij获得。
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述根据所述拉普拉斯矩阵L和获取的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:J(α)=αTLα+λ(α-bs)TDs(α-bs),具体包括:
    根据所述拉普拉斯矩阵L构建关于所述原始图像中目标像素的透明度的第二目标函数:
    f(α)=αTLα;
    获取所述辅助图像,并将所述辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记,以获取标记后的辅助图像;
    根据所述第二目标函数和所述标记后的辅助图像构建关于所述原始图 像中目标像素的透明度的第一目标函数:
    J(α)=αTLα+λ(α-bs)TDs(α-bs)。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述根据所述第一目标函数获得所述原始图像中目标像素的透明度值α之前,还包括:
    根据所述第一目标函数获得alpha图像:(L+λDs)α=λbs
  9. 一种基于透明度的抠图装置,其特征在于,包括:
    检测模块,用于获取待抠图的原始图像,对所述原始图像进行边缘检测,获得检测结果;
    处理模块,用于根据所述检测结果将全局像素或局部像素作为所述原始图像中的目标像素的邻居像素;其中,所述全局像素为在原始图像中根据全局搜索算法获得的像素,所述局部像素为在原始图像中根据局部搜索算法获得的像素;
    第一获取模块,用于根据所述原始图像和所述邻居像素获得所述原始图像中的目标像素的透明度值α,根据所述透明度值,在所述原始图像中抠出目标物体。
  10. 根据权利要求9所述的装置,其特征在于,所述检测模块包括:
    获取单元,用于将所述原始图像转换成灰度图像,对所述灰度图像进行拉普拉斯滤波和均值滤波处理,获得边缘检测图像。
  11. 根据权利要求9或10所述的装置,其特征在于,所述处理模块包括:
    判断单元,用于判断所述边缘检测图像中目标像素的像素值是否大于预设阈值;其中,所述边缘检测图像中的目标像素与所述原始图像中的目标像素相对应;
    若是,则采用全局像素作为所述原始图像中的目标像素的邻居像素;
    若否,则采用局部像素作为所述原始图像中的目标像素的邻居像素。
  12. 根据权利要求9或10所述的装置,其特征在于,所述处理模块还包括:
    确定单元,用于在所述原始图像中的目标像素的多个邻居像素中,确定第一预设数目的邻居像素为局部像素,第二预设数目的邻居像素为全局像素。
  13. 根据权利要求9-12任一项所述的装置,其特征在于,所述第一获取模块包括:
    拉普拉斯矩阵L获取单元,用于根据所述原始图像和所述邻居像素获得拉普拉斯矩阵L;
    第一目标函数获取单元,用于根据拉普拉斯矩阵L和获取的辅助图像构建关于目标像素的透明度的第一目标函数:
    J(α)=αTLα+λ(α-bs)TDs(α-bs);其中,α为透明度值,λ为预设参数,Ds为N*N的矩阵,N为所述辅助图像中像素的个数,bs为N*1的向量,N为大于0的整数;
    透明度值获取单元,用于根据所述第一目标函数获得所述目标像素的透明度值α。
  14. 根据权利要求13所述的装置,其特征在于,所述拉普拉斯矩阵L获取单元,具体用于:
    根据公式(1)计算邻接矩阵W:
    Figure PCTCN2015092537-appb-100002
    其中,I为所述原始图像,k为所述目标像素,i和j为所述邻居像素集合中两个不同的像素点,Nk为所述邻居像素的集合,uk为所述邻居像素集合中所有像素的均值,∑k为所述邻居像素集合中所有像素的协方差矩阵;
    根据公式(2)计算获得拉普拉斯矩阵L:
    L=D-W   (2)
    其中,D为度矩阵,通过公式Dii=∑jWij获得。
  15. 根据权利要求9-14任一项所述的装置,其特征在于,所述第一目标函数获取单元,具体用于:
    根据所述拉普拉斯矩阵L构建关于所述原始图像中目标像素的透明度的第二目标函数:
    f(α)=αTLα;
    获取所述辅助图像,并将所述辅助图像的背景用黑色进行标记,前景用白色进行标记,其它部分用灰色进行标记,以获取标记后的辅助图像;
    根据所述第二目标函数和所述标记后的辅助图像构建关于所述原始图像中目标像素的透明度的第一目标函数:
    J(α)=αTLα+λ(α-bs)TDs(α-bs)。
  16. 根据权利要求9-15任一项所述的装置,其特征在于,还包括:
    alpha图像获取模块,用于根据所述第一目标函数获得alpha图像:(L+λDs)α=λbs
PCT/CN2015/092537 2014-10-22 2015-10-22 基于透明度的抠图方法和装置 WO2016062259A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410568214.9A CN105590307A (zh) 2014-10-22 2014-10-22 基于透明度的抠图方法和装置
CN201410568214.9 2014-10-22

Publications (1)

Publication Number Publication Date
WO2016062259A1 true WO2016062259A1 (zh) 2016-04-28

Family

ID=55760310

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/092537 WO2016062259A1 (zh) 2014-10-22 2015-10-22 基于透明度的抠图方法和装置

Country Status (2)

Country Link
CN (1) CN105590307A (zh)
WO (1) WO2016062259A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111768422A (zh) * 2020-01-16 2020-10-13 北京沃东天骏信息技术有限公司 边缘检测的处理方法、装置、设备及存储介质

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108460770B (zh) * 2016-12-13 2020-03-10 华为技术有限公司 抠图方法及装置
CN110378867A (zh) * 2018-09-26 2019-10-25 惠州学院 通过前景背景像素对和灰度信息获得透明度遮罩的方法
CN110111342B (zh) * 2019-04-30 2021-06-29 贵州民族大学 一种抠图算法的优化选取方法及装置
CN110298833B (zh) * 2019-06-28 2021-08-31 百度在线网络技术(北京)有限公司 图片处理方法和装置
CN112399196B (zh) * 2019-08-16 2022-09-02 阿里巴巴集团控股有限公司 图像处理方法及装置
CN112150348A (zh) * 2020-08-13 2020-12-29 北京旷视科技有限公司 试妆及试妆部件模板的生成方法、装置、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1445984A (zh) * 2003-04-14 2003-10-01 浙江大学 数字图像处理中以任意图像为背景的快速抠图方法
CN102567727A (zh) * 2010-12-13 2012-07-11 中兴通讯股份有限公司 一种背景目标替换方法和装置
CN102842119A (zh) * 2012-08-18 2012-12-26 湖南大学 一种基于抠像和边缘增强的快速文本图像超分辨率方法
CN102902956A (zh) * 2012-09-10 2013-01-30 中国人民解放军理工大学气象学院 一种地基可见光云图识别处理方法
US20130051663A1 (en) * 2011-08-26 2013-02-28 Aravind Krishnaswamy Fast Adaptive Edge-Aware Matting

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1445984A (zh) * 2003-04-14 2003-10-01 浙江大学 数字图像处理中以任意图像为背景的快速抠图方法
CN102567727A (zh) * 2010-12-13 2012-07-11 中兴通讯股份有限公司 一种背景目标替换方法和装置
US20130051663A1 (en) * 2011-08-26 2013-02-28 Aravind Krishnaswamy Fast Adaptive Edge-Aware Matting
CN102842119A (zh) * 2012-08-18 2012-12-26 湖南大学 一种基于抠像和边缘增强的快速文本图像超分辨率方法
CN102902956A (zh) * 2012-09-10 2013-01-30 中国人民解放军理工大学气象学院 一种地基可见光云图识别处理方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111768422A (zh) * 2020-01-16 2020-10-13 北京沃东天骏信息技术有限公司 边缘检测的处理方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN105590307A (zh) 2016-05-18

Similar Documents

Publication Publication Date Title
WO2016062259A1 (zh) 基于透明度的抠图方法和装置
Tong et al. Saliency detection with multi-scale superpixels
JP2018537742A (ja) エッジ認識双方向画像処理
CN108596108B (zh) 基于三元组语义关系学习的航拍遥感图像变化检测方法
WO2015143624A1 (en) Methods and systems for denoising images
US9064178B2 (en) Edge detection apparatus, program and method for edge detection
Lo et al. Joint trilateral filtering for depth map super-resolution
US9401027B2 (en) Method and apparatus for scene segmentation from focal stack images
US9240038B2 (en) Method and apparatus for acquiring weight coefficient of digital filter
Hua et al. Extended guided filtering for depth map upsampling
WO2017050083A1 (zh) 一种元件识别方法及装置
CN108960280B (zh) 一种图片相似度检测方法及系统
US20120294519A1 (en) Opacity Measurement Using a Global Pixel Set
CN107784631B (zh) 图像去模糊方法及装置
Gutzeit et al. Automatic segmentation of wood logs by combining detection and segmentation
JP2010205067A (ja) 領域抽出装置、領域抽出方法及び領域抽出プログラム
WO2010043954A1 (en) Method, apparatus and computer program product for providing pattern detection with unknown noise levels
WO2011131029A1 (zh) 一种基于轮廓带图的相似单元的检测方法
CN108960012B (zh) 特征点检测方法、装置及电子设备
Zhao et al. Efficient image decolorization with a multimodal contrast-preserving measure
US20150235399A1 (en) Variable Patch Shape Synthesis
JP6754717B2 (ja) 物体候補領域推定装置、物体候補領域推定方法、及び物体候補領域推定プログラム
EP2966613A1 (en) Method and apparatus for generating a super-resolved image from an input image
CN110766708B (zh) 基于轮廓相似度的图像比较方法
US9098746B2 (en) Building texture extracting apparatus and method thereof

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

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

Country of ref document: EP

Kind code of ref document: A1