| With the flourishing development and dissemination of the Internet, as people are increasingly seeking their own personality, the highly realistic facial images or videos which are automatically synthesized by the computer, have broad application prospects in the field of computer animation, computer graphics, etc.By analyzing and summarizing the advantages and disadvantages of the current methods of face replacement, the paper improves some key steps. We design and implement a new automatic face replacement system, which can obtain new synthetic images with the source image’s facial feature and the target image’s modeling and background. Include the following steps:Firstly, align the source image and the target image. Secondly, combining with the skin color cross-dissolve method, find the best stitching line in the face region and achieve the seamless synthesis of the facial image. Lastly, accomplish the inpainting of the synthesized facial image in the hair region where needs further repair.In the process of face replacement, a face alignment method based on image morphing is proposed. Estatblish a mathematical model based on the facial feature points is established, which expresses the mapping of the position and shape of the face. The thin plate spline algorithm is applied in the facial image morphing. The new alignment method avoids the traditional, complex and time-consuming3D face model.In order to find the best seam with smallest difference in the aligned face images, a planning method for optimizing the stitching line based on the A*algorithm is adopted, which is suitable for the facial images with different hairstyle and different background. In the process of image fusion, we present an adaptive weighted average method, which can effectively make the transition of the stitching boundary natural and smooth.The hair region of the synthesized facial images may be vulnerable to the hairstyles, hair accessories and other factors, which will cause the partially "missing" or "damaged" phenomena. Based on the Criminisi algorithm, the paper proposes a repair-trend-restricted image inpainting method which effectively overcome the difficulty of the inpainting in the hair region. Finally, the paper builds the face replacement system based on the mobile platform. Under the condition of the input images with similar hairstyle and posture, the experiments show that this automatic face replacement method can reach a success rate of over90%for natural images, and the synthetic result images are highly realistic. |