Soft shadow generation method and device, storage medium and computer equipment

Through Archimedes spiral sampling and depth value comparison, the problems of low efficiency of traditional soft shadow calculation and uncertain results are solved, and efficient and accurate soft shadow generation is achieved, which is suitable for high-time and deterministic simulation tasks.

CN119228978APending Publication Date: 2024-12-31SHENZHEN DEEPROUTE AI CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411065112.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

In traditional soft shadow calculation methods, Poisson sampling efficiency is low, making it difficult to meet simulation tasks with high requirements for timeliness, and the results are uncertain, making it difficult to apply to simulation tasks that depend on determinism.

Method used

The camera image is sampled using Archimedes spiral. By comparing the depth value in the image and the depth value in the depth map, the degree of occlusion of the pixel points is evaluated, and the brightness value is adjusted based on this to generate a soft shadow.

Benefits of technology

It improves the efficiency and accuracy of soft shadow generation, avoids oversampling and sampling omissions, achieves determinism and uniformity, and is suitable for simulation tasks with high timeliness and determinism requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228978A_ABST
    Figure CN119228978A_ABST
Patent Text Reader

Abstract

The invention discloses a soft shadow generation method and device, a storage medium and computer equipment. The soft shadow generation method comprises the following steps: acquiring a depth map of a target scene under a light source view angle and a camera image of the target scene under a camera view angle; converting the camera image into a light source visual angle coordinate system of the depth map to obtain a converted image; sampling nearby pixel points corresponding to each pixel point in the converted image based on an Archimedes spiral to obtain a plurality of sampling points corresponding to each pixel point; and comparing the first depth value of each sampling point in the converted image with the second depth value of each sampling point in the depth map to evaluate the occlusion degree of the corresponding pixel point, and adjusting the brightness value of the corresponding pixel point in the camera image based on the occlusion degree to obtain the soft shadow of the target scene. Through the method, the sampling points can be uniformly and quickly selected, the soft shadow generation efficiency is improved, and an accurate, smooth and reliable soft shadow effect is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graphics simulation technology, and in particular to a soft shadow generation method, device, storage medium and computer equipment. Background Art

[0002] In the simulation test of the autonomous driving system, accurate simulation of the shadow effect of the sensor screen can make the simulation scene closer to the real scene, so as to conduct more accurate, effective and reliable tests on the visual perception and object detection functions of the autonomous driving system, which helps the autonomous driving system better adapt to the driving scenes in the real world. In the simulation of the shadow effect, the soft shadow effect is used to simulate the effect of the blurred edge of the shadow in reality, making the shadow look more natural and real, further improving the visual fidelity of the simulation environment.

[0003] Traditional methods mainly use shadow mapping and percentage close filtering (PCF) to calculate soft shadows in sensor images. Usually, shadow sampling is performed through Poisson sampling to obtain soft shadows of target scenes. However, since Poisson sampling is a multiple pass-rejection method with a large number of iterations, the actual sampling points are much more than the actual required sampling points, the computing power resources are consumed, the computing efficiency is low, and it is difficult to ensure the quality and timeliness of the soft shadow generation, and it is difficult to apply to simulation tasks with high timeliness requirements. At the same time, traditional Poisson sampling relies on random functions, and its results are not certain, which is not applicable to simulation tasks that rely heavily on determinism. Summary of the invention

[0004] The present application mainly provides a soft shadow generation method, device, storage medium and computer equipment, aiming to solve the problem of low calculation efficiency of existing soft shadow effects.

[0005] In order to solve the above technical problems, the technical solution adopted by the present application is: to provide a soft shadow generation method. The soft shadow generation method includes: obtaining a depth map of the target scene under the perspective of the light source, and a camera image of the target scene under the perspective of the camera; converting the camera image to the light source perspective coordinate system of the depth map to obtain a converted image; sampling the nearby pixel points corresponding to each pixel point in the converted image based on the Archimedean spiral to obtain multiple sampling points corresponding to each pixel point; comparing the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the corresponding pixel point, and adjusting the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0006] In some embodiments, the sampling of nearby pixel points corresponding to each pixel point in the conversion image based on the Archimedean spiral to obtain multiple sampling points corresponding to each pixel point includes: generating the Archimedean spiral with the pixel point as the origin; selecting the corresponding sampling point on the Archimedean spiral at every preset sampling interval angle, wherein the distance between the sampling point and the pixel point does not exceed a preset maximum polar diameter.

[0007] In some embodiments, the corresponding sampling points are selected on the Archimedean spiral at every preset sampling interval angle, based on the formula Among them, r is not greater than the preset maximum pole diameter r max The sampling point polar diameter, θ is the sampling point polar angle, θ init is the initial sampling angle, θ interval is the preset sampling interval angle, a is the preset initial parameter of the Archimedean spiral, b is the preset growth parameter of the Archimedean spiral, and n is less than the preset number of sampling points n max A natural number.

[0008] In some embodiments, the calculation formula of the sampling initial angle is: θ init =(x*prime_a+y*prime_b)mod prime_c mod 360, where, θ init is the initial sampling angle, (x, y) is the position coordinate of the pixel point in the light source viewing angle coordinate system, prime_a, prime_b and prime_c are extremely large prime numbers that are larger than the pixel order of the camera image and are different from each other.

[0009] In some embodiments, the preset initial parameter and the preset growth parameter satisfy the formula: a+b*(n max -1)*θ interval ≤r max , where a is the preset initial angle, b is the preset growth parameter, r max is the preset maximum pole diameter, n max is the preset number of sampling points, θ interval is the preset sampling interval angle.

[0010] In some embodiments, after selecting the corresponding sampling points on the Archimedean spiral at every preset sampling interval angle, the method further includes: selecting a group of the sampling points to form a pre-sampling list of corresponding pixel points; based on the positional relationship between each pixel point in the conversion image, performing position transformation on the pre-sampling list to obtain sampling points corresponding to each pixel point.

[0011] In some embodiments, the comparing of the first depth value of each of the sampling points in the converted image with the second depth value of the corresponding point of each of the sampling points in the depth map to evaluate the degree of occlusion of the corresponding pixel, and adjusting the brightness value of the corresponding pixel in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene includes: when the first depth value is greater than the second depth value, taking the sampling point as an occluded point; taking the proportion of the occluded points in the sampling points corresponding to each of the pixel points as the degree of occlusion of the pixel; and adjusting the brightness value of the pixel in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0012] To solve the above technical problems, another technical solution adopted in the present application is: to provide a soft shadow generating device, which includes: an acquisition module, used to acquire a depth map of the target scene under the perspective of a light source, and a camera image of the target scene under the perspective of a camera; a conversion module, used to convert the camera image to the light source perspective coordinate system of the depth map to obtain a converted image; a sampling module, used to sample nearby pixel points corresponding to each pixel point in the converted image based on an Archimedean spiral to obtain multiple sampling points corresponding to each pixel point; a generation module, used to compare the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the pixel point, and adjust the brightness value corresponding to the pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0013] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a storage medium, on which program data is stored, characterized in that when the program data is executed by a processor, the steps of the soft shadow generation method as mentioned above are implemented.

[0014] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a computer device, which includes a processor and a memory connected to each other, the memory stores a computer program, and when the processor executes the computer program, the steps of the soft shadow generation method as mentioned above are implemented.

[0015] The beneficial effects of the present application are as follows: Different from the prior art, the present application discloses a method, device, storage medium and computer equipment for generating soft shadows. The present application samples the converted image obtained by converting the camera image under the camera perspective through the Archimedean spiral, and compares the depth value of the sampling point in the converted image with the depth value of the corresponding point of the sampling point in the depth map under the light source perspective, thereby determining the degree of occlusion of the corresponding pixel point, and adjusting the brightness value of the corresponding pixel point based on the occlusion degree to obtain the soft shadow of the target scene. The sampling of the Archimedean spiral based on the method can cover the area near the pixel point more evenly and more deterministically, avoiding oversampling and sampling omissions. The sampling method based on the Archimedean route is simple to implement and does not require additional repeated sampling and calculation, and has low computing power requirements, which is conducive to improving the efficiency of soft shadow generation, and can generate accurate, smooth and reliable soft shadow effects, which is conducive to improving the simulation performance in the simulation scene. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0017] Figure 1 It is a flowchart of an embodiment of a soft shadow generation method provided by the present application;

[0018] Figure 2 yes Figure 1 A schematic flow chart of an embodiment of step 30 in the embodiment;

[0019] Figure 3 yes Figure 2 A schematic diagram of a flow chart of an embodiment after step 32 in the embodiment;

[0020] Figure 4 yes Figure 1 A schematic diagram of a flow chart of an embodiment of step 40 in the embodiment;

[0021] Figure 5 It is a structural schematic diagram of an embodiment of a soft shadow generating device provided by the present application;

[0022] Figure 6 It is a structural schematic diagram of an embodiment of a storage medium provided by the present application;

[0023] Figure 7 It is a structural diagram of an embodiment of a computer device provided by the present application. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] The terms "first", "second", "third" in the embodiments of the present application are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the feature defined as "first", "second", "third" can expressly or implicitly include at least one of the features. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically limited. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.

[0026] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0027] This application provides a soft shadow generation method, see Figure 1 , Figure 1 : is a flow chart of an embodiment of a soft shadow generation method provided by the present application, the soft shadow generation method comprising:

[0028] Step 10: Obtain a depth map of the target scene from the perspective of the light source and a camera image of the target scene from the perspective of the camera.

[0029] The target scene is the application scene that needs to generate soft shadows, such as autonomous driving simulation scenes, game environment scenes, architectural design scenes, etc. The light source perspective is the range and angle that can be seen when observing the scene from the position of the light source, and the corresponding light source perspective coordinate system can be established accordingly. Under the light source perspective, the depth map is the projection of the target scene illuminated by the light source. The depth map does not contain information such as color and brightness, but only contains the depth value from each pixel illuminated by the light source to the light source. The camera perspective is the range and angle of the camera's observation of the target scene, and the corresponding camera perspective coordinate system can be established accordingly. The camera perspective is used to simulate the perspective of the sensor in the autonomous driving main vehicle to observe the target scene in the autonomous driving simulation scene. In other application scenarios, the camera perspective can also correspond to the observation perspective of the human eye or other sensors. Under the camera perspective, the camera image contains the color, brightness, texture and other information of the target scene under the camera perspective. When the shadow is not rendered in the target scene, the simulated camera image does not contain the shadow effect presented in different colors, brightness and texture, lacking authenticity, so the soft shadow of the target scene can be generated based on the subsequent steps to achieve corresponding authenticity.

[0030] The depth map and the camera image can be obtained from a database or in real time. When obtained in real time, it usually involves a dynamic rendering process, and the real-time acquisition process usually includes: first rendering the target scene from the perspective of the light source, recording the depth value of the corresponding point closest to the light source in the depth map, generating a corresponding depth map, and then setting the camera viewing angle, and rendering the target scene from the perspective of the camera to obtain a corresponding camera image. After obtaining the depth map and camera image, the corresponding soft shadow of the target scene can be generated through subsequent steps, so that the color, brightness and texture obtained by the camera image are more realistic, so as to better simulate the scene conditions of the real world and the simulated image conditions used for processing.

[0031] Step 20: Convert the camera image to the light source perspective coordinate system of the depth map to obtain a converted image.

[0032] The camera image and depth map are usually acquired at different viewing angles, so they need to be converted to the same viewing angle for subsequent processing to ensure the consistency and accuracy of subsequent shadow calculations. The conversion process can be implemented based on the matrix relationship between coordinate systems, affine transformation, or other methods that use specific parameters or specific algorithms to transform images. The camera image is converted to the light source viewing angle coordinate system of the depth map, so that the corresponding converted image can be obtained, so that each pixel in the converted image has the same viewing angle and position relationship with the corresponding point in the depth map.

[0033] Step 30: Based on the Archimedean spiral, the nearby pixel points corresponding to each pixel point in the conversion image are sampled to obtain a plurality of sampling points corresponding to each pixel point.

[0034] The Archimedean spiral, also known as the constant velocity spiral, is a special plane curve. It is defined by the formula r=a+bθ in polar coordinates, where r is the polar diameter, which is used to measure the distance between a point in polar coordinates and the polar origin, θ is the polar angle, which is used to measure the angle between the polar diameter and the set polar axis, and a and b are constants that determine the shape and size of the spiral. In the polar coordinate system, the polar angle and polar diameter of the Archimedean spiral are linearly related. When the change of the polar angle is fixed, its polar diameter can change uniformly. Therefore, the sampling based on the fixed change of the polar angle of the Archimedean spiral can effectively cover the vicinity of the pixel point, and uniformly sample the corresponding nearby pixel points in the vicinity of each pixel point, so as to select multiple sampling points from the nearby pixel points for subsequent calculation and processing, so that the sampling points can cover a wider pixel area, while maintaining a certain regularity, avoiding the noise and irregularity that may be caused by random sampling.

[0035] Optionally, see Figure 2 , based on the Archimedean spiral, the nearby pixel points corresponding to each pixel point in the conversion image are sampled to obtain multiple sampling points corresponding to each pixel point, including:

[0036] Step 31: Generate an Archimedean spiral with the pixel point as the origin.

[0037] Step 32: Select corresponding sampling points on the Archimedean spiral at every preset sampling interval angle, wherein the distance between the sampling point and the pixel point does not exceed the preset maximum pole diameter.

[0038] The Archimedean spiral describes the trajectory of a point that moves evenly away from a fixed point while rotating around the fixed point at a fixed angular velocity. The fixed point is the origin of the Archimedean spiral. Generating the Archimedean spiral with the pixel point as the origin of the Archimedean spiral can ensure that the pixel area near the pixel point can be evenly covered during the sampling process, and some areas will not be over-sampled or the sampling of some areas will not be omitted due to the uneven distribution of sampling points.

[0039] The preset sampling interval angle and the preset maximum polar diameter are parameters set according to the sampling needs and the characteristics of the scene. The sampling interval angle determines the density and sampling frequency of the sampling points. A smaller sampling interval angle can produce denser sampling points and more comprehensively cover the pixel area near the pixel point, but it may also lead to an increase in calculation and a decrease in efficiency; a larger sampling interval angle can reduce the number of sampling points and improve calculation efficiency, but it may miss some important pixel areas, so the preset sampling interval angle may be selected based on the needs of computing power and efficiency. The preset maximum polar diameter limits the maximum distance between the sampling point and the origin to prevent the sampling point from being too far away from the pixel point and not representative.

[0040] Through the above Archimedean spiral-based sampling, a series of sampling points evenly distributed near the pixel can be obtained. These sampling points not only contain the information of the original pixel, but also incorporate the information of the surrounding pixels, so as to more comprehensively reflect the local characteristics of the image, ensure the certainty, uniformity and regularity of the sampling process, avoid the noise and irregularity that may be caused by random sampling, and further improve the quality and efficiency of subsequent soft shadow generation.

[0041] Optionally, a corresponding sampling point is selected on the Archimedean spiral at every preset sampling interval angle, based on the formula: Where r is not greater than the preset maximum pole diameter r max The sampling point polar diameter, θ is the sampling point polar angle, θ init is the initial sampling angle, θ interval is the preset sampling interval angle, a is the preset initial parameter of the Archimedean spiral, b is the preset growth parameter of the Archimedean spiral, and n is less than the preset number of sampling points n max A natural number.

[0042] In this formula, the Archimedean spiral starts from the sampling initial angle θ init Start with a preset sampling interval angle θ interval Preset the number of sampling points n max Since sampling starts from n=0, set n to be less than the preset number of sampling points n. max , you can sample n to a value between 0 and n max -1 sampling point, that is, a total of n max The value of n can be sampled from the nearest sampling point in a step-by-step manner, or can be sampled from the farthest sampling point in the opposite step-by-step direction, or can be sampled in a jump manner.

[0043] In this formula, the shape of the Archimedean spiral is determined by the preset initial parameter a and the preset growth parameter b. The preset initial parameter a determines the starting position and rotation direction of the spiral, while the preset growth parameter b directly controls the pitch and spacing of the spiral, thereby affecting the overall shape and characteristics of the spiral. Through the regulation of a and b, the polar diameter of the farthest sampling point is made smaller than the preset maximum polar diameter. Therefore, based on the Archimedean spiral, the sampling based on the above formula can collect a preset number of sampling points uniformly and quickly within the range of the preset maximum polar diameter, so as to perform subsequent processing of the sampling points.

[0044] Optionally, the calculation formula for the initial sampling angle is: θ init =(x*prime_a+y*prime_b)mod prime_c mod 360, where, θ init is the initial sampling angle, (x, y) is the position coordinate of the pixel point in the light source perspective coordinate system, prime_a, prime_b and prime_c are extremely large prime numbers that are larger than the pixel order of the camera image and are different from each other.

[0045] The sampling of Archimedean spiral can make the sampling points more uniform, making the sampling more certain. However, it is also necessary to ensure a certain randomness in the sampling, improve the generalization ability of the sampling, and make the obtained sampling points meet the characteristics of the statistical assumptions. Therefore, the present application introduces a very large prime number for calculation so that the initial sampling angle has corresponding randomness, and controls other parameters to be preset parameters so that the sampling also has uniformity and certainty.

[0046] Among them, a very large prime number refers to a prime number that is larger than the value usually calculated in the scene. For example, the resolution of a camera image is 1920*1080, so the calculation order of the image itself is 10 3 , 10 can be used for this 5 or 10 6 The prime numbers of the order of magnitude are used as the corresponding values ​​of prime_a, prime_b and prime_c, such as 500299, 1999007 and 777277, etc. The corresponding initial sampling angle can be obtained by substituting the prime numbers of the order of magnitude greater than the pixel magnitude of the camera image into the above formula. The formula is calculated by modulo, and by modulo 360, a highly random angle value in the range of 0-360 can be obtained as the corresponding initial sampling angle.

[0047] Optionally, the preset initial parameter and the preset growth parameter satisfy the formula: a+b*(n max -1)*θ interval ≤r max, where a is the preset initial angle, b is the preset growth parameter, and r max is the preset maximum pole diameter, n max is the number of sampling points, θ interval is the sampling interval angle.

[0048] When sampling based on the above formula, the first sampling point is the pixel point with respect to the origin at a polar angle of θ init , the polar diameter is a, and the last sampling point is the pixel point relative to the origin with a polar angle of (n max -1)*θ interval +θ init , the polar diameter is a+b*(n max -1)*θ interval , and in order to satisfy r is not greater than the preset maximum pole diameter r max The sampling point polar diameter requirement is met, so the preset initial parameter a and the preset growth parameter b need to satisfy the formula. Among them, since the polar diameter of the first point is not affected by the preset initial angle, its value is a. Therefore, a can be preset in advance to 0 or a smaller value close to the origin, and the preset a value is substituted into the above formula as a known parameter to determine the size of b, so that the sampling can be uniformly and quickly collected to the preset number of sampling points within the range of the preset maximum polar diameter.

[0049] Optionally, see Figure 3 , after selecting corresponding sampling points on the Archimedean spiral at every preset sampling interval angle, it also includes:

[0050] Step 33: Select a group of sampling points to form a corresponding pre-sampling list of pixel points.

[0051] Step 34: Based on the positional relationship between each pixel point in the conversion image, the pre-sampling list is transformed to obtain a sampling point corresponding to each pixel point.

[0052] The subsequent formation of soft shadows requires evaluating the degree of occlusion of each pixel based on the sampling points corresponding to all pixels. Since each pixel corresponds to a group of sampling points, multiple samplings are usually involved in the sampling process, and each sampling requires repeated calculations.

[0053] In the traditional soft shadow generation method based on Poisson sampling, when using Poisson sampling to generate sampling points, the sampling method usually adopted is the recursive subdivision method, but it includes repeated pass-rejection steps of generating too many candidate points and rejecting some of the candidate points. Therefore, when the sampling points are too close or too far apart, it will cause extra time waste. The sampling method of sampling a pixel point through position transformation cannot be generalized to other pixel points for use. Therefore, its efficiency is extremely low, and it is difficult to ensure the certainty, uniformity and reliability of the sampling points.

[0054] Since the sampling based on Archimedean spiral is a type of sampling method with strong certainty and uniformity, the present application can generate a pre-sampling list based on a group of sampling points obtained by sampling the Archimedean spiral, and then perform corresponding position transformation for sampling according to the position relationship of the corresponding pixel points, thereby reducing repeated calculations. Specifically, the positions of all sampling points corresponding to a certain pixel point can be calculated in advance based on the Archimedean spiral to obtain a pre-sampling list, and when sampling other pixel points, the origin position corresponding to each sampling point in the predicted sample list can be adjusted to other pixel points according to the position relationship between the pixel points, and the position relationship of the translation or rotation corresponding to the adjustment process of the pre-sampling list is determined to determine the position of the corresponding sampling point, so that the nearby pixel points of other pixel points can be sampled. Therefore, the sampling method of setting the pre-sampling list only needs to perform a simple position transformation to obtain the sampling points corresponding to each pixel point, which can effectively avoid repeated calculations, reduce the number of sampling iterations, and effectively improve the efficiency of sampling.

[0055] Step 40: Compare the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the corresponding pixel point, and adjust the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0056] The first depth value is a measurement parameter of the distance between the visible pixel point in the camera image converted to the point in the converted image and the light source, and the second depth value is a measurement parameter of the distance between the corresponding point of the pixel point in the depth map that can be seen from the perspective of the light source and the light source. The first depth value and the second depth value can be distance values, or they can be representation values ​​obtained after normalization, logarithmization or other mathematical transformations. The first depth value obtained is greater than or equal to the second depth value. When the first depth value is equal to the second depth value, it means that the corresponding pixel point can be illuminated by the light source, and when the first depth value is less than the second depth value, it means that the corresponding pixel point is blocked and cannot be directly illuminated by the light source. Therefore, it is possible to determine whether the pixel point is blocked based on the first depth value and the second depth value.

[0057] Since the sampling points are other pixel points sampled near the corresponding pixel points based on the Archimedean spiral, the occlusion of the sampling points can reflect the occlusion degree of the area near the pixel points. When the occlusion degree of the area near the pixel points is large, the pixel points are adjusted to be darker, and when the occlusion degree of the area near the pixel points is small, the pixel points are adjusted to be brighter. On this basis, the brightness of each pixel point is adjusted to obtain a smooth soft shadow effect.

[0058] Optionally, see Figure 4 , comparing the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the occlusion degree of the corresponding pixel point, and adjusting the brightness value of the corresponding pixel point in the camera image based on the occlusion degree to obtain a soft shadow of the target scene, including:

[0059] Step 41: When the first depth value is greater than the second depth value, the sampling point is regarded as an obscured point.

[0060] Step 42: The proportion of blocked points in the sampling points corresponding to each pixel is taken as the blocking degree of the pixel.

[0061] Step 43: adjusting the brightness value of the pixel in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0062] By comparing the first depth value of each sampling point in the conversion image with the second depth value of the corresponding point in the depth map, it is possible to accurately determine which sampling points are blocked. When the first depth value is greater than the second depth value, it means that there is an obstacle on the path from the light source to the sampling point, so the sampling point is regarded as a blocked point. Thereafter, the proportion of the number of blocked points in the sampling points corresponding to each pixel point is used as a quantitative indicator of the degree of occlusion of the pixel point, which can intuitively and accurately reflect the occlusion of the area near the pixel point, where the proportion can be a direct numerical ratio or a numerical value obtained after some linear, logarithmic or weighted mixing processing. The higher the degree of occlusion of the pixel point, the more its brightness value will be reduced, and vice versa. The adjustment of the brightness value can be based on a linear relationship or a specific brightness adjustment curve. By adjusting the brightness of the corresponding pixel point, the soft shadow effect caused by the occlusion of the target scene can be accurately and effectively simulated, thereby improving the simulation performance of the target scene. In addition, the method for generating soft shadows is particularly suitable for the simulation of autonomous driving scenes with extremely high requirements for certainty and timeliness, which is conducive to improving the authenticity and reliability of autonomous driving scene simulation.

[0063] See also Figure 5 , Figure 5 It is a structural schematic diagram of an embodiment of a soft shadow generating device provided in the present application.

[0064] The soft shadow generating device 50 includes: an acquisition module 51, which is used to acquire a depth map of a target scene under the perspective of a light source, and a camera image of the target scene under the perspective of a camera; a conversion module 52, which is used to convert the camera image into the light source perspective coordinate system of the depth map to obtain a converted image; a sampling module 53, which is used to sample the nearby pixel points corresponding to each pixel point in the converted image based on the Archimedean spiral to obtain multiple sampling points corresponding to each pixel point; a generation module 54, which is used to compare the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the pixel point, and adjust the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

[0065] Optionally, the sampling module 53 is further specifically used to: generate an Archimedean spiral with a pixel point as the origin; select a corresponding sampling point on the Archimedean spiral at every preset sampling interval angle, wherein the distance between the sampling point and the pixel point does not exceed a preset maximum polar diameter.

[0066] Optionally, the sampling module 53 selects corresponding sampling points on the Archimedean spiral at every preset sampling interval angle, based on the formula: Where r is not greater than the preset maximum pole diameter r max The sampling point polar diameter, θ is the sampling point polar angle, θ init is the initial sampling angle, θ interval is the preset sampling interval angle, a is the preset initial parameter of the Archimedean spiral, b is the preset growth parameter of the Archimedean spiral, and n is less than the preset number of sampling points n max A natural number.

[0067] Optionally, the calculation formula for the initial sampling angle is: θ init =(x*prime_a+y*prime_b)mod prime_c mod 360, where, θ init is the initial sampling angle, (x, y) is the position coordinate of the pixel point in the light source perspective coordinate system, prime_a, prime_b and prime_c are extremely large prime numbers that are larger than the pixel order of the camera image and are different from each other.

[0068] Optionally, the preset initial parameter and the preset growth parameter satisfy the formula: a+b*(n max -1)*θ interval ≤r max , where a is the preset initial angle, b is the preset growth parameter, and r max is the preset maximum pole diameter, n max is the number of sampling points, θ intervalis the sampling interval angle.

[0069] Optionally, after selecting corresponding sampling points on the Archimedean spiral at every preset sampling interval angle, the sampling module 53 is further used to: select a group of sampling points to form a pre-sampling list of corresponding pixel points; based on the positional relationship between each pixel point in the conversion image, transform the position of the pre-sampling list to obtain a sampling point corresponding to each pixel point.

[0070] Optionally, the generation module 54 is also specifically used to use the sampling point as an occluded point when the first depth value is greater than the second depth value; use the proportion of occluded points in the sampling points corresponding to each pixel point as the occlusion degree of the pixel point; and adjust the brightness value of the pixel point in the camera image based on the occlusion degree to obtain a soft shadow of the target scene.

[0071] Since the embodiments of the device part correspond to the embodiments of the above-mentioned method, the introduction of the soft shadow generating device 50 provided in the embodiment of the present invention and the corresponding beneficial effects can refer to the above-mentioned soft shadow generating method embodiment, and this embodiment will not be repeated here.

[0072] See also Figure 6 , Figure 6 It is a structural diagram of an embodiment of the storage medium provided by the present application.

[0073] The storage medium 60 stores program data 61. When the program data 61 is executed by the processor, the following is achieved: Figures 1 to 4 The described soft shadow generation method.

[0074] The program data 61 is stored in a storage medium 60, and includes a number of instructions for enabling a network device (such as a router, a personal computer, a server, or other network device) or a processor to execute all or part of the steps of the method described in each embodiment of the present application.

[0075] Optionally, the storage medium 60 may be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, or other medium that can store the program data 61 .

[0076] See also Figure 7 , Figure 7 It is a structural schematic diagram of an embodiment of a computer device provided by the present application.

[0077] The computer device 70 includes a processor 72 and a memory 71 connected to each other. The memory 71 stores a computer program. When the processor 72 executes the computer program, the following is achieved: Figures 1 to 4 The soft shadow generation method described herein. The memory 71 may include the storage medium 60, or may be other independently developed memory.

[0078] Different from the prior art, the present application discloses a soft shadow generation method, device, storage medium and computer equipment. The present application samples the converted image obtained by converting the camera image under the camera perspective through the Archimedean spiral, and compares the depth value of the sampling point in the converted image with the depth value of the corresponding point of the sampling point in the depth map under the light source perspective, so as to determine the degree of occlusion of the corresponding pixel point, and adjust the brightness value of the corresponding pixel point based on the occlusion degree to obtain the soft shadow of the target scene. The sampling of the Archimedean spiral based on this method can cover the area near the pixel point more evenly and more deterministically, avoiding oversampling and sampling omission. The sampling method based on the Archimedean route is simple to implement and does not require additional repeated sampling and calculation. The computing power requirement is low, which is conducive to improving the efficiency of soft shadow generation, and can generate accurate, smooth and reliable soft shadow effects, which is conducive to improving the simulation performance in the simulation scene.

[0079] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, storage medium embodiment and computer equipment embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0080] The present application can be used in many general or special computing system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0081] In the several embodiments provided in this application, it should be understood that the disclosed methods, devices, storage media, and computer equipment can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0082] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0083] In addition, each functional unit in each embodiment of the present application 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.

[0084] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A soft shadow generation method, characterized in that: include: Obtaining a depth map of a target scene from a light source perspective, and a camera image of the target scene from a camera perspective; Convert the camera image to the light source viewing angle coordinate system of the depth map to obtain a converted image; Based on the Archimedean spiral, the neighboring pixel points corresponding to each pixel point in the conversion image are sampled to obtain a plurality of sampling points corresponding to each pixel point; Compare the first depth value of each sampling point in the converted image with the second depth value of the corresponding point in the depth map of each sampling point to evaluate the degree of occlusion of the corresponding pixel point, and adjust the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

2. The soft shadow generation method according to claim 1, characterized in that: The method of sampling the neighboring pixel points corresponding to each pixel point in the conversion image based on the Archimedean spiral to obtain a plurality of sampling points corresponding to each pixel point includes: Generate the Archimedean spiral with the pixel point as the origin; The corresponding sampling point is selected on the Archimedean spiral at every preset sampling interval angle, wherein the distance between the sampling point and the pixel point does not exceed a preset maximum pole diameter.

3. The soft shadow generation method according to claim 2, characterized in that: The corresponding sampling points are selected on the Archimedean spiral at every preset sampling interval angle based on the following formula: Among them, r is not greater than the preset maximum pole diameter r max The sampling point polar diameter, θ is the sampling point polar angle, θ init is the initial sampling angle, θ interval is the preset sampling interval angle, a is the preset initial parameter of the Archimedean spiral, b is the preset growth parameter of the Archimedean spiral, and n is less than the preset number of sampling points n max A natural number.

4. The soft shadow generation method according to claim 3, characterized in that: The calculation formula of the initial sampling angle is: i init =(x*prime_a+y*prime_b)mod prime_c mod 360 Among them, θ init is the initial sampling angle, (x, y) is the position coordinate of the pixel point in the light source viewing angle coordinate system, prime_a, prime_b and prime_c are extremely large prime numbers that are larger than the pixel order of the camera image and are different from each other.

5. The soft shadow generation method according to claim 3, characterized in that: The preset initial parameter and the preset growth parameter satisfy the formula: a+b*(n max -1)*θ interval ≤r max Wherein, a is the preset initial angle, b is the preset growth parameter, r max is the preset maximum pole diameter, n max is the preset number of sampling points, θ interval is the preset sampling interval angle.

6. The soft shadow generation method according to claim 2, characterized in that: After selecting the corresponding sampling point on the Archimedean spiral at every preset sampling interval angle, the method further includes: Selecting a group of the sampling points to form a corresponding pre-sampling list of the pixel points; Based on the positional relationship between the pixels in the conversion image, the pre-sampling list is positionally transformed to obtain sampling points corresponding to the pixels.

7. The soft shadow generation method according to claim 1, characterized in that: The comparing the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the corresponding pixel point, and adjusting the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain the soft shadow of the target scene includes: When the first depth value is greater than the second depth value, taking the sampling point as an obscured point; Taking the proportion of the obscured points in the sampling points corresponding to each pixel as the obscuration degree of the pixel; The brightness value of the pixel in the camera image is adjusted based on the degree of occlusion to obtain a soft shadow of the target scene.

8. A soft shadow generating device, characterized in that: include: An acquisition module, used to acquire a depth map of a target scene from a perspective of a light source, and a camera image of the target scene from a perspective of a camera; A conversion module, used to convert the camera image into a light source viewing angle coordinate system of the depth map to obtain a converted image; A sampling module, used for sampling nearby pixel points corresponding to each pixel point in the conversion image based on the Archimedean spiral, to obtain a plurality of sampling points corresponding to each pixel point; A generating module is used to compare the first depth value of each sampling point in the converted image with the second depth value of the corresponding point of each sampling point in the depth map to evaluate the degree of occlusion of the pixel point, and adjust the brightness value of the corresponding pixel point in the camera image based on the degree of occlusion to obtain a soft shadow of the target scene.

9. A storage medium having program data stored thereon, characterized in that: When the program data is executed by a processor, the steps of the soft shadow generation method according to any one of claims 1 to 7 are implemented.

10. A computer device, characterized in that: The method comprises a processor and a memory connected to each other, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the soft shadow generation method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Rendering of soft shadows using depth maps

    CA2748681A1

  • Method for shadow rendering in virtual home decoration indoor scene design

    CN103903296A

  • Real-time soft shadow realization method based on image screen space

    CN104103089A

  • Illumination compensation method based on bionic spiral and image enhancement method

    CN108550124A

  • Shadow rendering method and device, computer equipment and storage medium

    CN116012520A