This application provides a method for extracting the foreground edge of a green screen based on edge
sharpening processing. First, the original image is acquired and the background and foreground are determined, generating a first
mask for initial separation. Edge regions are marked and assigned affixation labels based on the first
mask, and
color gradient changes and consistency features are calculated to provide a basis for identifying abnormal pixels. An abnormal pixel set is formed by filtering edge pixels under dual conditions to determine the correction target. Reference pixels are filtered based on spatial distance and texture matching, and weighted correction weights are determined to provide an accurate basis for filling. Abnormal pixels are filled using the
local color mean and weighted weights to generate a second
mask, forming a mask with higher
color consistency. The second mask is fused with the target virtual
background image; if the boundary gradient change exceeds the limit,
feathering is used to eliminate boundary abrupt changes. Finally, the fused image is verified; if continuity is not met, neighborhood interpolation is used for adjustment, and the final image is output, repairing local anomalies and completing the background replacement loop.