A method for adding realistic physical glow effects to images
By utilizing the GPU rendering pipeline and fragment shader on mobile devices to perform pixel color parameter normalization, binarization calculation, rotation processing, and Gaussian filtering, a simple and fast method is achieved to add realistic and controllable physical illumination effects to images on mobile devices, solving the problems of complex operation and high learning cost in existing technologies.
Patent Information
- Application Number
- CN202211671520.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-12-26
AI Technical Summary
It is difficult to add realistic and controllable physical illumination effects to images simply and quickly on mobile devices, and existing software requires complex operation and learning costs.
By utilizing the GPU rendering pipeline and fragment shader on mobile devices, pixel color parameters are normalized, binarized, rotated, subjected to multiple Gaussian filters, and mixed with color filters to achieve realistic physical light emission effects.
Add realistic and controllable physical illumination effects to images quickly and easily on mobile devices. No powerful computing resources are required. Realistic physical illumination effects can be simulated with a few interactive parameters.
Smart Images

Figure CN116563130B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for adding realistic physical luminescence effects to images. Background Technology
[0002] With the rise of mobile images and videos on social networks, quickly editing videos and images on mobile devices has become an essential basic operation. However, due to limitations in shooting equipment and environment, it's difficult to capture the glowing effect of the subject, or the glowing effect may be uncontrollable and fail to achieve the desired result; or one might want to add glowing effects to digital image materials in a video to enhance a dreamlike lighting effect.
[0003] Current video post-production effects software includes tools that simulate glow effects, such as Adobe After Effects' effects and the third-party plugin Deep Glow. However, these require complex interactive operations on a computer and a significant time investment in learning how to use the software. Research on achieving superior simulated glow effects on mobile devices is lacking. Summary of the Invention
[0004] To address the aforementioned technical problems, the present invention aims to provide a method for adding realistic physical luminescence effects to digital images running on mobile devices, which can easily and quickly add realistic and controllable physical luminescence effects to image frames or elements.
[0005] To achieve the above-mentioned technical objectives, the technical solution adopted by the present invention includes:
[0006] A method for adding realistic physically glowing effects to an image includes:
[0007] S1. Obtain the input image, normalize the pixel color parameters to 0.0~1.0, and perform binarization calculations with smooth transition on the R, G, B, and Alpha channels of the input image according to the emission range threshold and smoothing parameters to obtain the first threshold color image.
[0008] S2. Rotate the first threshold color image to obtain the second threshold color image;
[0009] S3. Perform three two-dimensional Gaussian filters with different degrees of blur on the second threshold color image to obtain three images with different degrees of blur. Then, perform rotation processing on each image to obtain the first, second, and third blurred images.
[0010] S4. Adjust the brightness of the first, second, and third blurred images respectively, and then perform color blending on the first, second, and third blurred images and the input image through the color blending mode, and render them into the output image.
[0011] In some preferred embodiments, the method for performing binarization calculation with smooth transition based on the emission range threshold and smoothing parameters in step S1 includes:
[0012] S101. Determine whether the value of the current channel of the pixel is less than or equal to the minimum emission threshold. If yes, return value = 0.0; if no, proceed to step S102. Wherein, the minimum emission threshold = emission range threshold * (1.0 - smoothing parameter), emission range threshold ∈ [0.0, 1.0] and smoothing parameter ∈ (0.0, 1.0).
[0013] S102. Determine whether the value of the current channel of the pixel is greater than or equal to the light emission range threshold. If yes, return value = 1.0; otherwise, proceed to step S103.
[0014] S103. Calculate the return value y=kx-b as the binarization result of the R, G, and B channels; where b = minimum emission threshold / (emission range threshold - minimum emission threshold); k = b / minimum emission threshold; x is the value of the current channel of the pixel.
[0015] In some preferred embodiments, the method for obtaining the first threshold color image in step S1 includes:
[0016] S104. Multiply the binarized results of the R, G, and B channels by the original R, G, and B channel values respectively to obtain the brightness parameters r, g, and b, and convert them into brightness according to the RGB brightness conversion formula: Brightness = 0.2125 * r + 0.7154 * g + 0.0721 * b;
[0017] S105. Using brightness as a weight, perform a weighted average of the binarized results of the R, G, and B channels and the original R, G, and B channel values to obtain the R, G, and B channels of the first threshold color image.
[0018] The first threshold color image.rgb = binarized result.rgb * (1.0 – brightness) + input image.rgb * brightness;
[0019] S106. Add the binarized results of the R, G, and B channels together and multiply them by the original Alpha channel. The normalized result is used as the Alpha channel of the threshold color.
[0020] In some preferred embodiments, the rotation process is as follows:
[0021] The target image is subjected to matrix transformation. After translating the center point of the image to the origin, the target image is scaled down proportionally so that the diagonal length of the scaled-down image is equal to the minimum side length of the original image.
[0022] The image is rotated and shrunk in reverse according to the input angle, and then translated back to the original position to obtain the shrunk and rotated result image.
[0023] In some preferred embodiments, step S3 further includes: setting user control parameters to control the sampling distance ratio in the horizontal and vertical directions of Gaussian blur, so as to achieve different degrees of blurring in the horizontal and vertical directions, thereby achieving the purpose of controlling and modifying the shape of the emitted light.
[0024] In some preferred embodiments, the method for adjusting the brightness of the first, second, and third blurred images respectively in step S4 includes:
[0025] S401. If the adjustment intensity ∈ (0.0, 1.0], then the adjustment result .rgba = 1 – power(1 – blur .rgba, intensity);
[0026] S402. If the adjustment intensity is greater than 1.0, the adjustment result .rgba = blur .rgba * power(2.0, intensity).
[0027] In some preferred embodiments, the method for adjusting the brightness of the first, second, and third blurred images respectively in step S4 further includes:
[0028] S403. By using the R, G, and B channel values of the adjustment result .rgba and the corresponding channel values in the first, second, and third blurred images, the emission color can be modified.
[0029] In some preferred embodiments, the method for calculating color blending of the first, second, and third blurred images and the input image through color blending modes in step S4 includes:
[0030] The first blending result is obtained by calculating the first and second blurred images using a color filter blending mode;
[0031] The second blending result is obtained by combining the first blending result and the third blurred image using a color filter blending mode.
[0032] The second blending result and the input image are used to calculate the output image through a color filter blending mode.
[0033] In some preferred embodiments, the method for performing two-dimensional Gaussian filtering in step S3 includes:
[0034] With a fixed kernel size, the second threshold color image is convolved in both the horizontal and vertical directions. Different degrees of blur are achieved by controlling the number of iterations and the sampling distance.
[0035] Beneficial effects
[0036] 1. The method for adding realistic physical luminescence effects to images proposed in this invention is simple and easy to implement, requiring no powerful computing resources. It can be implemented on a mobile GPU through simple programming. 2. Based on a small number of interactive parameters, the range and color of the light source in the original image are extracted. Through multi-layer Gaussian convolution operations of different degrees, the realistic physical luminescence effect can be easily simulated, and realistic and controllable physical luminescence effects can be added to images or elements in a simple and quick manner. Attached Figure Description
[0037] Figure 1 This is a schematic diagram of a method flow according to a preferred embodiment of the present invention;
[0038] Figures 2-24 This is an example diagram showing the operation results of each step in another preferred embodiment of the present invention; Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described below with reference to the accompanying drawings. In the description of this invention, it should be understood that the terms "upper," "lower," "front," "rear," "left," "right," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention.
[0040] Example 1
[0041] like Figure 1 As shown, this embodiment provides a method for adding realistic physical luminescence effects to an image, including:
[0042] S1. Obtain the input image, normalize the pixel color parameters to 0.0~1.0, and perform binarization calculations with smooth transitions on the R, G, B, and Alpha channels of the input image according to the emission range threshold and smoothing parameters to obtain the first threshold color image.
[0043] The image can be a photograph taken by a camera or an image frame extracted from a video stream. When implementing this method using the GPU of a mobile device, the GPU rendering pipeline and fragment shader can be used to obtain the input color information of each pixel of each frame or image based on vertex information mapping.
[0044] Those skilled in the art will understand that the smoothing transition described is a conventional technique in the field, a type of region enhancement algorithm. During image generation, transmission, and copying, images are often affected by noise or data loss due to various reasons, reducing image quality (a pixel is considered to be affected by noise if it differs significantly from its surrounding pixels). This necessitates image enhancement to mitigate the impact of these defects. Smoothing algorithms include neighborhood averaging, middle finger filtering, and boundary-preserving filtering. In this embodiment, the specific smoothing method is not limited.
[0045] Image binarization is the process of setting the grayscale value of pixels in an image to 0 or 255, thus giving the entire image a distinct black and white effect. Binary images play a crucial role in digital image processing, as they significantly reduce the amount of data in an image, thereby highlighting the contours of objects. Commonly used algorithms include those built into OpenCV and Matlab, as well as the OTSU and Kittle algorithms. In this embodiment, the specific binarization method is not limited.
[0046] In some preferred embodiments, a method for performing binarization calculations with smooth transitions based on a light emission range threshold and a smoothing parameter is provided, specifically including:
[0047] S101. Determine whether the value of the current channel of the pixel is less than or equal to the minimum emission threshold. If yes, return value = 0.0; if no, proceed to step S102. Wherein, the minimum emission threshold = emission range threshold * (1.0 - smoothing parameter), emission range threshold ∈ [0.0, 1.0] and smoothing parameter ∈ (0.0, 1.0). Wherein, the emission range threshold and smoothing parameter are both user-adjustable parameters, and have initial default values when the user does not adjust them, with the aim of quickly obtaining the effect. Preferably, the initial default value of the emission range threshold is 0.7, and the initial default value of the smoothing parameter is 0.0.
[0048] S102. Determine whether the value of the current channel of the pixel is greater than or equal to the light emission range threshold. If yes, return value = 1.0; otherwise, proceed to step S103.
[0049] S103. Calculate the return value y=kx-b as the binarization result of the R, G, and B channels; where b = minimum emission threshold / (emission range threshold - minimum emission threshold); k = b / minimum emission threshold; x is the value of the current channel of the pixel.
[0050] In some preferred embodiments, the method for obtaining the first threshold color image includes:
[0051] S104. Multiply the binarized results of the R, G, and B channels by the original R, G, and B channel values respectively to obtain the brightness parameters r, g, and b, and convert them into brightness according to the RGB brightness conversion formula: Brightness = 0.2125 * r + 0.7154 * g + 0.0721 * b; It should be understood that the brightness in this step is the brightness after converting the RGB channels to grayscale and discarding the chroma and saturation.
[0052] S105. Using brightness as a weight, perform a weighted average of the binarized results of the R, G, and B channels and the original R, G, and B channel values to obtain the R, G, and B channels of the first threshold color image.
[0053] The first threshold color image.rgb = binarized result.rgb * (1.0 – brightness) + input image.rgb * brightness;
[0054] S106. Add the binarized results of the R, G, and B channels together and multiply them by the original Alpha channel. The normalized result is used as the Alpha channel of the threshold color.
[0055] When implementing this method using the GPU of a mobile device, a fragment shader can be used to return a four-channel thresholded color image.
[0056] It should be noted that, unless otherwise specified in this invention, the normalized data values range from [0.0, 1.0].
[0057] S2. To achieve the goal of controlling the rotation of the luminous shape, the first threshold color image is rotated to obtain a second threshold color image. There are many methods for image rotation, and details will not be elaborated here. In some preferred embodiments, an example of a method for implementing rotation processing is given, including:
[0058] The target image is subjected to matrix transformation. After translating the center point of the image to the origin, the target image is scaled down proportionally so that the diagonal length of the scaled-down image is equal to the minimum side length of the original image.
[0059] The image is then rotated and scaled down in reverse based on the input angle, and then translated back to its original position to obtain the scaled-down and rotated result image. It should be understood that the preset angle for this reverse rotation is the rotation angle used in step S4. In some preferred embodiments, this reverse rotation angle can be user-defined. The scaled-down result image is used to prevent image information loss due to rotation sampling.
[0060] The proportionally scaled-down matrix includes: ;
[0061] The rotation matrix includes: ;
[0062] Translation matrices include: ;
[0063] The matrix transformation formula is: ,in and These are the first threshold color image and the second threshold color image, respectively.
[0064] S3. The second threshold color image is subjected to three different degrees of two-dimensional Gaussian filtering to obtain three images with different degrees of blur. These images are then rotated to obtain the first, second, and third blurred images. The degree of blur can be determined by those skilled in the art based on calculation results and actual needs; this invention does not impose further requirements. The purpose of performing three blurring operations is to simulate a more realistic luminous effect. After mixing the three different degrees of blur with color filters, compared to filtering the original image with a single blur, the effect is more volumetric and luminous, and closer to the luminous effect of a real object. It should be understood that two-dimensional Gaussian blur is a commonly used technique in this field, and its specific formula is:
[0065] ;
[0066] The simplified formula is obtained after decomposition: .
[0067] There are many methods to achieve different levels of blurring using two-dimensional Gaussian filtering. In some preferred embodiments, a method is provided that controls the convolution parameters to achieve different blurring effects, specifically including:
[0068] With a fixed kernel size, the second threshold color image is convolved in both the horizontal and vertical directions. Different degrees of blur are achieved by controlling the number of iterations and the sampling distance.
[0069] In some other preferred embodiments, in order to enable users to control the degree of light emission through proportional parameters and thus control the shape of the light emission, and to more conveniently and quickly simulate the real light effects of different distances and intensities, step S3 further includes: setting user control parameters, which control the distance ratio of Gaussian blur sampling in the horizontal and vertical directions to achieve different degrees of blurring in the horizontal and vertical directions, thereby achieving the purpose of controlling and modifying the shape of the light emission.
[0070] S4. Adjust the brightness of the first, second, and third blurred images respectively, and then perform color blending on the first, second, and third blurred images and the input image using the color blending mode, before rendering them into the output image. It should be understood that the brightness in this step refers to increasing or decreasing the pixel's current RGB value by the same ratio, so as to modify the image brightness without changing the image hue.
[0071] Adjusting the brightness of the first, second, and third blurred images is to control the luminous intensity of the images. In some preferred embodiments, a method for adjusting brightness by luminous intensity is provided, specifically including:
[0072] S401. If the adjustment intensity ∈ (0.0, 1.0], then the adjustment result .rgba = 1 – power(1 – blur .rgba, intensity);
[0073] S402. If the adjustment intensity is greater than 1.0, the adjustment result .rgba = blur .rgba * power(2.0, intensity).
[0074] The adjustment intensity is a parameter that characterizes the degree of target brightness adjustment. Its default value is 0, and it can be adjusted by the user.
[0075] To simplify the calculation process, the normalized values of the adjustment results can be truncated to [0.0, 1.0].
[0076] In some other preferred embodiments, in order to modify the emission color of the original image, the method of adjusting the brightness of the first, second, and third blurred images respectively in step S4 further includes:
[0077] S403. By using the R, G, and B channel values of the adjustment result .rgba and the corresponding channel values in the first, second, and third blurred images, the emission color can be modified.
[0078] In some preferred embodiments, an example of a method for sequentially performing color filtering and mixing calculations on the first, second, and third blurred images and the input image is provided, specifically including:
[0079] The first blending result is obtained by calculating the first and second blurred images using a color filter blending mode;
[0080] The second blending result is obtained by combining the first blending result and the third blurred image using a color filter blending mode.
[0081] The second blending result and the input image are used to calculate the output image through a color filter blending mode.
[0082] Furthermore, the color filter mixing formula is as follows:
[0083] Output image = 1.0 – ((1.0 – top layer) * (1.0 – bottom layer));
[0084] The upper layer is the pre-input of the above-mentioned color filter blending calculation method, consisting of the first blurred image, the first blending result, and the second blending result, respectively; the lower layer is the post-input of the above-mentioned color filter blending calculation method, consisting of the second blurred image, the third blurred image, and the input image, respectively.
[0085] Example 2
[0086] This embodiment is based on Embodiment 1 described above. This embodiment uses the following... Figure 2 The input image shown is an example, providing an instance of the method of adding realistic physical luminescence effects to an image according to the present invention.
[0087] (1). Obtain the input video or image, see Figure 2 Enter the original image.
[0088] (2). GPU rendering pipeline, fragment shader, obtains the input color information of each pixel of each frame or image based on vertex information mapping, and the data range is normalized 0.0~1.0.
[0089] For each frame of the input video or image, the input color red, green, blue, and alpha channels are binarized with smooth transitions according to the user-controllable luminous range threshold of 0.875 and the smoothing parameter of 0.1 to obtain the threshold color. The specific steps are as follows:
[0090] (2.1). Determine if the current channel value of the pixel is less than or equal to the minimum emission threshold: if yes, return value = 0.0, continue (3.4); if no, continue (2.2);
[0091] Minimum emission threshold = 0.875 * (1.0 - 0.1) = 0.7875;
[0092] (2.2). Determine whether the current channel value of the pixel is greater than or equal to the emission range threshold. If yes, return value = 1.0 and continue (2.4); if no, continue (2.3).
[0093] (2.3). Based on the current channel value of the pixel, the emission range threshold, and the smoothing parameters, calculate the return value and continue (2.4);
[0094] The closer the current channel value is to the minimum emission threshold, the closer the return value is to 0.0; the closer it is to the emission range threshold, the closer the return value is to 1.0. The calculation formula is a linear function f(x) = kx - b, where:
[0095] b = minimum luminous threshold / (luminous range threshold - minimum luminous threshold) = 0.7875 / (0.875 - 0.7875) = 9.0;
[0096] k = b / minimum emission threshold = 9.0 / 0.7875 = 11.4286;
[0097] Return value = 11.4286 * current channel value of this pixel - 9.0;
[0098] The example results for the red, green, and blue channels are as follows: Figure 3 , Figure 4 , Figure 5 The synthesized three-channel image is Figure 6 ;
[0099] (2.4). Multiply the binarized red, green, and blue channels by the red, green, and blue channels of the input image, respectively. The resulting three-channel image is shown below. Figure 7 ;
[0100] (2.5). Convert the image after multiplication to luminance using the RGB-to-luminance formula;
[0101] The formula for converting RGB to luminance is: Luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b; Example results are as follows: Figure 8 ;
[0102] (2.6). Using brightness as the weight value, the red, green, and blue channels of the binarized result and the red, green, and blue channels of the input color are weighted and averaged to obtain the red, green, and blue channels of the threshold color:
[0103] Threshold color.rgb = Binarized result.rgb * (1.0 – Brightness) + Input color.rgb * Brightness; Example result: Figure 9 ;
[0104] (2.7). The thresholding method adds the red, green, and blue channels of the binarized result, multiplies it by the alpha channel of the input color, and truncates the result to the range [0.0, 1.0] as the alpha channel of the threshold color. An example result is shown below. Figure 10 ;
[0105] (2.8). The fragment shader returns a four-channel thresholded color image; the example result is... Figure 11 .
[0106] (3). In order to achieve the purpose of controlling the rotation of the light-emitting shape, the threshold color image matrix is transformed, the center point is translated to the origin of the coordinate system, and it is scaled down proportionally so that the diagonal length of the scaled-down image is equal to the minimum side length of the original image. After the angle is rotated in the opposite direction, it is translated back to the original position to obtain the threshold color image after rotation preprocessing.
[0107] Scaling matrix formula:
[0108] Rotation matrix formula:
[0109] Translation matrix formula:
[0110] Matrix transformation formula:
[0111] The example input image has a width of 780px and a height of 488px. After normalization, the aspect ratio is 1.5983, the center point coordinates are (0.7992, 0.5), and the translation matrix is:
[0112]
[0113] The diagonal length is 920px, the scaling factor is 488 / 920 = 0.5304, and the scaling matrix is:
[0114]
[0115] When the input rotation angle is 30 degrees, the rotation matrix is:
[0116]
[0117] The example result is Figure 12 .
[0118] (4). The pre-processed threshold color image is subjected to three Gaussian filters with different degrees of blur to obtain three four-channel blurred images with small blur, medium blur and large blur respectively; and the user can control the shape of the light emission through the scaling parameter;
[0119] This method employs the GPU-based fast Gaussian filtering method: the two-dimensional Gaussian filtering algorithm uses a fixed convolution kernel size to perform convolutions in both the horizontal and vertical directions. By controlling the number of iterations and the sampling distance, the degree of blurring is controlled. The principle formula is as follows:
[0120] Two-dimensional Gaussian blur formula ;
[0121] Simplified formula after decomposition ;
[0122] In the example, the Gaussian kernel diameter is 5, and the weights are 0.0545, 0.2442, 0.4026, 0.2442, and 0.0545, respectively.
[0123] (4.2). User-controlled scaling parameters control the sampling distance ratio in the horizontal and vertical directions of Gaussian blur, achieving different degrees of blurring in the horizontal and vertical directions, thereby achieving the purpose of controlling and modifying the shape of the emitted light;
[0124] In the example, when the number of iterations is 8 and the default sampling distance in both the horizontal and vertical directions is 1.0, the result is: Figure 13 ;
[0125] When the horizontal sampling distance is 2.0 and the vertical sampling distance is 0.0, the result is: Figure 14 ;
[0126] When the horizontal sampling distance is 0.0 and the vertical sampling distance is 2.0, the result is: Figure 15 ;
[0127] In the example, when the default sampling distance in both the horizontal and vertical directions is 1.0, the number of iterations is 1, 5, and 8, respectively, resulting in different fuzzy areas. Figure 16 In the blur Figure 17 , blurry Figure 18 .
[0128] (5). In order to control the rotation of the luminous shape, the blurred image matrix is transformed, the center point is translated to the origin of the coordinate system, the image is enlarged proportionally back to the input image size, the input angle is rotated in the positive direction, and then translated back to the original position, so that the luminous shape can rotate, and three blurred images of small, medium and large blurred images are obtained after rotation.
[0129]
[0130] In the example, Figure 14 The glowing shape is used as an effect; the effect of rotating the glowing shape is shown separately, and the result is... Figure 19 .
[0131] (6) Adjust the brightness of the three blurred images (small, medium, and large blur) after rotation respectively to control the luminous intensity, with the intensity range greater than 0.0;
[0132] (6.1). If the intensity ∈ (0.0, 1.0], adjust the result .rgba = 1 – power(1 – blur .rgba, intensity);
[0133] (6.2). If the intensity is greater than 1.0, adjust the result.rgba = blur.rgba * power(2.0, intensity);
[0134] (6.3). Adjust the result value to be truncated to [0.0, 1.0].
[0135] In the example, the fuzzy small Figure 16 The intensity was adjusted to 1.0, and the result was... Figure 20 ;
[0136] In the blur Figure 17 The intensity was adjusted to 0.5, and the result was... Figure 21 ;
[0137] Blurry Figure 18 The intensity was adjusted to 1.8, and the result was... Figure 22 ;
[0138] (6.4). The red, green and blue channel values of the corresponding color of a pixel can be replaced to modify the color of the emitted light.
[0139] (7). Calculate the blur levels (small, medium, large) and blur intensity of the input image after brightness adjustment in sequence from front to back according to the color filter blending mode, and render them into the output image result.
[0140] Color blending formula: Result image = 1.0 – ((1.0 – top layer) * (1.0 – bottom layer)).
[0141] In the example, using the original image's emission color, the result is: Figure 23 ;
[0142] In the example, in step (6.4), the RGB value of the emitted color is modified to (0.06, 0.0, 1.0), and the result is... Figure 24 .
[0143] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.
Claims
1. A method for adding realistic physical luminescence effects to an image, characterized in that, include: S1. Obtain the input image, normalize the pixel color parameters to 0.0~1.0, and perform binarization calculations with smooth transition on the R, G, B, and Alpha channels of the input image according to the emission range threshold and smoothing parameters to obtain the first threshold color image. S2. Rotate the first threshold color image to obtain the second threshold color image; S3. Perform three two-dimensional Gaussian filters with different degrees of blur on the second threshold color image to obtain three images with different degrees of blur. Then, perform rotation processing on each image to obtain the first, second, and third blurred images. S4. Adjust the brightness of the first, second, and third blurred images respectively, and then perform color blending on the first, second, and third blurred images and the input image through the color blending mode, and render them into the output image.
2. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, The method for performing binarization calculation with smooth transition based on the emission range threshold and smoothing parameters in step S1 includes: S101. Determine whether the value of the current channel of the pixel is less than or equal to the minimum emission threshold. If yes, return value = 0.0; if no, proceed to step S102. Wherein, the minimum emission threshold = emission range threshold * (1.0 - smoothing parameter), emission range threshold ∈ [0.0, 1.0] and smoothing parameter ∈ (0.0, 1.0). S102. Determine whether the value of the current channel of the pixel is greater than or equal to the light emission range threshold. If yes, return value = 1.0; otherwise, proceed to step S103. S103. Calculate the return value y=kx-b as the binarization result of the R, G, and B channels; where b = minimum emission threshold / (emission range threshold - minimum emission threshold); k = b / minimum emission threshold; x is the value of the current channel of the pixel.
3. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, The method for obtaining the first threshold color image in step S1 includes: S104. Multiply the binarized results of the R, G, and B channels by the original R, G, and B channel values respectively to obtain the luminance parameters r, g, and b, and convert them into luminance according to the RGB luminance conversion formula: luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b; S105. Using brightness as a weight, perform a weighted average of the binarized results of the R, G, and B channels and the original R, G, and B channel values to obtain the R, G, and B channels of the first threshold color image. The first threshold color image.rgb = binarized result.rgb * (1.0 – brightness) + input image.rgb * brightness; S106. Add the binarized results of the R, G, and B channels together and multiply them by the original Alpha channel. The normalized result is used as the Alpha channel of the threshold color.
4. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, The rotation processing method is as follows: The target image is subjected to matrix transformation. After translating the center point of the image to the origin, the target image is scaled down proportionally so that the diagonal length of the scaled-down image is equal to the minimum side length of the original image. The image is rotated and shrunk in reverse according to the input angle, and then translated back to the original position to obtain the shrunk and rotated result image.
5. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, Step S3 further includes: setting user control parameters, which control the sampling distance ratio in the horizontal and vertical directions of Gaussian blur to achieve different degrees of blurring in the horizontal and vertical directions, thereby achieving the purpose of controlling and modifying the shape of the light emission.
6. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, The method for adjusting the brightness of the first, second, and third blurred images respectively in step S4 includes: S401. If the adjustment intensity ∈ (0.0, 1.0], then the adjustment result .rgba = 1 – power(1 – blur .rgba, intensity); S402. If the adjustment intensity is greater than 1.0, the adjustment result .rgba = blur .rgba * power(2.0, intensity).
7. The method for adding realistic physical luminescence effects to an image as described in claim 5, characterized in that, The method for adjusting the brightness of the first, second, and third blurred images respectively, as described in step S4, further includes: S403. By using the R, G, and B channel values of the adjustment result .rgba and the corresponding channel values in the first, second, and third blurred images, the emission color can be modified.
8. The method for adding realistic physical luminescence effects to an image as described in claim 1, characterized in that, Step S4, which describes the method of calculating and performing color blending of the first, second, and third blurred images and the input image using different color blending modes, includes: The first blending result is obtained by calculating the first and second blurred images using a color filter blending mode; The second blending result is obtained by combining the first blending result and the third blurred image using a color filter blending mode. The second blending result and the input image are used to calculate the output image through a color filter blending mode.
9. The method for adding realistic physical luminescence effects to an image as described in claim 1 or 3, characterized in that, Step S3 involves performing two-dimensional Gaussian filtering, which includes: With a fixed kernel size, horizontal and vertical convolutions are performed on the second threshold color image, and different degrees of blur are achieved by controlling the number of iterations and the sampling distance.
Citation Information
Patent Citations
Image rendering method, related device, equipment and storage medium
CN112051995A
Image processing method and device and electronic equipment
CN114363519A