CN-121982055-A - Portrait segmentation and fusion optimization processing method, device and equipment based on multiple models
Abstract
The invention discloses a multi-model-based portrait segmentation and fusion optimization processing method, device and equipment, which relate to the technical field of image processing and comprise the steps of adopting a first portrait segmentation model to carry out foreground preservation and background removal processing on an input source image to obtain a background removal segmentation image; the method comprises the steps of carrying out a face matting process on a source image in parallel by adopting a second face matting segmentation model to obtain a face matting segmentation image, carrying out a morphological dilation pixel operation and a corrosion pixel operation on the background removal segmentation image in parallel to obtain a first image and a second image respectively, carrying out an image intersection on the first image and the face matting segmentation image to obtain a third image, carrying out fusion on the second image and the third image to obtain a fused image, carrying out connected domain analysis, carrying out character segmentation on the fused image, and cutting different character bodies in the image into independent images. The invention can fuse the multi-model segmentation result and improve the matting quality through morphological operation and intelligent fusion strategy.
Inventors
- YUAN JIAHAO
- Ke Fanhui
- GONG YUMING
Assignees
- 深圳市酷开网络科技股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260114
Claims (10)
- 1. A portrait segmentation and fusion optimization processing method based on multiple models is characterized by comprising the following steps: acquiring a source image to be subjected to human image segmentation, and preprocessing the source image; Performing foreground preservation and background removal processing on the preprocessed source image by adopting a first human segmentation model to obtain a background removal segmentation image; carrying out a portrait matting process on the preprocessed source image by adopting a second portrait segmentation model in parallel to obtain a portrait matting segmentation image complementary with the background removal segmentation image; performing morphological dilation pixel operation on the background removal segmentation image to obtain a first image, and performing morphological erosion pixel operation on the background removal segmentation image to obtain a second image; The first image subjected to the pixel expansion operation and the image matting segmentation image are subjected to image intersection, an intersection area is extracted to obtain a third image, and the second image subjected to the pixel erosion operation and the third image are subjected to weighted fusion to generate a fused image; And carrying out connected domain analysis on the transparency value channels of the fused image, removing the non-transparent area of the designated area, carrying out character segmentation on the fused image, and cutting different character bodies in the image into independent images.
- 2. The method for optimizing human image segmentation and fusion based on multiple models according to claim 1, wherein the step of acquiring a source image to be subjected to human image segmentation and preprocessing the source image comprises: And receiving and acquiring a source image with any size and format, which is required to be subjected to image segmentation, and storing the source image as a temporary file.
- 3. The method for optimizing image segmentation and fusion based on multiple models according to claim 1, wherein the step of performing foreground preservation and background removal processing on the preprocessed source image by using a first image segmentation model to obtain a background removal segmentation image, and performing image matting processing on the preprocessed source image by using a second image segmentation model in parallel to obtain an image matting segmentation image complementary to the background removal segmentation image comprises the steps of: invoking a first segmentation model adopting a background removal algorithm, and carrying out foreground preservation and background removal processing on the preprocessed source image to obtain a background removal segmentation RGBA image; and calling a second segmentation model adopting a portrait matting algorithm in parallel, and carrying out portrait matting processing on the preprocessed source image to obtain a portrait matting segmentation RGBA image complementary with the background removal segmentation image.
- 4. The method for optimizing human image segmentation and fusion based on multiple models as set forth in claim 1, wherein the step of performing morphological dilation pixel operation on the background removed segmented image to obtain a first image, and performing morphological erosion pixel operation on the background removed segmented image to obtain a second image comprises: Performing morphological dilation pixel operation on the background removal segmentation image, expanding a preset area for a non-transparent area, and compensating edge contraction to obtain a first image; Performing morphological corrosion pixel operation on the background removed segmented image, shrinking a preset area on a non-transparent area, and removing edge burrs or noise points to obtain a second image; The morphological kernel size is configurable.
- 5. The method for optimizing human image segmentation and fusion based on multiple models according to claim 1, wherein the step of intersecting the first image subjected to the dilation pixel operation with the human image matting segmented image to extract an intersection region to obtain a third image comprises: And carrying out image intersection on the first image subjected to the expansion pixel operation and the portrait matting segmentation image, extracting an RGBA value of an intersection region retention source image, and selecting a minimum transparency value to obtain a third image.
- 6. The method for optimizing human image segmentation and fusion based on multiple models according to claim 5, wherein the step of performing weighted fusion on the second image subjected to the pixel erosion operation and the third image to generate a fused image comprises: And carrying out weighted fusion on the second image subjected to pixel corrosion operation and the third image, selecting a maximum transparency value of a reserved complete contour, and mixing RGBA values according to transparency value weights to generate a fused image.
- 7. The method for optimizing human image segmentation and fusion based on multiple models according to claim 1, wherein the steps of performing connected domain analysis on transparency value channels of the fused image, removing non-transparent areas of the designated areas, performing human image segmentation on the fused image, and cutting different human subjects in the image into independent images comprise: Carrying out connected domain analysis on the transparency value channels of the fused image, and removing a non-transparent region with the area smaller than n% of the total area of the image, wherein the value of n is 0.5-30; When a person separation function starting instruction is detected, carrying out example segmentation on the fused image, and cutting different person main bodies in the image into independent images; and outputting the final matted image, the number of people and the segmented single image list, and automatically cleaning the temporary file.
- 8. Portrait segmentation and fusion optimization processing device based on multiple models, which is characterized by comprising: The image acquisition and preprocessing module is used for acquiring a source image to be subjected to human image segmentation and preprocessing the source image; The multi-model segmentation module is used for carrying out foreground preservation and background removal processing on the preprocessed source image by adopting a first human segmentation model to obtain a background removal segmentation image; The morphological processing module is used for performing morphological dilation pixel operation on the background removal segmentation image to obtain a first image, and performing morphological erosion pixel operation on the background removal segmentation image to obtain a second image; The weighted fusion generation module is used for carrying out image intersection on the first image subjected to the expansion pixel operation and the portrait matting segmentation image, extracting an intersection area to obtain a third image, carrying out weighted fusion on the second image subjected to the corrosion pixel operation and the third image, and generating a fused image; The segmentation and output processing module is used for carrying out connected domain analysis on the transparency value channels of the fused image, removing the non-transparent area of the designated area, carrying out character segmentation on the fused image, and cutting different character bodies in the image into independent images.
- 9. A terminal device comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising steps for performing the method of any of claims 1-7.
- 10. A computer readable storage medium, on which a computer program is stored which, when being executed by a processor, enables an electronic device to perform the steps of the method according to any one of claims 1-7.
Description
Portrait segmentation and fusion optimization processing method, device and equipment based on multiple models Technical Field The present invention relates to the field of image processing technologies, and in particular, to a method, an apparatus, a terminal device, and a storage medium for optimizing image segmentation and fusion based on multiple models. Background In video advertising, intelligent photo album, virtual fitting, etc., it is often necessary to automatically and accurately extract a single person body (i.e., a person's image matting) from an original image containing multiple persons or complex backgrounds. The traditional method in the prior art relies on manual operation of a professional designer, and has low efficiency and high cost. Some image matting automation schemes also exist in the prior art, and a semantic segmentation model based on deep learning is adopted, such as RMBG (background removal), MODNet (polymorphic object matting network), baiduAI (hundred-degree artificial intelligence image segmentation) image segmentation and the like. However, the prior art is based on a single model, and has the following defects: the precision is unstable, and the difference of the detailed processing capacities of different models on hair, transparent clothes, blurred edges and the like is large. Therefore, an end-to-end portrait segmentation optimization scheme is needed that can fuse multi-model segmentation results, promote matting quality through morphological operations and intelligent fusion strategies, and support subsequent person separation. Accordingly, there is a need for improvement and development in the art. Disclosure of Invention In order to solve the technical problems, the invention provides a multi-model-based portrait segmentation and fusion optimization processing method, a multi-model-based portrait segmentation and fusion optimization device, terminal equipment and a storage medium. The technical scheme of the application is as follows: A portrait segmentation and fusion optimization processing method based on multiple models comprises the following steps: a, acquiring a source image to be subjected to human image segmentation, and preprocessing the source image; B, carrying out foreground preservation and background removal processing on the preprocessed source image by adopting a first human image segmentation model to obtain a background removal segmentation image; carrying out a portrait matting process on the preprocessed source image by adopting a second portrait segmentation model in parallel to obtain a portrait matting segmentation image c complementary with the background removal segmentation image; c, performing morphological dilation pixel operation on the background removal segmentation image to obtain a first image a, and performing morphological erosion pixel operation on the background removal segmentation image to obtain a second image b; D, carrying out image intersection on the first image a subjected to the expansion pixel operation and the portrait matting segmentation image c, extracting an intersection area to obtain a third image D, and carrying out weighted fusion on the second image b subjected to the corrosion pixel operation and the third image D to generate a fused image; e, carrying out connected domain analysis on the transparency value channels of the fused image, removing the non-transparent area of the designated area, carrying out character segmentation on the fused image, and cutting different character bodies in the image into independent images. The method for optimizing the human image segmentation and fusion based on the multiple models, wherein the steps of acquiring the source image to be subjected to human image segmentation and preprocessing the source image comprise the following steps: And receiving and acquiring a source image with any size and format, which is required to be subjected to image segmentation, and storing the source image as a temporary file. The method for optimizing the human image segmentation and fusion based on multiple models comprises the steps of carrying out foreground preservation and background removal processing on the preprocessed source image by adopting a first human image segmentation model to obtain a background removal segmentation image, carrying out human image matting processing on the preprocessed source image by adopting a second human image segmentation model in parallel to obtain a human image matting segmentation image c complementary with the background removal segmentation image, wherein the steps comprise: invoking a first segmentation model adopting a background removal algorithm, and carrying out foreground preservation and background removal processing on the preprocessed source image to obtain a background removal segmentation RGBA image; And calling a second segmentation model adopting a portrait matting algorithm in parallel, and carrying out portrait matting processing o