Fast Deep Matting for Portrait Animation on Mobile Phone

07/26/2017 ∙ by Bingke Zhu, et al. ∙ North China University of Technolege 0

Image matting plays an important role in image and video editing. However, the formulation of image matting is inherently ill-posed. Traditional methods usually employ interaction to deal with the image matting problem with trimaps and strokes, and cannot run on the mobile phone in real-time. In this paper, we propose a real-time automatic deep matting approach for mobile devices. By leveraging the densely connected blocks and the dilated convolution, a light full convolutional network is designed to predict a coarse binary mask for portrait images. And a feathering block, which is edge-preserving and matting adaptive, is further developed to learn the guided filter and transform the binary mask into alpha matte. Finally, an automatic portrait animation system based on fast deep matting is built on mobile devices, which does not need any interaction and can realize real-time matting with 15 fps. The experiments show that the proposed approach achieves comparable results with the state-of-the-art matting solvers.



There are no comments yet.


page 1

page 3

page 4

page 5

page 7

page 8

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1. Introduction

Figure 1. Examples of portrait animation. (a) The original images which are the inputs to our system. (b) The foregrounds of the original images, which are computed by the Eq. (1). (c) The portrait animation on mobile phone.

Image matting plays an important role in computer vision, which has a number of applications, such as virtual reality, augmented reality, interactive image editing, and image stylization

(Shen et al., 2016a). As people are increasingly taking selfies and uploading the edited to the social network with mobile phones, real-time matting technique is in demand which can handle real world scenes. However, the formulation of image matting is still an ill-posed problem. Given an input image , image matting problem is equivalent to decomposing it into foreground and background in assumption that is blended linearly by and :


where is used to evaluate the foreground opacity(alpha matte). In natural image matting, all quantities on the right-hand side of the composting Eq. (1) are unknown, which makes the original matting problem ill-posed.

Figure 2. Pipeline of our end-to-end real-time image matting framework. It includes a segmentation block and a feathering block.

To alleviate the difficulty of this problem, popular image matting techniques such as (Levin et al., 2008; He et al., 2010; Gastal and Oliveira, 2010; Shen et al., 2016b) require users to specify foreground and background color samples with trimaps or strokes, which makes a rough distinction among foreground, background and regions with unknown opacity. Benefit from the trimaps and strokes, the interactive mattings have high accuracy and have the capacity to segment the elaborate hair. However, despite the high accuracy of these matting techniques, these methods rely on user involvement (label the trimaps or strokes) and require extensive computation, which restricts the application scenario. In order to deal with the interactive problem, Shen et al. (Shen et al., 2016b) proposed an automatic matting with the help of semantic segmentation technique. But their automatic matting have a very high computational complexity and it is still slow even on the GPU.

In this paper, to solve user involvement and apply matting technique on mobile phones, we propose a real-time automatic matting method on mobile phone with a segmentation block and a feathering block. Firstly, we calculate a coarse binary mask by a light full convolutional network with dense connections. And then we design a learnable guided filter to obtain the final alpha matte through a feathering block. Finally, the predicted alpha matte is calculated through a linear transformation of the coarse binary mask, whose weights are obtained from the learnt guided filter. The experiments show that our real-time automatic matting method achieves comparable results to the general matting solvers. On the other hand, we demonstrate that our system possesses adaptive matting capacity dividing the parts of head and the neck precisely, which is unprecedented in other alpha matting methods. Thus, our system is useful in many applications like real-time video matting on mobile phone. And real-time portrait animation on mobile phone can be realized using our fast deep matting technique as shown in some examples in Figure

1. Compared with existing methods, the major contributions of our work are three-fold:

1. A fast deep matting network based on segmentation block and feathering block is proposed for mobile devices. By adding the dialed convolution into the dense block structure, we propose a light dense network for portrait segmentation.

2. A feathering block is proposed to learn the guided filter and transform the binary mask into alpha matte, which is edge-preserving and possesses matting adaptive capacity.

3. The proposed approach can realize real-time matting on the mobile phones and achieve comparable results with the state-of-the-art matting solvers.

2. Related Work

Image Matting: For interactive matting, in order to infer the alpha matte in the unknown regions, a Bayesian matting (Chuang et al., 2001) is proposed to model background and foreground color samples as Gaussian mixtures. Levin et al. (Levin et al., 2008) developed closed matting method to find the globally optimal alpha matte. He et al. (He et al., 2010) computed the large-kernel Laplacian to accelerate matting Laplacian computation. Sun et al. (Sun et al., 2004) proposed Poisson image mating to solve the homogenous Laplacian matrix. Different from the methods based on the Laplacian matrix, shared matting (Gastal and Oliveira, 2010)

presented the first real-time matting technique on modern GPUs by shared sampling. Benefit from the performance of deep learning, Xu et al.

(Xu et al., 2017) developed an encoder-decoder network to predict alpha matte with the help of trimaps. Recently, Aksoy et al. (Aksoy et al., 2017) designed an effective inter-pixel information flow to predict the alpha matte and reach the state of the art. Different from the interactive matting, Shen et al. (Shen et al., 2016b) first proposed an end-to-end convolutional network to train the automatic matting.

With the rapid development of mobile devices, automatic matting is a very useful technique for image editing. However, despite the high efficiency of these techniques, both interactive matting and automatic matting cannot reach real-time matting on CPUs and mobile phone. The Laplacian-based methods need to compute the Laplacian matrix and its inverse, which is an symmetric matrix, where is the number of unknowns. Neither non-iterative methods (Levin et al., 2008), nor iterative methods (He et al., 2010) can solve the sparse linear system efficiently due to the high computing cost. The real-time image matting methods like shared matting can be real-time with the help of powerful GPUs, but these methods are still slow on CPUs and mobile phone.
Semantic Segmentation: Long et al. (Long et al., 2015) first proposed to solve the problem of semantic segmentation with fully convolutional network. ENet (Paszke et al., 2016) is a light full convolutional network for semantic segmentation, which can reach real-time on GPU. Huang et al. (Huang et al., 2017) and Bengio et al. (Jégou et al., 2017) proposed a dense network with several densely connected blocks, which make the receptive filed of prediction more dense. Specially, Chen et al. (Chen et al., 2015) developed an operation called dilated convolution, which makes the receptive filed more dense and bigger. Similarly, Yu et al. (Yu and Koltun, 2016) proposed to use dilated convolution to aggregate the context information. On the other hand, semantic and multi-scale information is important in image understanding and semantic segmentation (Wang et al., 2008, 2014; Zhou et al., 2016; Handa et al., 2015). In order to absorb more semantic and multi-scale information, Zhao et al. (Zhao et al., 2017) proposed a pyramid structure with dilated convolution, Chen et al. (Chen et al., 2017) proposed an atrous spatial pyramid pooling (ASPP), and Peng et al. (Peng et al., 2017) used the large kernel convolutions to extract features. Based on these observations, we try to combine the works of Huang (Huang et al., 2017) and Chen (Chen et al., 2015) to create a light dense network,which can predict the segmentation densely in several layers.
Guided Filter:

Image filtering plays an important role in computer vision, especially after the development of convolutional neural network. He et al.

(He et al., 2013) proposed an edge-preserving filter - guided filter to deal with the problem of gradient drifts, which is a common problem in image filtering. Despite the powerful performance of convolutional neural network, it loses the information of edge when it comes to pixel-wise predicted assignments such as semantic segmentation and alpha matting due to its piecewise smoothing.

Figure 3. Diagram of our light dense network for portrait segmentation.

3. Overview

The pipeline of our system is presented in Figure 2. The input is a color image and the output is the alpha matte . The network consists of two stages. The first stage is a portrait segmentation network which takes an image as input and obtains a coarse binary mask. The second stage is a feathering module that refines the foreground/background mask to the final alpha matte. The first stage provides a coarse binary mask in a fast speed with a light full convolutional network, while the second stage refines the coarse binary mask with a single filter, which reduces the error greatly. We will describe our algorithm with more details in the following sections.

3.1. Segmentation Block

In order to segment the foreground with a fast speed, we propose a light dense network in the segmentation block. The architecture of the light dense network is presented in Figure 3. Output sizes are reported for an example input image resolution of . The initial block is a concatenation of a

convolution and a max-pooling, which is used to down sample the input image. The dilated dense block contains four convolutional layers in different dilated rates and four densely connections. The concatenation of four convolutional layers are sent to the final convolution to obtain a binary feature maps. Finally, we interpolate the feature maps to get the score maps which have the same size as the original image. Specifically, our light dense network has 6 convolutional layers and 1 max-pooling layer.

The motivation of this architecture is inspired by several popular full convolutional networks for semantic segmentation. Inspired by the real-time segmentation architecture of ENet (Paszke et al., 2016) and Inception network (Szegedy et al., 2016), we use the initial block in ENet to down sample the input, which can maintain more information than that of max-pooling and bring less computation cost than that of convolution. Then the down-sampling maps are sent to the dilated dense block, which is inspired by the densely connected convolution network (Huang et al., 2017) and the dilated convolution network (Chen et al., 2015)

. Each layer of the dilated dense block obtains different field of view, which is important in the multi-scale semantic segmentation. The dilated dense block can seize the foreground in variable sizes, thus obtain a better segmentation mask by the final classifier.

3.2. Feathering Block

The segmentation block can produce a coarse binary mask to the alpha matte. However, the binary mask cannot represent the alpha matte due to the coarse edge. Despite fully convolution networks have been proved to be effective in the semantic segmentation (Long et al., 2015), the methods like (Xu et al., 2017) using fully convolutional networks may suffer from the gradient drifts because of the pixel-wise smoothing in the convolutional operations. In this section, we will discuss a feathering block to refine the binary mask and solve the problem of gradient drifts.

3.2.1. Architecture

The convolutional operations play important roles in the classification networks. However, alpha matting is a pixel-wise predicted task, and it is unsuitable to predict the edge of the objects with the convolutional operations due to its piecewise smoothing. The state of the art method (Chen et al., 2015) relieves this problem using the conditional random field (CRF) model to refine the edge of the objects, but it costs too much computing memory and it cannot solve the problem in the convolutional neural networks intrinsically. Motivated by the gradient drifts of the convolution operations, we developed a sub-network to learn the filters of the coarse binary mask, which does not suffer from the gradient drifts.

Figure 4. Architecture of the feathering block, which is used to learn the filter refining the coarse binary mask. is the input image, is the score maps output from the segmentation network, is the alpha matte which is the final output of the whole network, and is the hadamard product.

The architecture of the feathering block is presented in Figure 4. The inputs to the feathering block are an image, the corresponding coarse binary mask, the square of the image as well as the product of the image and its binary mask. The design of these inputs is inspired by the guided filter (He et al., 2013), whose weights are designed as a function of these inputs. We concatenate the inputs and send the concatenation into the convolutional network which contains two convolutional layers. Then we can obtain three maps corresponding to the weights and bias of the binary mask. The feathering layer can be represented as a linear transform of the coarse binary mask in sliding windows centered at each pixel:


where is the output of feathering layer represented as alpha matte, is the foreground score from the coarse binary mask, is the background score, is the location of the pixel, and are the linear coefficients assumed to be constant in the -th sliding window . Thus, we have:


where , , , and is the input image.

Figure 5. Examples of the filters learnt from the feathering block. (a) The input images. (b) The foregrounds of the original images, which are calculated by the Eq. (1). (c) The weights of feathering block in Eq. (2) and Eq. (3). (d) The weights of feathering block in Eq. (2) and Eq. (3). (e) The weights of feathering block in Eq. (2) and Eq. (3).

From (3) we can get the derivative


where , , . It ensures that the feathering block possesses the property of edge-preserving and matting adaptive. As discussed above, both two score maps and would have strong responses in the area of edge because of the uncertainty in these areas. However, it is worth to note that the score maps of foreground and background are allowed to have inaccurate responses when the parameters , , are trained well. In this case, we hope that the parameters , become as small as possible, which means that the inaccurate responses are suppressed. In other word, the feathering block can preserve the edge as long as the absolute values of , are set to small in the area of edge while is predominant on it. Similarly, if we want to segment the neck apart from the head, the parameters , , should be set to small in the area of neck. Moreover, it is interesting that the feathering block performs like ensemble learning because we can treat , , as the classifiers and the parameters , , as the weights for classification.

When we apply the linear model to all sliding windows in the entire image, the value is not the same in different windows. We leverage the same strategy as He et al. (He et al., 2013). After computing for all sliding windows in the image, we average all the possible values of :



With this modification, we can still have because are the average of the filters, and their gradients should be much smaller than that of near strong edges.

To determine the linear coefficients, we design a sub-network to seek the solution. Specially, our network leverages a loss function including two parts, which makes the alpha predictions more accurate. The first loss

measures the alpha matte, which is the absolute difference between the ground truth alpha values and the predicted alpha values at each pixel. And the second loss is a compositional loss, which is the L2-norm loss function for the predicted RGB foreground. Thus, we minimize the following cost function:



This loss function is chosen for two reasons. Intuitively, we hope to obtain an accurate alpha matte through the feathering block in the end, thus we use the alpha matte loss to learn the parameters. On the other hand, the second loss is used to maintain the information of the input image as much as possible. Since the score maps and would lose the information of edges due to the pixel-wise smoothing, we need to use the input image to recover the lost detail of the edge. Therefore, we leverage the second loss to guide the learning process. Despite existing deep learning methods like (Cho et al., 2016; Shen et al., 2016b; Xu et al., 2017)

used the similar loss function to solve the alpha matting problem, we have a totally different motivation and a different solution. Their loss functions are used to estimate the expression of alpha matting without considering the gradient drifts for the convolution operation, which causes the pixel-wise smooth alpha matte and loses the gradients of input image, while our loss function is edge-preserving. Through the gradient propagation, the parameters of feathering layer can be updated pixel-wise so as to correct the edges. It is because that the guided filter is an edge-preserving filter. However, other deep learning methods can only update the parameters in the fixed windows. As a result, their approaches would make the results pixel-wise smooth, while our results are edge-preserving.

3.2.2. Guided Image Filter

The guided filter (He et al., 2013) proposed a local linear model:


where is a linear transform of in a window centered at the pixel , and are some linear coefficients assumed to be constant in . In order to determine the linear coefficients, they minimize the following cost function in the window:


Our feathering block does not use the same form like [10] because we hope to obtain not only an edge-preserving filter, but also a filter with the capacity of matting adaptive. It means the filters can suppress the inaccurate response and obtain a finer matting result. As a result, the guided filter needs to rely on an accurate binary mask while our filter does not. Therefore, the feathering block can be viewed as an extension of the guided filter. We extend the linear transform of the image to the linear transform of the foreground image, the background image as well as the whole image. Moreover, instead of solving the linear regression to obtain the linear coefficients, we leverage a sub-network to optimize the cost function, which should be much faster and reduce the computational complexity.

Figure 5 shows that our feathering block is closely to the guided filter in (He et al., 2013)

. Both the filter of ours and guided filter have high response on the high variance regions. However, it is obvious that there are great distinctions between our filter and guided filter. The differences between our filter and guided filter can be summarized into two aspects briefly:

1. Different inputs. The inputs of guided filter are the image as well as the corresponding binary mask while our inputs are the image and the score maps of the foreground and the background.

2. Different outputs. The output of guided filter is a feathering results relied on an accurate binary mask, while our learnt guided filter outputs an alpha matte or a foreground image, which possesses the fault tolerance to the binary mask.

In fact, our feathering block is matting oriented, therefore, the linear transform model of learnt guided filter in Eq. (3) is inferred from the linear transform model of matting filter in Eq. (2). Thus, our learnt guided filter has multiple product terms but no constant term. Though two filters are derived in different process, they have the same properties such as edge-preserving, which has been proved in Eq. (4). Moreover, Figure 5 shows that our learnable guided filter possesses adaptive matting capacity. The general matting methods like (Levin et al., 2008; Gastal and Oliveira, 2010) would take the neck as the foreground if we define the neck in the image as unknown region, because the gradient between the face and neck is small. However, our method can divide the face and neck into the foreground and background, respectively.

3.2.3. Attention Mechanism

Our proposed feathering block is not only an extension of the guided filter, but also can be interpreted as an attention mechanism. Figure 5 shows several examples of guided filters learnt from the feathering block. Intuitively, it can be interpreted as an attention mechanism, which pays different attention to various parts according to factors. Specially, from the examples in Figure 5, we can infer that the factor pays more attention to the part of object’s body, the factor pays more attention to the part of background, and the factor pays more attention to the part of object’s head. Consequently, it can be inferred that the factors and emphasize the matting problem locally while the factor considers the matting problem globally.

4. Experiments

4.1. Dataset and Implementation

Dataset: We collect the primary dataset from (Shen et al., 2016b)

, which is collected from Flickr. After training on this dataset, we release our app to obtain more data for training. Furthermore, we hired tens of well-trained students to accomplish the annotation work. All the ground truth alpha mattes are labelled with KNN matting

(Chen et al., 2013) firstly, and refined carefully with Photoshop quick selection.

Specially, we labelled the alpha matte in two ways. The first way of labelling is same as (Shen et al., 2016b; Xu et al., 2017), which labels the whole human as the foreground. The second way of labelling only labels the heads of human as the foreground. The head labels help us demonstrate that our proposed method possesses adaptive matting capacity dividing the parts of head and neck precisely. After labelling process, we collect 2,000 images with high-quality mattes, and split them randomly into training and testing sets with 1,800 and 200 images respectively.

For data augmentation, we adopt random mirror and random resize between 0.75 and 1.5 for all images, and additionally add random rotation between -30 and 30 degrees, and random Gaussian blur. This comprehensive data augmentation scheme prevents the network overfitting and greatly improves the performance of our system to handle new images with possibly different scale, rotation, noise and intensity.
Implementation details:

We setup our model training and testing experiments on Caffe platform

(Jia et al., 2014). With the model illustrated in Figure 2

, we use a stochastic gradient descent (SGD) solver with cross-entropy loss function, batch size 256, momentum 0.99 and weight decay 0.0005. We train our model without any further post-processing module nor pre-training. The unknown weights are initialized with random values. Specially, we train our network with a three-stage strategy. Firstly, we train the light dense network with a learning rate of 1e-3 and 1e-4 in the first 10k and the last 10k iterations, respectively. Secondly, the weights in light dense network is fixed and we only train the feathering block with a learning rate set to 1e-6 which will be divided by 10 after 10k iterations. Finally, we train the whole network with a fixed learning rate of 1e-7 for 20k iterations. We found that the three-stage training strategy makes the training process more stable. All experiments on computer are performed on a system of Core E5-2660 @2.60GHz CPU and a single NVIDIA GeForce GTX TITAN X GPU with 12GB memory. We also test our approach on the mobile phone with a Qualcomm Snapdragon 820 MSM8996 CPU and Adreno 530 GPU.

4.2. Head Matting Dataset

Figure 6. Several results from binary mask, binary mask with guided filter, and alpha matte from our feathering block. (a) The original images. (b) The ground truth foreground. (c) The foreground calculated by the binary mask. (d) The foreground calculated by the binary mask with guided filter. (e) The foreground calculated by the binary mask with our feathering block.

Accuracy Measure. We select the gradient error and mean squared error to measure matting quality, which can be expressed as:


where is the predicted matte and is the corresponding ground truth, is the number of pixels in , is the operator to compute gradients.

Approaches CPU (ms) GPU (ms) Grad. Error() MSE ()
Deeplab101 (Chen et al., 2015) 1243 73 3.61 5.84
PSPN101 (Zhao et al., 2017) 1289 76 3.88 7.07
PSPN50 (Zhao et al., 2017) 511 44 3.92 8.04
LDN 27 11 9.14 27.49
Deeplab101+FB 1424 78 3.46 4.23
PSPN101+FB 1343 83 3.37 3.82
PSPN50+FB 548 52 3.64 4.67
LDN+GF 236 220 4.66 15.34
LDN+FB 38 13 3.85 7.98
Table 1. Results on Head Matting Dataset. We compare the components of our proposed system with state-of-the-art semantic segmentation networks Deeplab and PSPN (Chen et al., 2015; Zhao et al., 2017). Light Dense Network (LDN) greatly increases the speed and Feathering Block (FB) deceases the gradient error(Grad. Error) and mean squared error(MSE) greatly in our system. Additionally, our feathering block has a better performance than guided filter (GF).

Method Comparison. We compare several automatic schemes for matting and report the performance of these methods in Table 1. From the results, we can draw the conclusion that our proposed method LDN+FB is efficient and effective. Firstly, comparing the portrait segmentation networks, LDN produces a coarse binary mask, which increases 3 times gradient error and 3 to 5 times mean squared error approximately, compared to the semantic segmentation networks. However, LDN is 20 to 60 times faster than the semantic segmentation networks on CPU. Secondly, taking our feathering block into consideration, we find that FB can refine the portrait segmentation networks with little effort on CPU or GPU. Moreover, the feathering block decreases the gradient error and mean squared error of our proposed LDN greatly, which decreases of the errors approximately. Furthermore, when compared to the guided filter, it deceases 2 times of mean squared error. Thirdly, our proposed LDN+FB structure have comparable accuracies with the combinations of segmentation networks and feathering blocks, while it is 15 to 40 times faster.

Approaches CPU /comp. (ms) GPU /comp. (ms) CPU /phone. (ms) GPU /phone. (ms) Grad. Error ()
DAPM 6000 600 - - 3.03
LDN+FB 38 13 140 62 7.40
Table 2. Results on Human Matting Dataset of (Shen et al., 2016b). DAPM means the approach of Deep Automatic Portrait Matting in (Shen et al., 2016b). LDN means the light dense network and FB means the feathering block. We report our speed on computer(comp.) and mobile phone(phone.) respectively.

Visually, we present the results of binary mask, binary mask with guided filter, and alpha matte from our feathering block in Figure 6. It is obvious that the binary masks are very coarse which lose the edge shape and contain lots of isolated holes. The binary mask with guided filter can fill the holes thereby enhancing the performance of the mask, however, the alpha mattes are over transparent due to the coarse binary mask. In contrast, our proposed system achieves better performance by making the foreground clearer and remaining the edge shape.

In order to illustrate the efficiency and effectiveness of the light dense block and feathering block, we discuss them separably. Firstly, comparing the four portrait segmentation networks, though our light dense network has a low performance, it decreases the computing time greatly, and it can produce a coarse segmentation with 8 convolutional layers. Secondly, the feathering block increases the performances of four portrait segmentation networks. It decreases the error of our proposed light dense network greatly, which holds a comparable results with the best results and keeps a high speed. Additionally, comparing the performances between guided filter and feathering block, we can infer that feathering block outperforms the guided filter in accuracy while keeping a high speed.

4.3. Human Matting Dataset

Furthermore, in order to demonstrate the efficiency and effectiveness of our proposed system. We train our system on the dataset of (Shen et al., 2016b), which contains a training set and a testing set with 1,700 and 300 images respectively, and compare our result with that of their proposed methods.

We report the performance of these automatic matting methods in Table 2. From the reported results, we find that our proposed method increases in gradient error, compared to the error reported in (Shen et al., 2016b). However, our method decreases the time cost of 5962ms on CPU and 587ms on GPU. Consequently, it can be illustrated that our method increases the matting speed greatly while keeping a comparable result with the general alpha matting methods. Moreover, the automatic matting approach proposed in (Shen et al., 2016b) can not run on the CPU of mobile phone because it needs a lot of time to infer the alpha matte. In contrast, our method can not only run on the GPU of mobile phone in real-time, but also has the capacity to run on the CPU of mobile phone.

4.4. Comparison with Fabby

Additionally, we compare our system with Fabby111The app of Fabby can be downloaded on the site, which is a real-time face editing app. The visual results are presented in Figure 7. It is shown that we have better results than that of Fabby. Moreover, we found that Fabby cannot locate the objects such as the cases in former three columns and it fails to process some special cases like the faults in the last three columns. In contrast, our method can hold these cases well.

From the former three columns in Figure 7, we can infer that Fabby needs to detect the objects first, and then computes the alpha matte. As a result, sometimes it is unable to calculate the alpha matte of the whole object. Conversely, our method can calculate the alpha matte of all pixels in an image and thus obtain the opacity of the whole object. Furthermore, Fabby fails to divide the similar background from foreground for the case of the fourth column, and fails to segment the foreground such as collar and shoulder in last two columns, while our method outperforms Fabby in these cases. Consequently, it can be inferred that our light matting network has a more reliable alpha matte than that of Fabby.

Figure 7. The results between our system and real-time editing app Fabby. First row: The input images. Second row: The results from the app Fabby. Third row: The results from our system.
Figure 8. Examples of our real-time portrait animation app.

5. Applications

Since our proposed system is fully automatic and can run fully real-time on mobile phone, a number of applications are enabled, such as fast stylization, color transform, background editing and depth-of-field. Moreover, it can not only process the image matting, but also real-time video matting due to its fast speed. Thus, we establish an app for real-time portrait animation on mobile phone, which is illustrated in Figure 8. Further, we test the speed of our method on the mobile phone with a Qualcomm Snapdragon 820 MSM8996 CPU and an Adreno 530 GPU. When tests on mobile phone, it runs 140ms on the CPU. Furthermore, after applying render script (Latifi Oskouei et al., 2016) to optimize the speed with GPU in Android, our approach takes 62ms on the GPU. Consequently, we can conclude that our proposed method is efficient and effective on mobile devices.

6. Conclusions and Future Work

In this paper, we propose a fast and effective method for image and video matting. Our novel insight is that refining the coarse segmentation mask can be fast and effective than the general image matting methods. We developed a real-time automatic matting method with a light dense network and a feathering block. Besides, the filter learnt by the feathering block possesses edge-preserving and matting adaptive capacity. Finally, a portrait animation system based on fast deep matting is built on mobile devices. Our method does not need any interaction and can realize real-time matting on the mobile phone. The experiments show that our real-time automatic matting method achieves comparable results with the state-of-the-art matting solvers. However, our system fails to distinguish tiny details in the hair areas because we have downsampled the input image. The downsampling operation would provide a more complete result but lose the detailed information. We treat this as the limitation of our method. In future, we will try to improve our method for higher accuracy by combining multiple technologies like object detection (Ren et al., 2015; Chen et al., 2016; Liu et al., 2016; Redmon and Farhadi, 2017), image retargeting (Wang et al., 2016; Qi et al., 2016)

and face detection

(Schroff et al., 2015; Qin et al., 2016; Hu and Ramanan, 2017).


  • (1)
  • Aksoy et al. (2017) Yagız Aksoy, Tunç Ozan Aydın, and Marc Pollefeys. 2017. Designing Effective Inter-Pixel Information Flow for Natural Image Matting. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Chen et al. (2015) Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. 2015. Semantic image segmentation with deep convolutional nets and fully connected crfs. In International Conference on Learning Representations (ICLR), 2015.
  • Chen et al. (2017) Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L. Yuille. 2017. DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs. IEEE transactions on pattern analysis and machine intelligence (2017).
  • Chen et al. (2013) Qifeng Chen, Dingzeyu Li, and Chi-Keung Tang. 2013. KNN matting. IEEE transactions on pattern analysis and machine intelligence 35, 9 (2013), 2175–2188.
  • Chen et al. (2016) Yingying Chen, Jinqiao Wang, Min Xu, Xiangjian He, and Hanqing Lu. 2016. A unified model sharing framework for moving object detection. Signal Processing 124 (2016), 72–80.
  • Cho et al. (2016) Donghyeon Cho, Yu Wing Tai, and Inso Kweon. 2016. Natural Image Matting Using Deep Convolutional Neural Networks. In European Conference on Computer Vision (ECCV), 2016. 626–643.
  • Chuang et al. (2001) Yung-Yu Chuang, Brian Curless, David H Salesin, and Richard Szeliski. 2001. A bayesian approach to digital matting. In Computer Vision and Pattern Recognition (CVPR), 2001. Proceedings of the 2001 IEEE Computer Society Conference on, Vol. 2. IEEE, II–II.
  • Gastal and Oliveira (2010) Eduardo SL Gastal and Manuel M Oliveira. 2010. Shared sampling for real-time alpha matting. In Computer Graphics Forum, Vol. 29. Wiley Online Library, 575–584.
  • Handa et al. (2015) Ankur Handa, Viorica Patraucean, Vijay Badrinarayanan, Simon Stent, and Roberto Cipolla. 2015. SceneNet: Understanding Real World Indoor Scenes With Synthetic Data. CoRR abs/1511.07041 (2015).
  • He et al. (2010) Kaiming He, Jian Sun, and Xiaoou Tang. 2010. Fast matting using large kernel matting laplacian matrices. In Computer Vision and Pattern Recognition (CVPR), 2010 IEEE Conference on. IEEE, 2165–2172.
  • He et al. (2013) Kaiming He, Jian Sun, and Xiaoou Tang. 2013. Guided image filtering. IEEE transactions on pattern analysis and machine intelligence 35, 6 (2013), 1397–1409.
  • Hu and Ramanan (2017) Peiyun Hu and Deva Ramanan. 2017. Finding Tiny Faces. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Huang et al. (2017) Gao Huang, Zhuang Liu, Kilian Q Weinberger, and Laurens van der Maaten. 2017. Densely connected convolutional networks. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Jégou et al. (2017) Simon Jégou, Michal Drozdzal, David Vázquez, Adriana Romero, and Yoshua Bengio. 2017. The One Hundred Layers Tiramisu: Fully Convolutional DenseNets for Semantic Segmentation. In Workshop on Computer Vision in Vehicle Technology CVPR, 2017.
  • Jia et al. (2014) Yangqing Jia, Evan Shelhamer, Jeff Donahue, Sergey Karayev, Jonathan Long, Ross Girshick, Sergio Guadarrama, and Trevor Darrell. 2014. Caffe: Convolutional architecture for fast feature embedding. In Proceedings of the 22nd ACM international conference on Multimedia. ACM, 675–678.
  • Latifi Oskouei et al. (2016) Seyyed Salar Latifi Oskouei, Hossein Golestani, Matin Hashemi, and Soheil Ghiasi. 2016. CNNdroid: GPU-Accelerated Execution of Trained Deep Convolutional Neural Networks on Android. In Proceedings of the 2016 ACM on Multimedia Conference. 1201–1205.
  • Levin et al. (2008) Anat Levin, Dani Lischinski, and Yair Weiss. 2008. A closed-form solution to natural image matting. IEEE Transactions on Pattern Analysis and Machine Intelligence 30, 2 (2008), 228–242.
  • Liu et al. (2016) Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott E. Reed, Cheng-Yang Fu, and Alexander C. Berg. 2016. SSD: Single Shot MultiBox Detector. In ECCV.
  • Long et al. (2015) Jonathan Long, Evan Shelhamer, and Trevor Darrell. 2015. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 3431–3440.
  • Paszke et al. (2016) Adam Paszke, Abhishek Chaurasia, Sangpil Kim, and Eugenio Culurciello. 2016. Enet: A deep neural network architecture for real-time semantic segmentation. arXiv preprint arXiv:1606.02147 (2016).
  • Peng et al. (2017) Chao Peng, Xiangyu Zhang, Gang Yu, Guiming Luo, and Jian Sun. 2017. Large Kernel Matters - Improve Semantic Segmentation by Global Convolutional Network. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Qi et al. (2016) Shaoyu Qi, Yu-Tseh Chi, Adrian M. Peter, and Jeffrey Ho. 2016. CASAIR: Content and Shape-Aware Image Retargeting and Its Applications. IEEE Transactions on Image Processing 25 (2016), 2222–2232.
  • Qin et al. (2016) Hongwei Qin, Junjie Yan, Xiu Li, and Xiaolin Hu. 2016. Joint Training of Cascaded CNN for Face Detection. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (2016), 3456–3465.
  • Redmon and Farhadi (2017) Joseph Redmon and Ali Farhadi. 2017. YOLO9000: Better, Faster, Stronger. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Ren et al. (2015) Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. 2015. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Transactions on Pattern Analysis and Machine Intelligence 39 (2015), 1137–1149.
  • Schroff et al. (2015) Florian Schroff, Dmitry Kalenichenko, and James Philbin. 2015. FaceNet: A unified embedding for face recognition and clustering. 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (2015), 815–823.
  • Shen et al. (2016a) Xiaoyong Shen, Aaron Hertzmann, Jiaya Jia, Sylvain Paris, Brian Price, Eli Shechtman, and Ian Sachs. 2016a. Automatic portrait segmentation for image stylization. In Computer Graphics Forum, Vol. 35. Wiley Online Library, 93–102.
  • Shen et al. (2016b) Xiaoyong Shen, Xin Tao, Hongyun Gao, Chao Zhou, and Jiaya Jia. 2016b. Deep Automatic Portrait Matting. In European Conference on Computer Vision. Springer, 92–107.
  • Sun et al. (2004) Jian Sun, Jiaya Jia, Chi-Keung Tang, and Heung-Yeung Shum. 2004. Poisson matting. In ACM Transactions on Graphics (ToG), Vol. 23. ACM, 315–321.
  • Szegedy et al. (2016) Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alex A. Alemi. 2016.

    Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning. In

    ICLR 2016 Workshop.
  • Wang et al. (2008) Jinqiao Wang, Ling-Yu Duan, Qingshan Liu, Hanqing Lu, and Jesse S. Jin. 2008. A Multimodal Scheme for Program Segmentation and Representation in Broadcast Video Streams. IEEE Trans. Multimedia 10 (2008), 393–408.
  • Wang et al. (2014) Jinqiao Wang, Wei Fu, Hanqing Lu, and Songde Ma. 2014. Bilayer Sparse Topic Model for Scene Analysis in Imbalanced Surveillance Videos. IEEE Transactions on Image Processing 23 (2014), 5198–5208.
  • Wang et al. (2016) Jinqiao Wang, Zhan Qu, Yingying Chen, Tao Mei, Min Xu, La Zhang, and Hanqing Lu. 2016. Adaptive Content Condensation Based on Grid Optimization for Thumbnail Image Generation. IEEE Trans. Circuits Syst. Video Techn. 26 (2016), 2079–2092.
  • Xu et al. (2017) Ning Xu, Brian Price, Scott Cohen, and Thomas Huang. 2017. Deep Image Matting. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Yu and Koltun (2016) Fisher Yu and Vladlen Koltun. 2016. Multi-scale context aggregation by dilated convolutions. In International Conference on Learning Representations (ICLR), 2016.
  • Zhao et al. (2017) Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, Xiaogang Wang, and Jiaya Jia. 2017. Pyramid Scene Parsing Network. In Computer Vision and Pattern Recognition (CVPR), 2017.
  • Zhou et al. (2016) Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. 2016. Semantic Understanding of Scenes through the ADE20K Dataset. CoRR abs/1608.05442 (2016).