Method and device for performing depth correction on portrait area of depth map
By performing portrait segmentation and depth correction on the depth map, the problem of uneven depth is solved, and the depth correction of the main part of the portrait is achieved, making the image processing effect closer to reality.
Patent Information
- Application Number
- CN202411916739.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-15
AI Technical Summary
The depth of the portrait area in the depth map is uneven, resulting in the image processing effect that does not match the actual effect.
By acquiring the original image, performing portrait segmentation and depth calculations, determining the depth distribution of the portrait area, and correcting the depth map, and finally obtaining the corrected depth map through segmentation mask texture fusion.
Correct the depth of the main part of the portrait to the same level, so that the depth map is closer to reality, and the depth difference between the subject and the front and back scene is more in line with the actual situation, thereby improving the consistency of the image processing effect.
Smart Images

Figure CN119831864A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method and device for performing depth correction on a portrait area of a depth map. Background Art
[0002] A depth map is a map that shows the distance between the content in a photo and the lens. Depth maps are widely used in the field of image processing. For example, depth maps are used to distinguish the near and far views of an image, and different blurring processes are applied according to the distance, which can imitate the blurring effect produced by a real camera aperture.
[0003] However, depth maps often have the problem of uneven depth. The depths of different parts of the image subject may vary greatly; the depth difference between the image subject and the foreground and background of the image may not be consistent with the actual situation. When processing images based on the absolute depth value and the depth difference, this uneven depth situation can easily lead to the final effect being inconsistent with the actual effect that you want to imitate. Summary of the invention
[0004] In order to at least to some extent overcome the problem of uneven depth in depth maps, the present application provides a method and apparatus for performing depth correction on a portrait area of a depth map.
[0005] The scheme of this application is as follows:
[0006] According to a first aspect of an embodiment of the present application, a method for performing depth correction on a portrait area of a depth map is provided, comprising:
[0007] Get the original image containing the person;
[0008] Performing portrait segmentation on the original image to obtain a segmentation mask texture;
[0009] Performing depth calculation on the original image to obtain a first depth map;
[0010] Determine the depth distribution of the portrait area in the first depth map;
[0011] Correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain a second depth map;
[0012] fusing the first depth map and the second depth map according to the segmentation mask texture to obtain a third depth map;
[0013] The third depth map is output as a corrected depth map.
[0014] Preferably, each pixel in the segmentation mask texture represents the probability of belonging to a portrait through a segmentation value;
[0015] The segmentation value ranges from 0 to 1, and a larger value indicates a higher probability.
[0016] Preferably, each pixel in the first depth map represents the distance of its content from the camera lens through a depth value;
[0017] The depth value ranges from 0 to 1, and a larger value indicates a closer distance to the camera.
[0018] Preferably, determining the depth distribution of the portrait area in the first depth map includes:
[0019] Constructing a depth value set according to a value range of the depth value; the depth value set is composed of a plurality of depth value elements with continuous values;
[0020] Traverse all pixels in the first depth map, if the segmentation value of the corresponding pixel of the current pixel in the segmentation mask texture is greater than 0, include the current pixel in the statistics, and record that the depth value of the current pixel appears once;
[0021] Updating the number of occurrences of each depth value element in the depth value set;
[0022] Determine the total number of pixels included in the statistics in the first depth map;
[0023] Calculate the occurrence probability of each depth value element in the depth value set according to the number of occurrences of each depth value element in the depth value set and the total number of pixels included in the statistics in the first depth map;
[0024] According to the occurrence probability of each depth value element in the depth value set, the depth value elements in the depth value set are sorted from high to low;
[0025] Traversing the sorted depth value set, calculating the sum of the occurrence probabilities of the traversed depth value elements, and when the sum of the occurrence probabilities of the traversed depth value elements is not less than a first threshold, stopping the traversal, and removing the untraversed depth value elements from the depth value set;
[0026] According to the size of the depth values, the depth value elements in the depth value set are sorted from small to large;
[0027] Construct a sub-statistical set, traverse the reordered depth value set, add the depth value elements to the sub-statistical set in sequence, and if the depth value of the current depth value element is not continuous with the depth value of the previous depth value element, construct the next sub-statistical set and add the current depth value element;
[0028] Calculate the sum of the occurrence probabilities of all depth value elements in the sub-statistical set as the occurrence probability of the sub-statistical set;
[0029] Integrate all sub-statistical sets into a total statistical set, traverse the total statistical set, and sort the sub-statistical sets in the total statistical set from high to low according to the probability of occurrence of the sub-statistical sets;
[0030] Traversing the sorted total statistical set, calculating the sum of the occurrence probabilities of the traversed sub-statistical sets, and when the sum of the occurrence probabilities of the traversed sub-statistical sets is not less than a second threshold, stopping the traversal and removing the untraversed sub-statistical sets from the total statistical set;
[0031] Replacing all elements in the depth value set with all elements in all sub-statistical sets in the total statistical set;
[0032] Traverse the updated depth value set, and calculate the weighted average depth value, the minimum depth value, and the maximum depth value of all depth value elements in the depth value set;
[0033] Calculate the estimated depth range of the portrait area according to the minimum depth value and the maximum depth value;
[0034] The weighted average depth value and the estimated depth range are used as the depth distribution of the portrait area in the first depth map.
[0035] Preferably, correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain the second depth map includes:
[0036] Determine correction curve parameters and correction range parameters;
[0037] Calculate the depth value of each pixel in the second depth map according to the correction curve parameter, the correction range parameter, the depth distribution of the portrait area in the first depth map, and the depth value of each pixel in the first depth map:
[0038]
[0039] r1=s*r;
[0040]
[0041] p = ((da) / (la))^c;
[0042] Wherein, d1 represents the depth value of the pixel in the first depth map, d2 represents the depth value of the pixel in the second depth map, a represents the weighted average depth value, r represents the correction range parameter, s represents the estimated depth range, r1 represents the depth range to be corrected, l and p represent the first parameter and the second parameter respectively, and c represents the correction curve parameter;
[0043] A second depth map is obtained according to the depth value of each pixel in the second depth map.
[0044] Preferably, fusing the first depth map and the second depth map according to the segmentation mask texture to obtain a third depth map comprises:
[0045] The depth value of each pixel in the third depth map is calculated according to the depth value of each pixel in the first depth map, the depth value of each pixel in the second depth map, and the segmentation value of each pixel in the segmentation mask texture:
[0046] d3=m*d2+(1-m)*d1;
[0047] Wherein, d3 represents the depth value of the pixel in the third depth map, and m represents the segmentation value of the pixel in the segmentation mask texture;
[0048] A third depth map is obtained according to the depth value of each pixel in the third depth map.
[0049] Preferably, the first threshold value is 0.99;
[0050] The second threshold value is 0.9.
[0051] Preferably, the correction curve parameter value is 3;
[0052] The correction range parameter takes a value of 2.
[0053] According to a second aspect of an embodiment of the present application, a device for performing depth correction on a portrait area of a depth map is provided, comprising:
[0054] Processor and memory;
[0055] The processor and the memory are connected via a communication bus:
[0056] Wherein, the processor is used to call and execute the program stored in the memory;
[0057] The memory is used to store a program, and the program is at least used to execute a method for performing depth correction on a portrait area of a depth map as described in any one of the above items.
[0058] The technical solution provided by this application may have the following beneficial effects:
[0059] The method for depth correction of a portrait area in a depth map in the present application includes: obtaining an original image containing a person; performing portrait segmentation on the original image to obtain a segmentation mask texture; performing depth calculation on the original image to obtain a first depth map; determining the depth distribution of the portrait area in the first depth map; correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain a second depth map; fusing the first depth map and the second depth map according to the segmentation mask texture to obtain a third depth map; and outputting the third depth map as a corrected depth map.
[0060] In this technical solution, the first depth map is first corrected according to the depth distribution of the portrait area to obtain the second depth map. Then, the first depth map and the second depth map are fused with the segmentation mask texture obtained by performing portrait segmentation on the original image, so that the depth of the main part of the portrait can be corrected to the same level as much as possible. After correction, the main part of the portrait in the depth map is closer to reality, and the depth difference between the main part and the foreground and background is more in line with the actual situation. When the image is processed according to the depth map later, the effect of the main part of the portrait can also be consistent.
[0061] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0063] Figure 1 It is a flowchart of a method for performing depth correction on a portrait area of a depth map provided by an embodiment of the present application;
[0064] Figure 2 It is a structural schematic diagram of a device for performing depth correction on a portrait area of a depth map provided by an embodiment of the present application.
[0065] Reference numerals: processor-21; memory-22. DETAILED DESCRIPTION
[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0067] Embodiment 1
[0068] Figure 1 is a flow chart of a method for performing depth correction on a portrait area of a depth map provided by an embodiment of the present application, with reference to Figure 1 , a method for performing depth correction on a portrait area of a depth map, comprising:
[0069] S11: Acquire an original image containing a person;
[0070] The original image containing a person may be a portrait photo, and the background is not restricted and may be a solid color or may have other information.
[0071] The main part of the original image containing a person is the person, and other information is the non-main part.
[0072] S12: performing portrait segmentation on the original image to obtain a segmentation mask texture;
[0073] It should be noted that image segmentation technology is a technology that separates the main part from the non-main part of an image. The calculation results are usually presented in the form of a grayscale image. The grayscale value of each pixel represents the probability that the pixel belongs to the main part. Currently, most image segmentation technologies are implemented through machine learning.
[0074] Each pixel in the segmentation mask texture represents the probability of belonging to a portrait through a segmentation value;
[0075] The segmentation value ranges from 0 to 1, and the larger the value, the higher the probability.
[0076] S13: Calculate the depth of the original image to obtain a first depth map;
[0077] Depth calculation technology is a technology that calculates the distance between different contents in an image and the camera lens. The calculation results are usually presented in the form of a grayscale image. The grayscale value of each pixel indicates the distance between the content of the pixel and the camera lens. Currently, most depth calculation technologies are implemented through machine learning.
[0078] Each pixel in the first depth map indicates how far its content is from the camera through a depth value;
[0079] The depth value ranges from 0 to 1, and the larger the value, the closer it is to the camera.
[0080] S14: Determine the depth distribution of the portrait area in the first depth map;
[0081] S15: Correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain a second depth map;
[0082] S16: fusing the first depth map and the second depth map according to the segmentation mask texture to obtain a third depth map;
[0083] S17: Output the third depth map as a corrected depth map.
[0084] Specifically, determining the depth distribution of the portrait area in the first depth map includes:
[0085] Constructing a depth value set according to a value range of the depth value; the depth value set is composed of a plurality of depth value elements with continuous values;
[0086] Traverse all pixels in the first depth map. If the segmentation value of the corresponding pixel of the current pixel in the segmentation mask texture is greater than 0, include the current pixel in the statistics and record that the depth value of the current pixel appears once.
[0087] Update the number of occurrences of each depth value element in the depth value set;
[0088] Determine the total number of pixels included in the statistics in the first depth map;
[0089] Calculate the occurrence probability of each depth value element in the depth value set according to the number of occurrences of each depth value element in the depth value set and the total number of pixels included in the statistics in the first depth map;
[0090] According to the occurrence probability of each depth value element in the depth value set, the depth value elements in the depth value set are sorted from high to low;
[0091] Traversing the sorted depth value set, calculating the sum of the occurrence probabilities of the traversed depth value elements, and when the sum of the occurrence probabilities of the traversed depth value elements is not less than a first threshold, stopping the traversal, and removing the untraversed depth value elements from the depth value set;
[0092] According to the size of the depth values, the depth value elements in the depth value set are sorted from small to large;
[0093] Construct a sub-statistical set, traverse the reordered depth value set, add the depth value elements to the sub-statistical set in sequence, and if the depth value of the current depth value element is not continuous with the depth value of the previous depth value element, construct the next sub-statistical set and add the current depth value element;
[0094] Calculate the sum of the occurrence probabilities of all depth value elements in the sub-statistical set as the occurrence probability of the sub-statistical set;
[0095] Integrate all sub-statistical sets into a total statistical set, traverse the total statistical set, and sort the sub-statistical sets in the total statistical set from high to low according to the probability of occurrence of the sub-statistical sets;
[0096] Traversing the sorted total statistical set, calculating the sum of the occurrence probabilities of the traversed sub-statistical sets, and when the sum of the occurrence probabilities of the traversed sub-statistical sets is not less than a second threshold, stopping the traversal and removing the untraversed sub-statistical sets from the total statistical set;
[0097] Replace all elements in the depth value set with all elements in all sub-statistic sets in the total statistics set;
[0098] Traverse the updated depth value set, and calculate the weighted average depth value, the minimum depth value, and the maximum depth value of all depth value elements in the depth value set;
[0099] Calculate the estimated depth range of the portrait area according to the minimum depth value and the maximum depth value;
[0100] The weighted average depth value and the estimated depth range are used as the depth distribution of the portrait area in the first depth map.
[0101] Example description:
[0102] The color bit depth of the depth map used in this embodiment is 8 bits, so the value range of the depth value d is 256 integers from 0 to 255. Finally, a depth value set H is obtained, and the depth value set H includes 256 depth value elements h.
[0103] Traverse all pixels in the first depth map. If the segmentation value m of the corresponding pixel of the current pixel in the segmentation mask texture is greater than 0, include the current pixel in the statistics and record that the depth value d of the current pixel appears once.
[0104] The number of occurrences of each depth value element h in the depth value set H is updated; at this time, each depth value element h in the depth value set H includes a pair of values: a depth value d and the number of times c that the depth value is counted.
[0105] The total number C of pixels included in the statistics in the first depth map is determined.
[0106] According to the number of occurrences c of each depth value element h in the depth value set and the total number C of pixels included in the statistics in the first depth map, the occurrence probability p=c / C of each depth value element in the depth value set is calculated.
[0107] According to the occurrence probability p of each depth value element h in the depth value set H, the depth value elements h in the depth value set H are sorted from high to low.
[0108] The sorted depth value set H is traversed, and the sum of the occurrence probabilities of the traversed depth value elements h is calculated. When the sum of the occurrence probabilities of the traversed depth value elements is not less than the first threshold t1, the traversal is stopped, and the untraversed depth value elements are removed from the depth value set.
[0109] According to the size of the depth value d, the depth value elements h in the depth value set H are sorted again from small to large.
[0110] Construct a sub-statistical set g, traverse the reordered depth value set H, add the depth value elements h to the sub-statistical set g in sequence, and if the depth value of the current depth value element is discontinuous with the depth value of the previous depth value element (for example, the depth value of the previous depth value element is 103, and the depth value of the previous depth value element is 100), construct the next sub-statistical set and add the current depth value element; in this way, each sub-statistical set contains depth value elements with continuous depth values.
[0111] The sum of the occurrence probabilities of all depth value elements in the sub-statistical set is calculated as the occurrence probability of the sub-statistical set; for example, if the occurrence probability of the depth value element h1 in the sub-statistical set is 0.01 and the occurrence probability of the depth value element h2 is 0.02, then the occurrence probability of the sub-statistical set is the sum of the two, 0.03.
[0112] Integrate all the sub-statistical sets g into the total statistical set G, traverse the total statistical set G, and sort the sub-statistical sets g in the total statistical set from high to low according to the probability of occurrence of the sub-statistical sets g;
[0113] Traverse the sorted total statistical set, G calculates the sum of the occurrence probabilities of the traversed sub-statistical sets g, and when the sum of the occurrence probabilities of the traversed sub-statistical sets is not less than the second threshold t2, stop traversing and remove the untraversed sub-statistical sets from the total statistical set G;
[0114] Replace all elements in the depth value set H with all elements h in all sub-statistical sets g in the total statistical set G; in the present technical solution, each sub-statistical set in the statistical set G contains depth value elements with continuous depth values, and through multiple traversal screening, each element h in the statistical set G is now a depth value with a high probability of occurrence, and replacing all elements in the depth value set H with all elements h in all sub-statistical sets g in the total statistical set G can make all depth value elements in the depth value set H have depth values with high probability of occurrence and high continuity, so that a more accurate depth distribution of the portrait area in the first depth map can be obtained.
[0115] Traverse the updated depth value set H, calculate the weighted average depth value a, minimum depth value min and maximum depth value max of all depth value elements h in the depth value set H; use the weighted average depth value a as the average depth estimate of the portrait area
[0116] Calculate the estimated depth range s of the portrait area according to the minimum depth value min and the maximum depth value max = (max-min)*0.5;
[0117] The weighted average depth value and the estimated depth range are used as the depth distribution of the portrait area in the first depth map.
[0118] Preferably, the first threshold value is 0.99; the second threshold value is 0.9.
[0119] Further, the first depth map is corrected according to the depth distribution of the portrait area in the first depth map to obtain a second depth map, including:
[0120] Determine correction curve parameters and correction range parameters;
[0121] The depth value of each pixel in the second depth map is calculated according to the correction curve parameter, the correction range parameter, the depth distribution of the portrait area in the first depth map, and the depth value of each pixel in the first depth map:
[0122]
[0123] r1=s*r;
[0124]
[0125] p = ((da) / (la))^c;
[0126] Wherein, d1 represents the depth value of the pixel in the first depth map, d2 represents the depth value of the pixel in the second depth map, a represents the weighted average depth value, r represents the correction range parameter, s represents the estimated depth range, r1 represents the depth range to be corrected, l and p represent the first parameter and the second parameter respectively, and c represents the correction curve parameter;
[0127] A second depth map is obtained according to the depth value of each pixel in the second depth map.
[0128] Further, the first depth map and the second depth map are fused according to the segmentation mask texture to obtain a third depth map, including:
[0129] The depth value of each pixel in the third depth map is calculated according to the depth value of each pixel in the first depth map, the depth value of each pixel in the second depth map, and the segmentation value of each pixel in the segmentation mask texture:
[0130] d3=m*d2+(1-m)*d1;
[0131] Wherein, d3 represents the depth value of the pixel in the third depth map, and m represents the segmentation value of the pixel in the segmentation mask texture;
[0132] A third depth map is obtained according to the depth value of each pixel in the third depth map.
[0133] Preferably, according to the method of claim 5, the correction curve parameter is 3;
[0134] The correction range parameter value is 2.
[0135] It can be understood that in this technical solution, the first depth map is first corrected according to the depth distribution of the portrait area to obtain the second depth map. Then, the first depth map and the second depth map are fused with the segmentation mask texture obtained by performing portrait segmentation on the original image, so that the depth of the main part of the portrait can be corrected to the same level as much as possible. After correction, the main part of the portrait in the depth map is closer to reality, and the depth difference between the main part and the foreground and background is more in line with the actual situation. When the image is processed according to the depth map later, the effect of the main part of the portrait can also remain consistent.
[0136] Embodiment 2
[0137] Figure 2 is a schematic diagram of a structure of a device for performing depth correction on a portrait area of a depth map provided by an embodiment of the present application, with reference to Figure 2 , a device for performing depth correction on a portrait area of a depth map, comprising:
[0138] Processor 21 and memory 22;
[0139] The processor 21 and the memory 22 are connected via a communication bus:
[0140] The processor 21 is used to call and execute the program stored in the memory 22;
[0141] The memory 22 is used to store a program, and the program is used to execute at least one of the methods for performing depth correction on the portrait area of the depth map in the above embodiments.
[0142] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0143] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0144] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0145] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0146] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0147] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0148] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0149] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0150] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for depth correction of a portrait area of a depth map, characterized in that: include: Get the original image containing the person; Performing portrait segmentation on the original image to obtain a segmentation mask texture; Performing depth calculation on the original image to obtain a first depth map; Determine the depth distribution of the portrait area in the first depth map; Correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain a second depth map; fusing the first depth map and the second depth map according to the segmentation mask texture to obtain a third depth map; The third depth map is output as a corrected depth map.
2. The method according to claim 1, characterized in that Each pixel in the segmentation mask texture represents the probability of belonging to a portrait through a segmentation value; The segmentation value ranges from 0 to 1, and a larger value indicates a higher probability.
3. The method according to claim 2, characterized in that Each pixel in the first depth map indicates how far its content is from the camera through a depth value; The depth value ranges from 0 to 1, and a larger value indicates a closer distance to the camera.
4. The method according to claim 3, characterized in that Determining the depth distribution of the portrait area in the first depth map includes: Constructing a depth value set according to a value range of the depth value; the depth value set is composed of a plurality of depth value elements with continuous values; Traverse all pixels in the first depth map, if the segmentation value of the corresponding pixel of the current pixel in the segmentation mask texture is greater than 0, include the current pixel in the statistics, and record that the depth value of the current pixel appears once; Updating the number of occurrences of each depth value element in the depth value set; Determine the total number of pixels included in the statistics in the first depth map; Calculate the occurrence probability of each depth value element in the depth value set according to the number of occurrences of each depth value element in the depth value set and the total number of pixels included in the statistics in the first depth map; According to the occurrence probability of each depth value element in the depth value set, the depth value elements in the depth value set are sorted from high to low; Traversing the sorted depth value set, calculating the sum of the occurrence probabilities of the traversed depth value elements, and when the sum of the occurrence probabilities of the traversed depth value elements is not less than a first threshold, stopping the traversal, and removing the untraversed depth value elements from the depth value set; According to the size of the depth values, the depth value elements in the depth value set are sorted from small to large; Construct a sub-statistical set, traverse the reordered depth value set, add the depth value elements to the sub-statistical set in sequence, and if the depth value of the current depth value element is not continuous with the depth value of the previous depth value element, construct the next sub-statistical set and add the current depth value element; Calculate the sum of the occurrence probabilities of all depth value elements in the sub-statistical set as the occurrence probability of the sub-statistical set; Integrate all sub-statistical sets into a total statistical set, traverse the total statistical set, and sort the sub-statistical sets in the total statistical set from high to low according to the probability of occurrence of the sub-statistical sets; Traversing the sorted total statistical set, calculating the sum of the occurrence probabilities of the traversed sub-statistical sets, and when the sum of the occurrence probabilities of the traversed sub-statistical sets is not less than a second threshold, stopping the traversal and removing the untraversed sub-statistical sets from the total statistical set; Replacing all elements in the depth value set with all elements in all sub-statistical sets in the total statistical set; Traverse the updated depth value set, and calculate the weighted average depth value, the minimum depth value, and the maximum depth value of all depth value elements in the depth value set; Calculate the estimated depth range of the portrait area according to the minimum depth value and the maximum depth value; The weighted average depth value and the estimated depth range are used as the depth distribution of the portrait area in the first depth map.
5. The method according to claim 4, characterized in that Correcting the first depth map according to the depth distribution of the portrait area in the first depth map to obtain a second depth map includes: Determine correction curve parameters and correction range parameters; Calculate the depth value of each pixel in the second depth map according to the correction curve parameter, the correction range parameter, the depth distribution of the portrait area in the first depth map, and the depth value of each pixel in the first depth map: r1=s*r; p = ((da) / (la))^c; Wherein, d1 represents the depth value of the pixel in the first depth map, d2 represents the depth value of the pixel in the second depth map, a represents the weighted average depth value, r represents the correction range parameter, s represents the estimated depth range, r1 represents the depth range to be corrected, l and p represent the first parameter and the second parameter respectively, and c represents the correction curve parameter; A second depth map is obtained according to the depth value of each pixel in the second depth map.
6. The method according to claim 5, characterized in that The first depth map and the second depth map are fused according to the segmentation mask texture to obtain a third depth map, comprising: The depth value of each pixel in the third depth map is calculated according to the depth value of each pixel in the first depth map, the depth value of each pixel in the second depth map, and the segmentation value of each pixel in the segmentation mask texture: d3=m*d2+(1-m)*d1; Wherein, d3 represents the depth value of the pixel in the third depth map, and m represents the segmentation value of the pixel in the segmentation mask texture; A third depth map is obtained according to the depth value of each pixel in the third depth map.
7. The method according to claim 4, characterized in that The first threshold value is 0.99; The second threshold value is 0.
9.
8. The method according to claim 5, characterized in that The correction curve parameter value is 3; The correction range parameter takes a value of 2.
9. A device for performing depth correction on a portrait area of a depth map, characterized in that: include: Processor and memory; The processor and the memory are connected via a communication bus: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store a program, and the program is at least used to execute a method for depth correction of a portrait area of a depth map as described in any one of claims 1-8.