Soft shadow generation method and image processing system

By generating soft shadows through shadow segmentation models and weighted processing, the problems of unnatural shadow boundaries and color shifts in mobile devices are solved, achieving smooth transitions and tonal uniformity in shadow areas. It is suitable for 2D/3D games, animations, movie special effects, and VR/AR scenes.

CN121962403APending Publication Date: 2026-05-01CHIPONE (SHENZHEN) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHIPONE (SHENZHEN) TECH CO LTD
Filing Date
2025-12-12
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In resource-constrained environments such as mobile devices, existing soft shadow generation methods suffer from problems such as template estimation errors leading to obvious fusion boundaries, high computational resource consumption, and color distortion in soft shadows.

Method used

A shadow segmentation model is used to segment the shadows of the current frame image, determine the shadow confidence of each pixel, and generate soft shadow effects through weighted averaging and dynamic weight processing. The shadow rendering process is optimized by combining frame error processing.

Benefits of technology

It achieves a smooth transition in shadow areas, solves the problem of soft and hard shadow blending boundaries, optimizes the jagged edges and color cast in shadow areas, and presents a more harmonious visual effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121962403A_ABST
    Figure CN121962403A_ABST
Patent Text Reader

Abstract

The invention provides a soft shadow generation method and an image processing system. The method comprises the following steps: performing shadow segmentation on a current frame image to obtain a shadow mask; for the current frame image, determining the shadow confidence of the pixel; for each pixel in the current frame of image, obtaining a statistical value of the pixel by using pixel values of peripheral pixels in a preset range and confidence coefficient weighted average; for each pixel in the current frame image, determining a dynamic weight according to a distance relationship between the pixel and a shadow area indicated by the shadow mask; and weighting each pixel in the current frame image according to the statistical value and the pixel value and the dynamic weight, and outputting an image formed by the weighted pixels as an image with a soft shadow effect. The method solves the problem of soft and hard shadow fusion boundary, optimizes the sawtooth problem of the shadow area, enables the overall visual effect of the shadow to be smoother, and also solves the problem of soft shadow color cast.
Need to check novelty before this filing date? Find Prior Art

Description

Soft shadow generation methods and image processing systems Technical Field

[0001] This disclosure relates to the field of computer graphics and image processing technology, and in particular to a soft shadow generation method and image processing system. Background Technology

[0002] In 2D / 3D game and animation rendering, shadow effects are crucial for enhancing the three-dimensionality and visual realism of scenes. Traditional shadow generation methods, such as hard shadows based on simple geometric projections, suffer from problems such as jagged edges, abrupt transitions, and poor integration with the scene, resulting in unnatural visual effects.

[0003] Soft shadow technology simulates the penumbra effect created when light passes through the edge of an object by calculating the light source, object shape, and material. Compared to hard shadows, it can more subtly simulate the gradual diffusion of light as it is blocked by an object, generating highly realistic shadow images. This technology is widely used in film special effects, game rendering, and VR / AR fields, significantly enhancing the immersion and realism of visual scenes, and is one of the important technologies for improving the realism of computer graphics.

[0004] To achieve real-time rendering of soft shadows in resource-constrained environments such as mobile devices, the industry generates soft shadows based on hard shadows using shadow templates. However, this method has drawbacks, such as: template estimation errors leading to obvious blending boundaries; and the calculated shadow content being both resource-intensive and too homogeneous, resulting in color distortion of the soft shadows.

[0005] Therefore, it is necessary to design a complete soft shadow generation solution that covers positioning, optimization and adaptation. Summary of the Invention

[0006] In view of this, the purpose of the present disclosure is to provide a soft shadow generation method and an image processing system.

[0007] In a first aspect, embodiments of this disclosure provide a method for generating soft shadows, including:

[0008] Perform shadow segmentation on the current frame image to obtain a shadow mask;

[0009] For each pixel in the current frame image, determine the shadow confidence of that pixel;

[0010] For each pixel in the current frame image, the statistical value of the pixel is obtained by weighting the pixel values ​​and confidence levels of the surrounding pixels within a preset range.

[0011] For each pixel in the current frame image, a dynamic weight is determined based on its distance relationship with the shadow region indicated by the shadow mask;

[0012] For each pixel in the current frame image, its statistical value and pixel value are weighted according to the dynamic weight, and the image composed of the weighted pixels is output as an image with a soft shadow effect.

[0013] In some embodiments, the current frame image is a YUV image, and determining the shadow confidence of each pixel in the current frame image includes:

[0014] Calculate the statistical values ​​of the Y components of all pixels within the shadow region indicated by the shadow mask, and use them as the feature threshold of the shadow region;

[0015] For pixels outside the shadow region indicated by the shadow mask, their shadow confidence is set to zero;

[0016] For a pixel inside the shadow region indicated by the shadow mask, the shadow confidence is calculated based on the difference between the Y value of its pixel value and the feature threshold of the shadow region indicated by the shadow mask.

[0017] In some embodiments, calculating the shadow confidence level for pixels within the shadow region indicated by the shadow mask, based on the difference between the Y value of the pixel and a feature threshold of the shadow region indicated by the shadow mask, includes:

[0018] For a pixel inside the shadow region indicated by the shadow mask, and whose pixel value's Y value is less than or equal to the feature threshold of the shadow region indicated by the shadow mask, its shadow confidence is set to the maximum value;

[0019] For a pixel inside the shadow region indicated by the shadow mask, but whose pixel value Y value is greater than the feature threshold of the shadow region indicated by the shadow mask, the shadow confidence is calculated based on the degree of difference between the pixel value Y value and the feature threshold of the shadow region indicated by the shadow mask.

[0020] In some embodiments, the distance between each pixel in the current frame image and the shadow region indicated by the shadow mask is calculated using the following method:

[0021] If the pixel is outside the shadow area indicated by the shadow mask, then calculate the nearest distance from the pixel to all pixels within the shadow area within a set range centered on the pixel;

[0022] If the pixel is inside the shadow area indicated by the shadow mask, then calculate the nearest distance from the pixel to all pixels outside the shadow area within a set range centered on the pixel.

[0023] In some embodiments, the shadow segmentation is implemented using a lightweight instance segmentation network.

[0024] In some embodiments, the method further includes: normalizing the dynamic weights.

[0025] In some embodiments, in the step of obtaining the statistical value of a pixel by weighting the pixel values ​​and confidence levels of the surrounding pixels within a preset range, the preset range of different sizes is configured according to the game category.

[0026] In some embodiments, the current frame image comes from a sequence of frame images, and the soft shadow generation method performs frame misalignment processing on the sequence of frame images, including:

[0027] When the first frame of the image is input, no image is output;

[0028] When the second frame image is input, the first frame image without soft shadow effects is output.

[0029] Starting from frame 3, output the previous frame image with soft shadow effects sequentially from frame N to frame 3.

[0030] In some embodiments, the method further includes converting the RGB image to a YUV image.

[0031] In a second aspect, embodiments of this disclosure provide an image processing system, including:

[0032] The receiving and buffering unit is used to receive frame images frame by frame, compress and buffer the received frame images and intermediate images during the processing.

[0033] The segmentation unit is used to perform shadow segmentation on the current frame image to obtain a shadow mask;

[0034] The first calculation unit is used to determine the shadow confidence of each pixel in the current frame image for each pixel, and to obtain the statistical value of the pixel by weighted averaging the pixel values ​​and confidence of the surrounding pixels within a preset range.

[0035] The second calculation unit is used to determine the dynamic weight for each pixel in the current frame image based on its distance relationship with the shadow region indicated by the shadow mask;

[0036] The soft shadow image generation unit is used to perform weighted processing on each pixel in the current frame image according to the statistical value and the pixel value according to the dynamic weight, and output the image composed of the weighted pixels as an image with soft shadow effect.

[0037] Thirdly, embodiments of this disclosure provide an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the soft shadow generation method described in any of the preceding claims.

[0038] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing a computer program or instructions that, when executed by a processor, implement the soft shadow generation method described in any of the preceding claims.

[0039] In summary, the soft shadow generation method provided in this disclosure, combined with an AI shadow segmentation model, achieves "softening" processing of shadow areas in the rendered 2D image. This not only solves the problem of soft and hard shadow fusion boundaries and optimizes the jagged edges in shadow areas, making the overall shadow visual effect smoother, but also solves the problem of soft shadow color cast, ensuring the uniformity of the overall shadow tone and presenting a more harmonious visual effect. This solution can be adapted to many scenarios such as 2D / 3D games and animations, movie special effects, VR / AR, etc.

[0040] It should be noted that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this disclosure. Attached Figure Description

[0042] The above and other objects, features, and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0043] Figure 1 is a flowchart of a soft shadow generation method provided in an embodiment of this disclosure;

[0044] Figure 2 is a schematic diagram of the structure of Yolov5n-seg;

[0045] Figure 3 is a schematic diagram of the shadow mask output by YOLOv5n-seg;

[0046] Figure 4 is a schematic diagram of the distribution of shadow confidence corresponding to the shadow mask in Figure 3;

[0047] Figures 5A and 5B illustrate how the shortest distance from the outer pixel of the shadow mask to the shadow mask region and the shortest distance from the inner pixel of the shadow mask to the non-shadow mask region are calculated.

[0048] Figure 6 is a dynamic distance weight distribution diagram according to an embodiment of the present disclosure;

[0049] Figure 7 shows examples of setting different parameter values ​​according to game category;

[0050] Figure 8 shows a flowchart of the frame error design process for the image processing system.

[0051] Figures 9 and 10 provide comparative examples of different degrees of soft shadow effects in embodiments of this disclosure. Detailed Implementation

[0052] The present application will now be described in more detail with reference to the accompanying drawings. In the various drawings, the same elements are indicated by similar reference numerals. For clarity, the various parts in the drawings are not drawn to scale. Furthermore, some well-known parts may not be shown.

[0053] The following terms are used in this article:

[0054] Soft shadows are shadows with blurred, gradual edges. When the light source is large or far from the object, the scattering and diffusion of light results in a smooth transition at the shadow's edge. Hard shadows, on the other hand, are shadows with sharp, clear edges. They primarily reflect the shape of an object under different lighting conditions and typically occur when the light source is small or close to the object, with the light rays almost parallel, resulting in no transition at the shadow's edge. Soft and hard shadows differ in edge sharpness, shadow depth, light source size, and the gradation characteristics of the shadow.

[0055] Figure 1 is a schematic flowchart of a soft shadow generation method according to an embodiment of the present disclosure. As shown in Figure 1, the soft shadow generation method includes the following steps.

[0056] In step S101, shadow segmentation is performed on the current frame image to obtain a shadow mask.

[0057] The current frame image in this step is a 2D image from a 2D image sequence. The 2D image sequence can come from rendered 2D / 3D games, animations, or movies. Due to rendering, each image in the 2D image sequence already has a preliminary shadow effect. However, this shadow effect is closer to a hard shadow and needs to be further "softened".

[0058] In this step, an AI model is used to perform shadow segmentation on the current frame image. An example of such an AI model is Yolov5n-seg, as shown in Figure 2. Yolov5n-seg is a lightweight version of the YOLOv5 series designed for resource-constrained environments (such as mobile devices, embedded systems, or real-time applications requiring high frame rates). It has instance segmentation capabilities and can output a precise pixel-level mask for each detected object. This means it can accurately delineate the irregular shapes of shadows, such as the complex shadow outlines cast by objects like people and trees. Figure 3 shows a schematic diagram of the shadow mask after shadow segmentation of the input frame image using Yolov5n-seg.

[0059] In step S102, the shadow confidence of each pixel in the current frame image is determined based on the shadow mask. The shadow confidence of each pixel represents the confidence that the pixel belongs to the shadow.

[0060] For YUV images, since the main characteristic of shadow areas compared to surrounding non-shadow areas is a significant reduction in brightness (Y component), this step can calculate the statistical values ​​(e.g., average, median, or maximum) of the Y components of all pixels within the shadow area indicated by the shadow mask. This statistical value can be used as a feature threshold for the shadow area. Then, for each pixel, its Y value is compared with the shadow feature threshold, and the shadow confidence of that pixel is determined based on the comparison result. For example, Y_shadow_avg is the average value of the Y components in the shadow area. If a pixel's Y value is lower than Y_shadow_avg, and it is within the area indicated by the shadow mask, it definitely belongs to the shadow area, with the highest confidence. If a pixel's Y value is greater than Y_shadow_avg, but it is still within the area indicated by the shadow mask, the larger the difference between the pixel's Y value and Y_shadow_avg, the lower the shadow confidence. Furthermore, to simplify the calculation, the shadow confidence is usually limited to a certain range. For example, for pixels outside the shadow area, their shadow confidence is directly set to zero. For pixels inside the shadow area, if their pixel value Y is less than or equal to the feature threshold, their shadow confidence is directly set to the maximum value (e.g., 256). For pixels inside the shadow area, if their pixel value Y is greater than the feature threshold, the shadow confidence is calculated based on the difference between the pixel value Y and the feature threshold.

[0061] Figure 4 shows a schematic diagram of the shadow confidence level corresponding to the shadow mask in Figure 3. Formula (1) gives the formula for calculating the shadow confidence level:

[0062] (1)

[0063] in, This represents the current pixel value (Y value), and `thred` represents the feature threshold for the shadow. This indicates the confidence level of the shadow.

[0064] For HSV / HSL images, there is also a sharp drop in the V (luminance) or L (brightness) components in shadow areas, so the above method can be used for processing. For RGB images, convert them to YUV images before processing.

[0065] In step S103, for each pixel in the current frame image, the statistical value of the pixel is obtained by weighting the pixel values ​​and confidence levels of the surrounding pixels within a preset range.

[0066] This step uses the following formula (2) to obtain the statistical value of each pixel in the current frame image.

[0067] (2)

[0068] in, This represents the statistical value at (i,j). This represents the pixel value (Y, U, or V value) at (i+m,j+n). This represents the shadow confidence score of the pixel at (i+m,j+n). This represents the preset range.

[0069] It should be understood that pixels at the center of the shadow area mostly have high shadow confidence, while pixels outside the shadow area mostly have low shadow confidence. After weighted averaging, the statistical value inside the shadow area will approach the typical value of the shadow area (low brightness, specific chromaticity), and the difference between the original value and the statistical value is very small. The statistical value outside the shadow area will approach the typical value of the illuminated area (high brightness), and the difference between the original value and the statistical value is also very small. Pixels located at the edge of the shadow, because their neighborhood contains some pixels with high shadow confidence and some pixels with low shadow confidence, will have a weighted average statistical value that is a smooth transition value between shadow and non-shadow. This smooth transition value reflects the local contextual information of the edge and can effectively avoid the soft shadow color cast problem caused by using uniform feature values.

[0070] In step S104, for each pixel in the current frame image, a dynamic weight is determined based on its distance relationship with the shadow region indicated by the shadow mask.

[0071] Specifically, if the current pixel is outside the shadow area indicated by the shadow mask, the nearest distance from that pixel to the shadow area indicated by the shadow mask is calculated. If the current pixel is inside the shadow area indicated by the shadow mask, the nearest distance from that pixel to the non-shadow area is calculated. For example, referring to Figure 5A, if the current pixel A is outside the shadow mask, the distances from pixel A to all pixels within the shadow area indicated by the shadow mask within a circular area centered on A and with a radius of shadow_size are calculated, and the minimum value among them is the nearest distance from that pixel to the preferred shadow area.

[0072] Referring to Figure 5B, if the current pixel B is a pixel within the shadow area indicated by the shadow mask, then calculate the distance from pixel B to all pixels outside the shadow area indicated by the shadow mask within a circular area centered on B and with a radius of shadow_size, and count the minimum value among them as the shortest distance from that pixel to the non-shadow area.

[0073] Then, the dynamic weight is calculated based on the relationship between the dynamic weight and the nearest distance. For example, the dynamic weight of each pixel is calculated using sampling formula (3):

[0074] (3)

[0075] in, This represents the dynamic weight of the current pixel. This indicates the closest distance between the current pixel and the shadow mask.

[0076] For ease of calculation, the dynamic weights are restricted to the range [0,1]. Figure 6 shows a schematic diagram of the dynamic weights. As can be seen from the figure, the dynamic weight of a pixel completely outside the shadow area is 1, the dynamic weight of a pixel at the center of the shadow area is 0, and the dynamic weight of a pixel at the edge of the shadow area is between 0 and 1.

[0077] In step S105, for each pixel in the current frame image, a weighted processing is performed based on its statistical value and pixel value according to dynamic weights, and the image composed of the weighted pixels is output as an image with soft shadows.

[0078] This step can be performed by weighting each pixel using the following formula (4).

[0079] (4)

[0080] in, This represents the statistical value (Y, U, or V value) at (i,j). This represents the pixel value (Y, U, or V value) at (i,j). This represents the dynamic weight of the pixel at (i,j). This represents the weighted result value.

[0081] It should be understood that, through the above embodiment, pixels located outside the shadow area indicated by the shadow mask and far from the shadow will have their corresponding pixel values ​​in the output image almost completely preserved from their original pixel values ​​(i.e., ), pixels located in the core region of the shadow, the corresponding pixel values ​​in the output image are almost entirely determined by statistical values ​​(i.e. The statistical value is calculated based on the surrounding shadow pixels, representing the average, smooth dark tone of the shadow area. This eliminates noise and fine textures that may exist in the original image. For edge pixels on the shadow side, the corresponding pixel value in the output image is a slight mixture of the statistical value (shadow tone) and the original pixel value. The statistical value is dominant, but some original details begin to be incorporated. For edge pixels on the illuminated side, the corresponding pixel value in the output image is a slight mixture of the statistical value (shadow tone) and the original pixel value. Illumination details dominate, but there is a hint of shadow. For pixels in the center of the edge, the corresponding pixel value in the output image is an equal mixture of the shadow tone and the original pixel value. In summary, through this embodiment, the transition between the shadow tone and the illuminated area in the output image is no longer a harsh, jagged jump, but rather a gradual transition band with continuous brightness / color, i.e., a soft shadow.

[0082] In the above embodiments, both formulas (2) and (3) use This parameter can be adjusted to meet the different requirements of various users for soft shadow effects. The specific values ​​are used to adjust the soft shadow intensity. The example in Figure 7 shows the settings based on the game category of the input image. The specific value.

[0083] Correspondingly, this disclosure also provides an image processing system, which includes module units corresponding to the steps in the above method:

[0084] The receiving and buffering unit is used to receive frame images frame by frame, compress and buffer the received frame images and intermediate images during the processing.

[0085] The segmentation unit is used to perform shadow segmentation on the current frame image to obtain a shadow mask;

[0086] The first calculation unit is used to determine the shadow confidence of each pixel in the current frame image for each pixel, and to obtain the statistical value of the pixel by weighted averaging the pixel values ​​and confidence of the surrounding pixels within a preset range.

[0087] The second calculation unit is used to determine the dynamic weight for each pixel in the current frame image based on its distance relationship with the shadow region indicated by the shadow mask;

[0088] The soft shadow image generation unit is used to perform dynamic weighting of the statistical value and pixel value of each pixel in the current frame image, and output the image composed of the weighted pixels as an image with soft shadow effect.

[0089] In a further embodiment, considering that it is necessary to extract the shadow mask from the frame image and count the feature threshold of the shadow, the display of the soft shadow effect is delayed from the input time of the data of this frame. Figure 8 shows a flowchart of this frame-shifting design of the image processing system.

[0090] In Figure 8, step S1 receives the input Nth frame RGB image and converts it into a YUV image. The YUV image is divided into two paths: one path is processed by image quality enhancement in step S2, and then the Nth frame image is compressed and cached in steps S4 and S6; the other path is processed by AI shadow detection in step S3 to generate a shadow mask, and then the shadow mask of the Nth frame image is compressed and cached in steps S5 and S7. In steps S8 and S9, the compressed N-1th frame image and its corresponding shadow mask are retrieved from the cache and decompressed. Then, in step S10, the decompressed N-1th frame image is subjected to soft processing. The soft processing can refer to the process in Figure 1. The soft-processed output image has a soft shadow effect. Step S11 uses other image processing algorithms to perform other processing on it, and then step S12 converts the output image from YUV to RGB image for output, so that when the Nth image is input, the N-1th frame image with a soft shadow effect is output. When the first frame image is input, no image is output. When the second frame image is input, the feature threshold of the shadow in the second frame image needs to be calculated, so only the first frame image without shadow effect is output. When the third to Nth frames are input, the previous frame image with soft shadow effect is output respectively.

[0091] Figures 9 and 10 provide comparative examples of different degrees of soft shadow effects in embodiments of the present disclosure, with the image in Figure 9 showing a weak soft shadow and the image in Figure 10 showing a strong soft shadow.

[0092] In summary, the soft shadow generation method and image processing system provided in this disclosure, combined with an AI shadow segmentation model, achieve "softening" of shadow areas in rendered 2D images. This not only solves the problem of soft and hard shadow fusion boundaries and optimizes the jagged edges in shadow areas, making the overall shadow visual effect smoother, but also solves the problem of soft shadow color cast, ensuring the uniformity of the overall shadow tone and presenting a more harmonious visual effect. This solution is adaptable to many scenarios such as 2D / 3D games and animations, movie special effects, VR / AR, etc.

[0093] The soft shadow generation method and image processing system provided in this disclosure can also be configured as a computer program, which is configured as a computer-readable storage medium storing one or more computer instructions. When these one or more computer instructions are executed, they implement the steps in the 2D soft shadow generation method. Furthermore, the computer program configured as the soft shadow generation method and image processing system provided in this disclosure can also be stored in the memory of an electronic device and run by the processor of that electronic device, which can be a desktop computer, laptop computer, game console, or similar device.

[0094] It should be understood that the methods, systems, computer-readable storage media, and image processing chips of the embodiments of this disclosure are all based on the same conceptual idea and therefore can be referenced to each other.

[0095] Although the embodiments of this application are disclosed above with reference to preferred embodiments, they are not intended to limit the claims. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application shall be determined by the scope defined by the claims of this application.

[0096] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating soft shadows, characterized in that, include: Perform shadow segmentation on the current frame image to obtain a shadow mask; For each pixel in the current frame image, determine the shadow confidence of that pixel; for each pixel in the current frame image, obtain the statistical value of that pixel by weighting the pixel values ​​and confidence of the surrounding pixels within a preset range; for each pixel in the current frame image, determine the dynamic weight based on its distance relationship with the shadow area indicated by the shadow mask; for each pixel in the current frame image, weight its statistical value and pixel value according to the dynamic weight, and output the image composed of the weighted pixels as an image with a soft shadow effect.

2. The soft shadow generation method according to claim 1, characterized in that, The current frame image is a YUV image. Determining the shadow confidence of each pixel in the current frame image includes: calculating the statistical value of the Y component of all pixels inside the shadow region indicated by the shadow mask, as the feature threshold of the shadow region; setting the shadow confidence of pixels outside the shadow region indicated by the shadow mask to zero; and calculating the shadow confidence of pixels inside the shadow region indicated by the shadow mask based on the difference between the Y value of the pixel and the feature threshold of the shadow region indicated by the shadow mask.

3. The soft shadow generation method according to claim 2, characterized in that, The step of calculating the shadow confidence level for pixels within the shadow region indicated by the shadow mask, based on the difference between the Y value of the pixel and the feature threshold of the shadow region indicated by the shadow mask, includes: for pixels within the shadow region indicated by the shadow mask, where the Y value of the pixel is less than or equal to the feature threshold of the shadow region indicated by the shadow mask, setting the shadow confidence level to the maximum value; and for pixels within the shadow region indicated by the shadow mask, where the Y value of the pixel is greater than the feature threshold of the shadow region indicated by the shadow mask, calculating the shadow confidence level based on the difference between the Y value of the pixel and the feature threshold of the shadow region indicated by the shadow mask.

4. The soft shadow generation method according to claim 1, characterized in that, The distance between each pixel in the current frame image and the shadow region indicated by the shadow mask is calculated by the following method: if the pixel is outside the shadow region indicated by the shadow mask, then the nearest distance from the pixel to all pixels within the shadow region within a set range centered on the pixel is calculated; if the pixel is inside the shadow region indicated by the shadow mask, then the nearest distance from the pixel to all pixels outside the shadow region within a set range centered on the pixel is calculated.

5. The soft shadow generation method according to claim 1, characterized in that, The shadow segmentation is implemented using a lightweight instance segmentation network.

6. The soft shadow generation method according to claim 1, characterized in that, Also includes: The dynamic weights are then normalized.

7. The soft shadow generation method according to claim 1, characterized in that, In the step of obtaining the statistical value of a pixel by weighting the pixel values ​​and confidence levels of the surrounding pixels within a preset range, preset ranges of different sizes are configured according to the game category.

8. The soft shadow generation method according to claim 1, characterized in that, The current frame image comes from a frame image sequence. The soft shadow generation method performs frame error processing on the frame image sequence, including: when the first frame image is input, no image is output; when the second frame image is input, the first frame image without soft shadow effect is output; from the third frame to the Nth frame image, the previous frame image with soft shadow effect is output sequentially.

9. The soft shadow generation method according to claim 1, characterized in that, Also includes: Convert an RGB image to a YUV image.

10. An image processing system, characterized in that, include: The receiving and buffering unit is used to receive frame images frame by frame, compress and buffer the received frame images and intermediate images during the processing. The segmentation unit is used to perform shadow segmentation on the current frame image to obtain a shadow mask; The first calculation unit is used to determine the shadow confidence of each pixel in the current frame image, and to obtain the statistical value of the pixel by weighted averaging the pixel values ​​and confidence of the surrounding pixels within a preset range. The second calculation unit is used to determine the dynamic weight of each pixel in the current frame image based on its distance relationship with the shadow area indicated by the shadow mask; the soft shadow image generation unit is used to perform weighted processing on the statistical value and pixel value of each pixel in the current frame image according to the dynamic weight, and output the image composed of the weighted pixels as an image with soft shadow effect.

11. An electronic device, comprising: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the soft shadow generation method as described in any one of claims 1 to 9.

12. A computer-readable storage medium storing a computer program or instructions that, when executed by a processor, implement the soft shadow generation method as described in any one of claims 1 to 9.