The popularity of short video formats has led to frequent use of visual effects on mobile devices,among which effects related to portraits are now a core part of many special effects algorithms.Portrait effects are achieved by deploying convolutional neural network models on mobile devices,providing users with capabilities such as beautification,contouring,and portrait segmentation.With the development of neural network architecture and lightweight technology,models deployed on mobile devices are gradually transitioning to more lightweight and real-time architectures,achieving smooth and realistic special effects.However,due to the insufficient computing power of mobile devices and the complex and variable shooting environment,the accuracy and robustness of portrait segmentation are facing significant challenges.Furthermore,pasting the segmented portrait onto a new background can result in contrast distortion,color disharmony,and other issues.This article mainly focuses on how to improve portrait segmentation in mobile device scenarios and use image harmonization algorithms to process the results of segmentation to obtain natural and harmonious composite images.First,this article proposes a new portrait segmentation algorithm that comprehensively considers portrait image features and device computing capabilities to address the issues of improving the inference speed and refinement level of portrait segmentation.Additionally,optical flow algorithms are used to optimize real-time segmentation and reduce interference caused by occlusion and deformation between adjacent frames.The algorithm uses a spatial information compression module to extract features,reducing parameter volume,increasing running speed,and effectively filtering out low-relevance features through the introduction of an attention mechanism,refining the segmentation results at the edge points.Secondly,considering the inconsistent lighting and texture in the composite images after portrait segmentation,this article proposes an image harmonization algorithm based on lighting-aware style transfer.By extracting style features and lighting features through the style feature backbone network and lighting estimation module,respectively,and designing a lighting transfer strategy,style features and lighting features are adaptively fused,achieving harmonization operations for composite images under different shooting environments and enabling portraits to blend more naturally into the background.Finally,this article designs and implements a visual effects processing system based on mobile devices,and tests the system’s functionality and performance,verifying the system’s usability and the effectiveness of the proposed methods. |