Human image background blurring method and system

By obtaining the focus frame and depth map of the portrait image, the images taken by the mobile phone are blurred and de-blended, which solves the problem of poor background blur effect in mobile phone photography, and achieves the aesthetic effect of a large aperture shallow depth of field.

CN120013749APending Publication Date: 2025-05-16FACEUNITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510158696.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

It is difficult to achieve physical background blur in taking pictures on mobile phones, resulting in poor image effects and lack of the beauty of a large aperture and shallow depth of field.

Method used

By obtaining the focus frame and depth map of the portrait image, combined with the blurring technology, the image is globally blurred and the portrait part is de-blended to achieve the background blurring effect.

Benefits of technology

Effectively simulate the image effect with a large aperture shallow depth of field, highlight the image subject, enhance the aesthetics, and provide a full-link background blur solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120013749A_ABST
    Figure CN120013749A_ABST
Patent Text Reader

Abstract

The invention discloses a portrait image background blurring method, and belongs to the technical field of image processing. The method comprises the following steps: acquiring a portrait image; performing global blurring processing on the portrait image to obtain a blurred image; and carrying out portrait part de-blurring processing on the blurred image to obtain a background blurred image. The invention provides a full-link solution for background blurring of an image in mobile phone photographing, which mainly comprises two parts, one part is to carry out overall blurring processing on a global image, and the other part is to obtain a main body part of the image through image matting and carry out de-blurring processing on the main body part to ensure the definition of the main body part.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for blurring the background of a portrait image. Background Art

[0002] Background blur is an image processing technology that blurs the background area of ​​an image in order to highlight the main subject of the image. In mobile phone photography, it is difficult to achieve a physical blur effect due to the influence of hardware factors such as the mobile phone lens and sensor. Through the background blur processing method, it is possible to better simulate the image effect of a large aperture, shallow depth of field, and large bokeh, which is more subjectively beautiful. Summary of the invention

[0003] The purpose of the present invention is to provide a method and system for blurring the background of a portrait image

[0004] In order to solve the above technical problems, the present invention provides a method for blurring the background of a portrait image, which is characterized by comprising the following steps:

[0005] Get a portrait image;

[0006] Performing global blur processing on the portrait image to obtain a blurred image;

[0007] The portrait part of the blurred image is deblurred to obtain a background blurred image.

[0008] Preferably, obtaining a portrait image specifically includes the following steps:

[0009] Use the mobile phone camera to take pictures and obtain portrait images.

[0010] Preferably, performing global blur processing on the portrait image specifically includes the following steps:

[0011] Get the focus frame of the portrait image;

[0012] Get the depth map of the portrait image;

[0013] The depth map is blurred according to the focus frame to obtain a blurred image.

[0014] Preferably, obtaining a depth map of a portrait image specifically includes the following steps:

[0015] Determine the mode of the mobile phone lens; the modes of the mobile phone lens include single-camera lens, dual-camera lens and TOF lens;

[0016] For the TOF lens, it is determined that a depth map needs to be calculated, and the portrait image is used as the depth map;

[0017] For a dual-camera lens, determine whether it is necessary to calculate a depth map; when it is determined that it is necessary to calculate a depth map, perform stereo matching on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map;

[0018] For a single camera, it is determined that a depth map needs to be calculated, and the portrait image is processed based on deep learning technology to obtain a depth map.

[0019] Preferably, for a dual-camera lens, it is determined whether a depth map needs to be calculated; when it is determined that a depth map needs to be calculated, stereo matching is performed on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map, specifically including the following steps:

[0020] The internal and external parameters of the portrait image are obtained through image calibration, and the projection relationship between the camera coordinate system and the image coordinate system is obtained;

[0021] Perform Gaussian blur on the portrait image, calculate the gradient information of the image through the Sobel gradient operator, extract the image edge by thresholding the gradient amplitude, and calculate the ratio of edge pixels to total pixels;

[0022] When the ratio of edge pixels to total pixels is less than the preset ratio threshold, the portrait image is judged to be dirty and the depth map is not calculated;

[0023] When the ratio of edge pixels to total pixels is greater than or equal to the preset ratio threshold, it is determined that there is no dirt in the portrait image. Through the internal and external parameters of the two cameras, for the two input RGB images, it is necessary to use the internal parameters of the two cameras to perform image distortion correction, and use the external parameters to perform stereo correction on the images; stereo matching is performed on the two corrected RGB images to determine the position difference of the photographed object in the two frames of images, thereby obtaining a depth map.

[0024] Preferably, the calibration of the internal reference uses the Zhang Zhengyou calibration method, and the internal reference includes fx, fy, cx, cy, and distortion coefficients [k1, k2, p1, p2, k3];

[0025] The external parameters are the rotation R and translation T relationship between the two camera coordinate systems. The feature point detection algorithm is used to extract feature points in the two rectified images respectively, and then the feature point matching algorithm is used to find the matching point pairs in the two images. The matching point pairs and the camera intrinsic parameter matrix are used to solve the essential matrix.

[0026] Preferably, blurring the depth map according to the focus frame to obtain a blurred image specifically includes the following steps:

[0027] When the depth map is not calculated, the portrait image I is blurred to obtain f(I), and the calculation formula is:

[0028] I blur =K*f(I)

[0029] Where: I blur represents the global blurred image, K∈[0,1] is the preset blur intensity, and f represents the blur method;

[0030] When calculating the depth map, the average depth value d corresponding to the focus frame position in the depth map is obtained according to the focus frame. f , traverse the image pixels at that position in the portrait image, calculate the blur intensity of each pixel according to its depth value, and the blur intensity value k of the i-th pixel i It can be expressed as:

[0031] k i = abs(d i -d f )*K

[0032] Where: d i ∈[0,1] represents the depth value of the current pixel, and abs represents the absolute value in mathematical calculation;

[0033] When the blur intensity value of the current pixel point is less than the preset intensity threshold, it is not blurred; when the blur intensity value of the current pixel point is greater than or equal to the preset intensity threshold, it is blurred.

[0034] Preferably, the blurred image is subjected to a portrait portion deblurring process to obtain a background blurred image, which specifically includes the following steps:

[0035] Perform matting processing on the portrait image to obtain a matting image;

[0036] According to the matting image, the corresponding part of the blurred image is deblurred to obtain a blurred background image. blur The calculation formula is:

[0037] I out =I α I blur +(JI α )·I

[0038] Where: J represents a matrix of all 1s, · represents matrix multiplication, I blur represents the global blurred image, I represents the input image, and I α Represents the matting image, with a value range of [0,1].

[0039] The present invention also provides a system for blurring the background of a portrait image, comprising:

[0040] An acquisition module, used for acquiring a portrait image;

[0041] A blur processing module is used to perform global blur processing on the portrait image to obtain a blurred image;

[0042] The deblurring processing module is used to perform deblurring processing on the portrait part of the deblurred image to obtain a background deblurred image.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] The present invention provides a full-link solution for background blurring of images in mobile phone photography, which mainly includes two parts: one part is to perform overall blurring processing on the global image, and the other part is to obtain the main part of the image through image matting and deblur it to ensure the clarity of the main part. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The specific implementation modes of the present invention are further described in detail below with reference to the accompanying drawings.

[0046] Figure 1 The present invention is a flowchart of a method for blurring the background of a portrait image;

[0047] Figure 2 is a flow chart for obtaining the focus area;

[0048] Figure 3 is a flowchart for obtaining a depth map;

[0049] Figure 4 It is a flow chart of dirt detection;

[0050] Figure 5 It is the depth map acquisition process of the dual camera lens;

[0051] Figure 6 It is a global blurring flow chart;

[0052] Figure 7 This is a result of blurring the background of the portrait image in Example 1. DETAILED DESCRIPTION

[0053] Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited to the specific implementation disclosed below.

[0054] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0055] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0056] The present invention is further described in detail below in conjunction with the accompanying drawings:

[0057] The present invention provides a method for blurring the background of a portrait image, comprising the following steps:

[0058] Get a portrait image;

[0059] Performing global blur processing on the portrait image to obtain a blurred image;

[0060] The portrait part of the blurred image is deblurred to obtain a background blurred image.

[0061] Preferably, obtaining a portrait image specifically includes the following steps:

[0062] Use the mobile phone camera to take pictures and obtain portrait images.

[0063] Preferably, performing global blur processing on the portrait image specifically includes the following steps:

[0064] Get the focus frame of the portrait image;

[0065] Get the depth map of the portrait image;

[0066] The depth map is blurred according to the focus frame to obtain a blurred image.

[0067] Preferably, obtaining a depth map of a portrait image specifically includes the following steps:

[0068] Determine the mode of the mobile phone lens; the modes of the mobile phone lens include single-camera lens, dual-camera lens and TOF lens;

[0069] For the TOF lens, it is determined that a depth map needs to be calculated, and the portrait image is used as the depth map;

[0070] For a dual-camera lens, determine whether it is necessary to calculate a depth map; when it is determined that it is necessary to calculate a depth map, perform stereo matching on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map;

[0071] For a single camera, it is determined that a depth map needs to be calculated, and the portrait image is processed based on deep learning technology to obtain a depth map.

[0072] Preferably, for a dual-camera lens, it is determined whether a depth map needs to be calculated; when it is determined that a depth map needs to be calculated, stereo matching is performed on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map, specifically including the following steps:

[0073] The internal and external parameters of the portrait image are obtained through image calibration, and the projection relationship between the camera coordinate system and the image coordinate system is obtained;

[0074] Perform Gaussian blur on the portrait image, calculate the gradient information of the image through the Sobel gradient operator, extract the image edge by thresholding the gradient amplitude, and calculate the ratio of edge pixels to total pixels;

[0075] When the ratio of edge pixels to total pixels is less than the preset ratio threshold, the portrait image is judged to be dirty and the depth map is not calculated;

[0076] When the ratio of edge pixels to total pixels is greater than or equal to the preset ratio threshold, it is determined that there is no dirt in the portrait image. Through the internal and external parameters of the two cameras, for the two input RGB images, it is necessary to use the internal parameters of the two cameras to perform image distortion correction, and use the external parameters to perform stereo correction on the images; stereo matching is performed on the two corrected RGB images to determine the position difference of the photographed object in the two frames of images, thereby obtaining a depth map.

[0077] Preferably, the calibration of the internal reference uses the Zhang Zhengyou calibration method, and the internal reference includes fx, fy, cx, cy, and distortion coefficients [k1, k2, p1, p2, k3];

[0078] The external parameters are the rotation R and translation T relationship between the two camera coordinate systems. The feature point detection algorithm is used to extract feature points in the two rectified images respectively, and then the feature point matching algorithm is used to find the matching point pairs in the two images. The matching point pairs and the camera intrinsic parameter matrix are used to solve the essential matrix.

[0079] Preferably, blurring the depth map according to the focus frame to obtain a blurred image specifically includes the following steps:

[0080] When the depth map is not calculated, the portrait image I is blurred to obtain f(I), and the calculation formula is:

[0081] I blur =K*f(I)

[0082] Where: I blur represents the global blurred image, K∈[0,1] is the preset blur intensity, and f represents the blur method;

[0083] When calculating the depth map, the average depth value d corresponding to the focus frame position in the depth map is obtained according to the focus frame. f , traverse the image pixels at that position in the portrait image, calculate the blur intensity of each pixel according to its depth value, and the blur intensity value k of the i-th pixel i It can be expressed as:

[0084] k i = abs(d i -d f )*K

[0085] Where: d i ∈[0,1] represents the depth value of the current pixel, and abs represents the absolute value in mathematical calculation;

[0086] When the blur intensity value of the current pixel point is less than the preset intensity threshold, it is not blurred; when the blur intensity value of the current pixel point is greater than or equal to the preset intensity threshold, it is blurred.

[0087] Preferably, the blurred image is subjected to a portrait portion deblurring process to obtain a background blurred image, which specifically includes the following steps:

[0088] Perform matting processing on the portrait image to obtain a matting image;

[0089] According to the matting image, the corresponding part of the blurred image is deblurred to obtain a blurred background image. blur The calculation formula is:

[0090] I out =I α I blur +(JI α )·I

[0091] Where: J represents a matrix of all 1s, · represents matrix multiplication, I blur represents the global blurred image, I represents the input image, and I α Represents the matting image, with a value range of [0,1].

[0092] The present invention also provides a system for blurring the background of a portrait image, comprising:

[0093] An acquisition module, used for acquiring a portrait image;

[0094] A blur processing module is used to perform global blur processing on the portrait image to obtain a blurred image;

[0095] The deblurring processing module is used to perform deblurring processing on the portrait part of the deblurred image to obtain a background deblurred image.

[0096] In order to better illustrate the technical effect of the present invention, the present invention provides the following specific embodiments to illustrate the above technical process:

[0097] Embodiment 1: The present invention provides a method for blurring the background of a portrait image. Figure 1 As shown, the following steps are included:

[0098] 1. Global blur of the image

[0099] Perform global blurring on the input image (portrait image). First, you need to calculate the depth map. The depth map indicates the distance between the object in the image and the phone lens. By blurring the image in combination with the depth map, the blurring effect of the image can be more realistic and the overall image has a more layered feel. After obtaining the depth map, the blurring degree map of the image is obtained in combination with the focus area, and the image is globally blurred in combination with the blurring degree map. Otherwise, use the preset blurring intensity to globally blur the image.

[0100] 1.1 Depth map acquisition

[0101] Before calculating the depth map, it is necessary to first obtain the focus area of ​​the portrait image. When the default focus mode of the mobile phone is used, the focus frame is obtained by face detection. The face detection method can be implemented by any known technology, which will not be described in detail in the present invention. Otherwise, the corresponding focus frame is obtained by the user's manual focus mode.

[0102] The flowchart for obtaining the focus area is as follows Figure 2 As shown;

[0103] At the same time, the depth map is obtained according to the phone's lens mode. There are three lens modes: single camera, dual camera and TOF lens.

[0104] The flowchart for obtaining the depth map is as follows Figure 3 As shown;

[0105] First, determine whether the lens is a TOF lens. If the lens is a TOF lens, the depth map can be directly obtained. The TOF lens continuously sends light pulses to the target, and then uses the sensor to receive the light returned from the object, and obtains the distance of the target by detecting the flight (round-trip) time of the light pulse. This technology is basically similar to the principle of 3D laser sensors, except that 3D laser sensors scan point by point, while TOF cameras obtain the depth (distance) information of the entire image at the same time.

[0106] Otherwise, further determine whether the lens is a dual-camera lens. Since the field of view of the dual-camera lens is different, the depth image can be obtained according to the stereo matching algorithm of the binocular image. Before the image is stereo matched, the binocular lens needs to be preprocessed, and the internal and external parameters of the image are obtained through image calibration to obtain the projection relationship between the camera coordinate system and the image coordinate system. The calibration of the internal parameters can use the Zhang Zhengyou calibration method. The internal parameters of the camera include fx, fy, cx, cy, and distortion coefficients [k1, k2, p1, p2, k3]. The external parameters of the camera are the rotation R and translation T relationship between the two camera coordinate systems. The feature point detection algorithm (such as SIFT, SURF, ORB, etc.) is used to extract feature points in the two corrected images. Then, the feature point matching algorithm (such as FLANN, BFMatcher, etc.) is used to find the matching point pairs in the two images. Using the matching point pairs and the camera internal parameter matrix, the essential matrix is ​​solved by mathematical methods (such as OpenCV's findEssentialMat function, etc.). The essential matrix describes the rotation and translation relationship between the two camera coordinate systems.

[0107] Perform dirt detection on the input RGB image (portrait image). If the image is dirty, it will affect the subsequent stereo matching results and make the calculated depth map inaccurate. First, perform Gaussian blur on the image, then calculate the gradient information of the image through the Sobel gradient operator, and extract the image edge by thresholding the gradient amplitude. Calculate the ratio of edge pixels to total pixels. When the ratio is less than the preset threshold, it is determined that the current image is dirty and the depth map of the image is not calculated.

[0108] The flowchart of dirt detection is as follows Figure 4 As shown;

[0109] When the image is not dirty, the internal and external parameters of the two cameras are used to correct the distortion of the two input RGB images (such as undistort in OPENCV) and use the external parameters to perform stereo correction on the images (such as stereoRectify in OPENCV) to ensure that the two input images are in the same world coordinate system. Stereo matching is performed on the two corrected RGB images to determine the position difference of the photographed object in the two frames of images, so as to obtain the depth information of the image. Stereo matching can be achieved through deep learning methods, such as the CREStereo method, which will not be explained here.

[0110] The process of obtaining the depth map of the dual camera is as follows: Figure 5 As shown;

[0111] When the lens is not a dual-camera lens, the depth map of the single-camera lens can be obtained through many existing deep learning methods, such as the ZoeDepth method, which will not be described in detail here.

[0112] 1.2 Global blur

[0113] When the depth map is not calculated, the input image I (portrait image) is blurred to obtain f(I), and the final output blurred image is:

[0114] I blur =K*f(I)

[0115] Among them I blur represents the global blurred image, K∈[0,1] is the preset blur intensity, and f represents the blur method, which can be achieved by any known method such as Gaussian filtering.

[0116] After the depth map is calculated, the average depth value d in the corresponding focus frame is obtained according to the focus frame coordinates. f Traverse the image pixels and calculate the blur intensity of each pixel according to its depth value. The blur intensity value k of the i-th pixel is i It can be expressed as:

[0117] k i = abs(d i -d f )*K

[0118] where d i ∈[0,1] represents the depth value of the current pixel, and abs represents the absolute value in mathematical calculation. When the blur intensity value of the current pixel is less than the preset intensity threshold, it will not be blurred.

[0119] The flowchart of global blurring is as follows Figure 6 As shown;

[0120] 2. Image cutout and deblurring

[0121] The input image is matted, the color and transparency of the subject are calculated, and the subject is extracted from the image. The subject area is deblurred by masking, and only the blur effect of the non-subject area is retained. This highlights the main part of the image. The final output image I blur It can be expressed as:

[0122] I out =I α I blur +(JI α )·I

[0123] Where J represents a matrix of all 1s, · represents matrix multiplication, and I blur represents the global blurred image, I represents the input image, and I α Represents a matting image, with a value range of [0,1]. Images can be matted using deep learning methods, such as the MattingV2 method.

[0124] The result of blurring the background of the portrait image in Example 1 is shown in FIG. Figure 7 shown.

[0125] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules, modules or units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units, modules or components can be combined or integrated into another device, or some features can be ignored or not executed.

[0126] The units may or may not be physically separated, and the components displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0127] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0128] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part, and / or installed from a removable medium. When the computer program is executed by the central processing unit (CPU), the above-mentioned functions defined in the method of the present invention are executed. It should be noted that the above-mentioned computer-readable medium of the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of an electrical, magnetic, optical, electromagnetic, infrared segment, or semiconductor, or any combination of the above.

[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0130] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for blurring the background of a portrait image, characterized in that: The following steps are involved: Get a portrait image; Performing global blur processing on the portrait image to obtain a blurred image; The portrait part of the blurred image is deblurred to obtain a background blurred image.

2. The method for blurring the background of a portrait image according to claim 1, characterized in that: Obtaining a portrait image includes the following steps: Use the mobile phone camera to take pictures and obtain portrait images.

3. The method for blurring the background of a portrait image according to claim 2, characterized in that: Performing global blur processing on the portrait image specifically includes the following steps: Get the focus frame of the portrait image; Get the depth map of the portrait image; The depth map is blurred according to the focus frame to obtain a blurred image.

4. The method for blurring the background of a portrait image according to claim 3, characterized in that: Obtaining a depth map of a portrait image includes the following steps: Determine the mode of the mobile phone lens; the modes of the mobile phone lens include single-camera lens, dual-camera lens and TOF lens; For the TOF lens, it is determined that a depth map needs to be calculated, and the portrait image is used as the depth map; For a dual-camera lens, determine whether it is necessary to calculate a depth map; when it is determined that it is necessary to calculate a depth map, perform stereo matching on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map; For a single camera, it is determined that a depth map needs to be calculated, and the portrait image is processed based on deep learning technology to obtain a depth map.

5. The method for blurring the background of a portrait image according to claim 4, characterized in that: For a dual-camera lens, determine whether it is necessary to calculate a depth map; when it is determined that it is necessary to calculate a depth map, perform stereo matching on the portrait image based on a stereo matching algorithm of the binocular image to obtain a depth map, specifically including the following steps: The internal and external parameters of the portrait image are obtained through image calibration, and the projection relationship between the camera coordinate system and the image coordinate system is obtained; Perform Gaussian blur on the portrait image, calculate the gradient information of the image through the Sobel gradient operator, extract the image edge by thresholding the gradient amplitude, and calculate the ratio of edge pixels to total pixels; When the ratio of edge pixels to total pixels is less than the preset ratio threshold, the portrait image is judged to be dirty and the depth map is not calculated; When the ratio of edge pixels to total pixels is greater than or equal to the preset ratio threshold, it is determined that there is no dirt in the portrait image. Through the internal and external parameters of the two cameras, for the two input RGB images, it is necessary to use the internal parameters of the two cameras to perform image distortion correction, and use the external parameters to perform stereo correction on the images; the two corrected RGB images are stereo matched to determine the position difference of the photographed object in the two frames of images, thereby obtaining a depth map.

6. The method for blurring the background of a portrait image according to claim 5, characterized in that: The internal references are calibrated using Zhang Zhengyou calibration method. The internal references include fx, fy, cx, cy, and distortion coefficients [k1, k2, p1, p2, k3]; The external parameters are the rotation R and translation T relationship between the two camera coordinate systems. The feature point detection algorithm is used to extract feature points in the two rectified images respectively, and then the feature point matching algorithm is used to find the matching point pairs in the two images. The matching point pairs and the camera intrinsic parameter matrix are used to solve the essential matrix.

7. The method for blurring the background of a portrait image according to claim 6, characterized in that: The depth map is blurred according to the focus frame to obtain a blurred image, which specifically includes the following steps: When the depth map is not calculated, the portrait image I is blurred to obtain f(I), and the calculation formula is: I blur =K*f(I) Where: I blur represents the global blurred image, K∈[0,1] is the preset blur intensity, and f represents the blur method; When calculating the depth map, the average depth value d corresponding to the focus frame position in the depth map is obtained according to the coordinates of the focus frame. f , traverse the image pixels at that position in the portrait image, calculate the blur intensity of each pixel according to its depth value, and the blur intensity value k of the i-th pixel i It can be expressed as: k i =abs(d i -d f )*K Where: d i ∈[0,1] represents the depth value of the current pixel, and abs represents the absolute value in mathematical calculation; When the blur intensity value of the current pixel point is less than the preset intensity threshold, it is not blurred; when the blur intensity value of the current pixel point is greater than or equal to the preset intensity threshold, it is blurred.

8. The method for blurring the background of a portrait image according to claim 7, characterized in that: The blurred image is subjected to a portrait portion deblurring process to obtain a background blurred image, which specifically includes the following steps: Perform matting processing on the portrait image to obtain a matting image; According to the matting image, the corresponding part of the blurred image is deblurred to obtain a background blurred image.

9. The method for blurring the background of a portrait image according to claim 8, characterized in that: The background blur image I blur The calculation formula is: I out =I α ·I blur +(J-I α )·I Where: J represents a matrix of all 1s, · represents matrix multiplication, I blur represents the global blurred image, I represents the input image, and I α Represents the matting image, with a value range of [0,1].

10. A system for blurring the background of a portrait image, used to implement the method for blurring the background of a portrait image as claimed in any one of claims 1 to 9, characterized in that: include: An acquisition module, used for acquiring a portrait image; A blur processing module is used to perform global blur processing on the portrait image to obtain a blurred image; The deblurring processing module is used to perform deblurring processing on the portrait part of the deblurred image to obtain a background deblurred image.