Image rendering method, device, electronic device and storage medium
Through multiple sampling and superposition processing of noisy images, random flashing rendered images are generated, which solves the problem of low rendering efficiency in the prior art, realizes real-time rendering effect, simplifies the processing flow and reduces memory footprint.
Patent Information
- Application Number
- CN202111482231.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-12-06
AI Technical Summary
In the prior art, the rendering efficiency of the star flash map is low, making it difficult to achieve real-time rendering effect. It is mainly because the CPU needs to read pixels one by one, calculate highlight corner points, and adjust random light and dark values, which makes the calculation time longer.
By acquiring different kinds of noise images for multiple sampling, generating sub-images, and superimposing them with brightness data and other noise images, a random flashing rendered image is generated, reducing the direct processing requirement for pixels and using GPU for Process for efficiency.
It greatly improves the calculation rate of image rendering, realizes real-time rendering effect, saves CPU and GPU processing time, and does not require pixel comparison operations, simplifies memory usage.
Smart Images

Figure CN114155311B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image rendering technology, and in particular to an image rendering method, device, electronic device and storage medium. Background Art
[0002] The star flash image is a flashing effect image of the highlight area in the image (such as the highlight points on the stars or crystals). It is widely used in the field of games and videos for screen special effects, embellishing the task or landscape screen, and highlighting the shining effect of the highlight area. In the related technology, the star flash image is obtained by the following rendering technology. The CPU (Central Processing Unit) is used to read the pixels of the image to be rendered one by one, calculate the highlight corner points in the image to be rendered, obtain the star pattern, and place the star pattern on the above-mentioned highlight corner points. The pattern obtained at this time is a static pattern, and further a random algorithm is used to calculate a randomly changing and flashing light and dark value for each highlight corner point. The processed image is sent to the GPU (Graphics Processing Unit) for rendering. In the above process, reading pixels, calculating highlight corner points, setting light and dark values, and sending the processed image all require a lot of CPU time, which is difficult to meet the needs of real-time rendering technology in reality.
[0003] Therefore, there is an urgent need for an image rendering method to improve the efficiency of image rendering and achieve real-time image rendering effects. Summary of the invention
[0004] The present disclosure provides an image rendering method, device, electronic device and storage medium to at least solve the problem of low image rendering efficiency in related technologies. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, an image rendering method includes:
[0006] Acquire brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types;
[0007] Along a preset direction of the first noise image, the starting sampling position is offset by a preset distance each time, and the first noise image is sampled multiple times to obtain multiple sub-images;
[0008] Each sub-image of the multiple sub-images is sequentially superimposed with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
[0009] In a possible implementation, acquiring brightness data of an image includes:
[0010] Respectively obtain first brightness data of the image in the first color space and second brightness data of the image in the second color space;
[0011] A weighted sum is performed on the first brightness data and the second brightness data to obtain brightness data of the image.
[0012] In a possible implementation manner, performing weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image includes:
[0013] adjusting the first brightness data according to the first contrast coefficient, and adjusting the second brightness data according to the second contrast coefficient;
[0014] The adjusted first brightness data and the adjusted second brightness data are weightedly summed to obtain brightness data of the image.
[0015] In a possible implementation manner, a method for acquiring the first noise image and the second noise image includes:
[0016] Acquire a first original image of a first noise and a second original image of a second noise;
[0017] The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
[0018] In a possible implementation, the first noise image is sampled multiple times along a preset direction of the first noise image, with the starting sampling position offset by a preset distance each time, to obtain multiple sub-images, including:
[0019] Obtaining a starting sampling position of a previous sampling period, shifting a preset distance along a preset direction of the first noise image, to obtain a starting sampling position of a current sampling period;
[0020] Starting from the starting sampling position of the current sampling period, sampling the data after the starting sampling position of the first noise image;
[0021] When the sampling result does not meet the preset size of the sub-image, the first noise image is sampled from a preset position of the first noise image until the number of the sub-images reaches a preset value, wherein the number of the sub-images corresponds to the number of sampling time periods.
[0022] In a possible implementation, sequentially superimposing each sub-image of the multiple sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image includes:
[0023] sequentially superimposing each of the plurality of sub-images with the second noise image to obtain a plurality of initial starburst images;
[0024] Performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction;
[0025] The starburst pattern, the brightness data and the image are superimposed to obtain a rendered image of the image.
[0026] In a possible implementation manner, the first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
[0027] According to a second aspect of an embodiment of the present disclosure, there is provided an image rendering device, including:
[0028] An acquisition module, used for acquiring brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types;
[0029] A sampling module, configured to sample the first noise image multiple times by shifting a starting sampling position by a preset distance each time along a preset direction of the first noise image to obtain multiple sub-images;
[0030] A generating module is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
[0031] In a possible implementation, the acquisition module includes:
[0032] A first acquisition submodule, used to respectively acquire first brightness data of an image in a first color space and second brightness data of an image in a second color space;
[0033] The first processing submodule is used to perform weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image.
[0034] In a possible implementation, the processing submodule includes:
[0035] an adjusting unit, configured to adjust the first brightness data according to the first contrast coefficient, and to adjust the second brightness data according to the second contrast coefficient;
[0036] The processing unit is used to perform weighted summation on the adjusted first brightness data and the adjusted second brightness data to obtain brightness data of the image.
[0037] In a possible implementation manner, a method for acquiring the first noise image and the second noise image includes:
[0038] Acquire a first original image of a first noise and a second original image of a second noise;
[0039] The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
[0040] In a possible implementation, the sampling module includes:
[0041] A second acquisition submodule is used to acquire the starting sampling position of the previous sampling period, and to shift the first noise image by a preset distance along a preset direction to obtain the starting sampling position of the current sampling period;
[0042] A first sampling submodule, configured to sample data after the starting sampling position of the first noise image starting from the starting sampling position of the current sampling period;
[0043] The second sampling submodule is used to sample the first noise image from a preset position of the first noise image when the sampling result does not meet the preset size of the sub-image, until the number of the sub-images reaches a preset value, wherein the number of the sub-images corresponds to the number of sampling time periods.
[0044] In a possible implementation, the generating module includes:
[0045] A second processing submodule is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image to obtain multiple initial starburst images;
[0046] A convolution submodule, used for performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction;
[0047] A generation submodule is used to superimpose the starburst pattern, the brightness data and the image to obtain a rendered image of the image.
[0048] In a possible implementation manner, the first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
[0049] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0050] processor;
[0051] a memory for storing instructions executable by the processor;
[0052] The processor is configured to execute the instructions to implement the image rendering method described in any one of the embodiments of the present disclosure.
[0053] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image rendering method described in any one of the embodiments of the present disclosure.
[0054] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, wherein the computer program product includes instructions, and when the instructions are executed by a processor of an electronic device, the electronic device is enabled to perform the image rendering method as described in any one of the embodiments of the present disclosure.
[0055] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: In the embodiments of the present disclosure, multiple sampling is performed by offsetting the starting sampling position of the first noise image by a preset distance each time, thereby obtaining multiple sub-images. The sampled sub-image is superimposed with the second noise image, and further superimposed with the brightness data of the image, so as to obtain a rendered image in which the highlight area of the image flashes randomly. Compared with the traditional rendering method, the embodiments of the present disclosure do not need to read each pixel of the image one by one, calculate the highlight corner point, and place each starburst pattern on the highlight corner point. Therefore, the calculation rate is greatly increased. Since the present solution does not involve pixel comparison operations, the above method can be executed with the help of a GPU processor. Due to the hardware framework design of the GPU, the method running time is greatly saved, and a real-time rendering effect is achieved.
[0056] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0058] Figure 1 The figure is a flowchart of an image rendering method according to an exemplary embodiment.
[0059] Figure 2 The figure is a flowchart of an image rendering method according to an exemplary embodiment.
[0060] Figure 3 is a sampling flowchart of a first noise image according to an exemplary embodiment.
[0061] Figure 4 is a schematic diagram of a convolution kernel of a starburst pattern according to an exemplary embodiment.
[0062] Figure 5 The invention is a block diagram of an image rendering device according to an exemplary embodiment.
[0063] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment.
[0064] Figure 7 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0065] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0066] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0067] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0068] In order to facilitate those skilled in the art to understand the technical solution provided by the embodiments of the present disclosure, the technical environment in which the technical solution is implemented is described below.
[0069] In the related art, in the process of generating a starburst image, the CPU reads the pixels to be rendered one by one, which is time-consuming. The highlight corners in the rendered image are calculated, and the storage of the highlight corners requires a memory space proportional to the size of the screen resolution. Then each starburst pattern is placed at the coordinate point for rendering. The rendering drawcall instruction is called, and the call of this instruction will occupy a high bandwidth. At this time, only a static starburst pattern is obtained, and a random algorithm is still required to calculate a randomly changing light and dark value for each highlight corner point. This operation is further time-consuming and occupies more memory space. When the data is only sent to the GPU for rendering, it further occupies bandwidth. Another related technology is to pre-produce an animated video with a starburst effect. In order to ensure clarity and loop length, it is usually multiple pictures and large. Reading these video files from the disk is a slow process. The CPU decodes this data and generates renderable RGB data, which also takes a certain amount of time and occupies a large amount of memory. The final rendered data is also relatively fixed, with almost no adjustable parameters, and the density and flashing speed of the starburst pattern cannot be adjusted in real time. If modification is required, the animation file needs to be remade and imported from scratch. The overall process is time-consuming and occupies a large memory space.
[0070] Figure 1 is a flowchart of an image rendering method according to an exemplary embodiment. Figure 1 As shown. Perform color coding conversion on image 100, and convert the RGB format pattern into YUV format and LUV format. Extract the brightness component of the data in the two formats to obtain brightness data. Perform contrast calibration on Gaussian noise image 102 and Perlin noise image 101, and amplify the brightness data, mix the amplified Perlin noise image and Gaussian noise image, so that the peaks, troughs and other brightness values of the two noise brightness are sometimes in the same phase and sometimes in different phases. After the two images are mixed, spots are formed to obtain a spot pattern 107. Multiple spot patterns 107 form randomly flickering spots because the positions of the spots will change. Perform convolution sampling on the spot pattern 107, and pull the brighter data out of the corners in the diagonal direction to obtain a starburst pattern. Mix the starburst pattern and brightness data 103, and superimpose them with image 100 to obtain a rendered image 104.
[0071] Figure 2 The figure is a flowchart of an image rendering method according to an exemplary embodiment. Figure 3 FIG. 1 is a sampling flow chart of a first noise image according to an exemplary embodiment. Figure 2 As shown, the method is applied to a terminal or a server, comprising:
[0072] Step S101 : acquiring brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types.
[0073] In the embodiment of the present disclosure, the brightness of the image refers to the brightness of the image. For example, the grayscale value of the image is between [0, 255]. The closer the grayscale value is to 0, the lower the brightness is, and the closer the grayscale value is to 255, the higher the brightness is. In the embodiment of the present disclosure, the first noise image and the second noise image belong to different types of noise images. The noise image may include a Gaussian noise image, a Perlin noise image, a Poisson noise image, a salt and pepper noise image, a Rayleigh noise image, a gamma noise image, and a uniform noise image.
[0074] Step S103 : along a preset direction of the first noise image, the starting sampling position is shifted by a preset distance each time, and the first noise image is sampled multiple times to obtain multiple sub-images.
[0075] In the embodiment of the present disclosure, the preset direction of the first noise image may include along the horizontal direction of the first noise image, along the vertical direction of the first noise image, or along the diagonal direction of the first noise image. Figure 3 For example, along the positive direction of the Y-axis direction of the first noise image, for example, the starting sampling position of the previous sampling period is the position of the first row, then the starting sampling position of the current sampling period can be offset by a preset distance, for example, the position of the second row. Starting from the second row, the first noise image can be sampled row by row to obtain a first sub-image that meets the preset size requirement. Starting from the next sampling period, the starting sampling position is offset by the same preset distance in the positive direction of the Y-axis, for example, starting from the third row position, the first noise image is sampled to obtain the second sub-image, and so on, to obtain a preset number of sub-images.
[0076] Step S105 , sequentially superimposing each sub-image of the multiple sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
[0077] In the embodiments of the present disclosure, reference Figure 3As described above, the first sub-image can be superimposed with the second noise image, and then superimposed with the brightness data of the image. The superimposition process includes multiplying the pixels in the sub-image with the pixels at the same position (phase) in the second noise image. Since the brightness value of the pixel in the first sub-image is different from the brightness value of the pixel at the same position in the second noise image, when the two brightness values are small, such as 0.2 and 0.3, after multiplication, the brightness value becomes smaller and appears as a dark area. When the two brightness values are large, after multiplication, the brightness value becomes larger and appears as a bright area. Therefore, after the superimposition process of the sub-image and the second noise image, a discrete speckle pattern 107 can be obtained. Since the pixel brightness values at the same position of the first sub-image and the second sub-image are different, the image obtained by superimposing the first sub-image and the second noise image is also different from the image obtained by superimposing the second sub-image and the second noise image. The flashing image is superimposed with the brightness data of the image. Based on the same principle, a spot pattern can be obtained that only appears in the highlight area of the image. Multiple superimposed spot images form a flashing rendering image in time. In an example, the flashing speed of the spot pattern can be achieved by setting the number of sub-images in a unit time.
[0078] In the embodiment of the present disclosure, during the process of superimposition processing, if the size of the sub-image, the size of the second noise image and the size of the image do not match, the second noise image can be tiled, and the sub-image can be tiled in the same way, so that the size of the sub-image, the second noise image and the image are consistent. In one example, the density of spots after the second noise image and the sub-image are superimposed can be adjusted by setting the number of tiles of the second noise image. The more tiles within the same size, the denser the spots; the fewer tiles, the sparser the spots.
[0079] In the disclosed embodiment, multiple sampling is performed by offsetting the starting sampling position of the first noise image by a preset distance each time, thereby obtaining multiple sub-images. The sampled sub-image is superimposed with the second noise image, and further superimposed with the brightness data of the image, so as to obtain a rendered image in which the highlight area of the image flashes randomly. Compared with the traditional rendering method, the disclosed embodiment does not need to read each pixel of the image one by one, calculate the highlight corner point, place each star pattern on the highlight corner point, and so on. Therefore, the calculation rate is greatly increased. Since the present solution does not involve pixel comparison operations, the above method can be executed with the help of a GPU processor. Due to the hardware framework design of the GPU, the method running time is greatly saved, and a real-time rendering effect is achieved.
[0080] In a possible implementation, acquiring brightness data of an image includes:
[0081] Respectively obtain first brightness data of the image in the first color space and second brightness data of the image in the second color space;
[0082] A weighted sum is performed on the first brightness data and the second brightness data to obtain brightness data of the image.
[0083] In the embodiments of the present disclosure, a color space is a mathematical representation of a color set, and the color space may include an RGB color space, which is used in computer graphics; YIQ, YUV or YCbCr, which are used in video systems; CMYK, which is used in color printing; and LUV color space, etc. In one example, for example, if an image is an RGB color signal, the image is YUV-encoded by formula (1), and the Y (brightness) channel thereof is calculated to obtain brightness data under the color space.
[0084] Y=0.299×R+0.587×G+0.114×B (1)
[0085] In one example, the RGB color signal of the image is converted into LUV code using equations (2) and (3), and the L (brightness) channel is calculated to obtain the brightness data in the color space.
[0086] Y1=0.212671×R+0.715160×G+0.072169×B (2)
[0087]
[0088] In one example, the first brightness data and the second brightness data can be mixed using formula (4), where M is a mixing coefficient, and the value determines the mixing ratio of Y and L. out is the result of mixing. P1 is the contrast coefficient of the Y signal, and P2 is the contrast coefficient of the L signal. The larger the value, the higher the contrast. In practical applications, the contrast coefficient and the mixing coefficient can be calibrated according to different types of image content and different shooting equipment to extract the target area (such as the area with higher brightness value).
[0089] Y out =Y p1 ×M+L p2 ×(1-M) (4)
[0090] The embodiments of the present disclosure take into account that different color spaces have different chromaticities corresponding to points with higher brightness, for example, in the YUV color space, the pixels corresponding to brighter red and yellow are brighter, and in the LUV color space, the pixels corresponding to brighter blue and green are brighter. The brightness data of different color spaces are weighted and summed, which improves the generalization ability of the method. This enables the present disclosure to process images with different color saturations well.
[0091] In a possible implementation manner, performing weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image includes:
[0092] adjusting the first brightness data according to the first contrast coefficient, and adjusting the second brightness data according to the second contrast coefficient;
[0093] The adjusted first brightness data and the adjusted second brightness data are weightedly summed to obtain brightness data of the image.
[0094] In the disclosed embodiment, before weighted summing the brightness data, the contrast of the first brightness data and the contrast of the second brightness data are increased respectively. For example, the values of P1 and P2 in formula (4) are increased. Increasing the contrast of the image brightness data makes the values with greater brightness become larger and the values with less brightness become smaller, so that the distinction between the highlight area and the low brightness area is more obvious, which is conducive to extracting a more accurate highlight area.
[0095] In a possible implementation manner, a method for acquiring the first noise image and the second noise image includes:
[0096] Acquire a first original image of a first noise and a second original image of a second noise;
[0097] The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
[0098] In the disclosed embodiment, the contrast of the first original image and the second original image is amplified. In one example, the frequency and amplitude of the two are adjusted to be close, that is, the bright distribution density and size of the noise image are close, so as to facilitate the phase alignment when the first noise image is mixed with the second noise image. In one example, increasing the contrast of the first original image and the second original image can improve the sensitivity of the noise image and highlight the peak white part. In one example, the contrast of the first original image and the second original image is amplified and the pixel value is amplified respectively by formula (5). Wherein N is the input original image, P is the contrast coefficient, X is the signal amplification coefficient, and P out For output results, for example, input the first original image, P out Then it is the first noise image; input the second original image, P out The contrast coefficient and signal amplification coefficient of the first original image and the second original image may be different.
[0099] P out =N P ×X (5)
[0100] In the disclosed embodiment, by adjusting the contrast of the original image, the number of starbursts in the starburst pattern can be controlled. By adjusting the pixel value of the original image, the brightness of the starbursts in the starburst pattern can be controlled. Adjusting the contrast first and then amplifying the signal can avoid small high-frequency useless noise from being amplified to generate interference.
[0101] In a possible implementation, the first noise image is sampled multiple times along a preset direction of the first noise image, with the starting sampling position offset by a preset distance each time, to obtain multiple sub-images, including:
[0102] Obtaining a starting sampling position of a previous sampling period, shifting a preset distance along a preset direction of the first noise image, to obtain a starting sampling position of a current sampling period;
[0103] Starting from the starting sampling position of the current sampling period, sampling the data after the starting sampling position of the first noise image;
[0104] When the sampling result does not meet the preset size of the sub-image, the first noise image is sampled from a preset position of the first noise image until the number of the sub-images reaches a preset value, wherein the number of the sub-images corresponds to the number of sampling time periods.
[0105] In the embodiments of the present disclosure, reference Figure 3 As shown, for example, the actual sampling position of the previous sampling period is the first row position of the first noise image, and is offset by one row along the preset direction, such as the positive direction of the Y axis. Sampling is performed from the second row position of the first noise image. When sampling reaches the 19th row position of the first noise image, the size of the obtained sub-image does not match the size of the preset image, and then the preset position (for example, the first row position) of the first noise image is returned for sampling to obtain the first sub-image. Similarly, when sampling is offset by one row along the positive direction of the Y axis, sampling is performed from the third row position of the first noise image. When sampling reaches the 19th row position of the first noise image, the size of the obtained sub-image does not match the size of the preset image, and then the preset position of the first noise image is returned for sampling to obtain the second sub-image. And so on, when the number of sub-images meets the preset value, the sampling is completed.
[0106] In the disclosed embodiment, the starting sampling position of the first noise image is offset by a preset distance each time, and when the size of the sampled sub-image does not meet the preset requirement, the sampling is returned to the preset position of the first noise image. Sub-images of the same size can be obtained. In the disclosed embodiment, the brightness value of each pixel in each sub-image changes in the previous and next frames, so that when mixed with the second noise image, spots with alternating light and dark can be generated.
[0107] Figure 4 FIG. 1 is a schematic diagram of a convolution kernel of a starburst pattern according to an exemplary embodiment. Figure 4 As shown, the method of sequentially superimposing each sub-image of the plurality of sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image includes:
[0108] sequentially superimposing each of the plurality of sub-images with the second noise image to obtain a plurality of initial starburst images;
[0109] Performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction;
[0110] The starburst pattern, the brightness data and the image are superimposed to obtain a rendered image of the image.
[0111] In the embodiment of the present disclosure, each of the plurality of sub-images is sequentially superimposed with the second noise image to obtain a plurality of initial starburst images. The initial starburst pattern can refer to Figure 1 The speckled pattern in the image is a picture of a dotted line, where the bright spots are scattered pixels. Figure 5 As shown, the initial starburst pattern is subjected to convolution sampling processing by equation (6), wherein g is the input image data, h is the convolution kernel, and k is the convolution kernel step size.
[0112]
[0113] In the disclosed embodiment, the weights of the convolution kernel 401 decrease from the center to the diagonal direction, that is, Weight1>Weight2>Weight3. As a result, the center of the starburst pattern 402 is brighter, and the pixels toward the four diagonals are stretched and darkened. In one example, the weights of the convolution kernel 401 can be adjusted dynamically, corresponding to the brightness of the center to the periphery pixels. The higher the center weight, the brighter the center, and vice versa, the higher the surrounding weights, the brighter the surroundings. Figure 4 A 5×5 convolution kernel is shown. According to the actual effect requirements, the convolution kernel can be adjusted to a 3×3 convolution kernel, or increased to a 7×7 convolution kernel to meet the clarity and operating efficiency at different resolutions. Reducing the size can reduce the number of calculations and improve operating efficiency. Increasing the size can increase the number of calculations, and the output effect leads to higher clarity of the sharp corner details of the starburst pattern. At the same time, the step size k of the convolution kernel can be adjusted. The larger the value, the greater the distance the four sharp corners are stretched outward, and the longer the sharp corners are formed.
[0114] In the disclosed embodiment, the obtained starburst pattern is mixed with the image to obtain a final starburst effect in the highlight area of the image. When the calculated starburst effect is a grayscale value, it can be restored to the RGB color space by dyeing it. Then a specific mixing mode is selected to perform mixing calculation with the image. The specific formula is as follows:
[0115] F=Bliend(I,G out ×Color) (7)
[0116] Where I is the original image data, Gout is the star data from the previous step, Color is the color value in the selected RGB space, and different color values can make the star appear in different colors. Blend is the selected blending mode, and different blending modes can affect the brightness and color tendency of the star, so that the final fusion of the star and the image can be different, achieving different artistic effects.
[0117] In the disclosed embodiment, a convolution sampling process is performed on an initial starburst image through a convolution kernel to obtain a starburst pattern. By further adjusting the weight and size of the convolution kernel, starburst patterns of different shapes can be obtained, thereby facilitating the adjustment of the pattern.
[0118] In a possible implementation manner, the first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
[0119] In the embodiment of the present disclosure, the first noise image includes a Perlin noise image. The Perlin noise image smoothly increases and then decreases within a specific interval. Figure 3 , the brightness values of adjacent pixels in the Y-axis direction of the first noise image increase or decrease smoothly. Therefore, when the first noise image is offset sampled, the brightness value of the obtained sub-image at the same pixel point increases or decreases uniformly. For example Figure 3 The first pixel value of the first sub-image and the second pixel value of the second sub-image. Therefore, when the sub-images are superimposed, the brightness value of each pixel is evenly brightened or darkened. The distribution characteristic of the second noise image, the Gaussian noise image, is a normal distribution. Therefore, the points with larger brightness values are also evenly distributed in the image. Figure 1 Gaussian image 102. This characteristic of the Gaussian image makes it the basis of the starburst pattern, which is close to the shape of stars in the starry sky.
[0120] In the disclosed embodiment, using a Gaussian image as the second noise image helps to evenly distribute the starburst pattern, and using Perlin noise as the first noise image helps to evenly change the brightness of the rendered image between previous and next frames, thereby improving the rendering effect.
[0121] The calculation process of the disclosed embodiment does not involve reading the image pixel data and sending it from the GPU to the CPU, so no additional transmission bandwidth is required, and no additional calculation and memory consumption is required on the CPU side. The effect of the disclosed embodiment is generated by programming, and the density, brightness, spot size, flashing speed, color, etc. of the final effect are all controlled by corresponding parameters, which is very easy to adjust and can preview the effect in real time. Non-technical personnel can also easily create a variety of effects.
[0122] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0123] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can refer to each other, and each embodiment focuses on the differences from other embodiments. For related points, please refer to the description of other method embodiments.
[0124] Figure 5 is a block diagram of an image rendering device according to an exemplary embodiment. Figure 5 ,include:
[0125] An acquisition module 501 is used to acquire brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types;
[0126] A sampling module 502 is used to sample the first noise image multiple times along a preset direction of the first noise image, shifting a starting sampling position by a preset distance each time, and obtaining multiple sub-images;
[0127] The generating module 503 is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
[0128] In a possible implementation, the acquisition module includes:
[0129] A first acquisition submodule, used to respectively acquire first brightness data of an image in a first color space and second brightness data of an image in a second color space;
[0130] The first processing submodule is used to perform weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image.
[0131] In a possible implementation, the processing submodule includes:
[0132] an adjusting unit, configured to adjust the first brightness data according to the first contrast coefficient, and to adjust the second brightness data according to the second contrast coefficient;
[0133] The processing unit is used to perform weighted summation on the adjusted first brightness data and the adjusted second brightness data to obtain brightness data of the image.
[0134] In a possible implementation manner, a method for acquiring the first noise image and the second noise image includes:
[0135] Acquire a first original image of a first noise and a second original image of a second noise;
[0136] The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
[0137] In a possible implementation, the sampling module includes:
[0138] A second acquisition submodule is used to acquire the starting sampling position of the previous sampling period, and to shift the first noise image by a preset distance along a preset direction to obtain the starting sampling position of the current sampling period;
[0139] A first sampling submodule, configured to sample data after the starting sampling position of the first noise image starting from the starting sampling position of the current sampling period;
[0140] The second sampling submodule is used to sample the first noise image from a preset position of the first noise image when the sampling result does not meet the preset size of the sub-image, until the number of the sub-images reaches a preset value, wherein the number of the sub-images corresponds to the number of sampling time periods.
[0141] In a possible implementation, the generating module includes:
[0142] A second processing submodule is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image to obtain multiple initial starburst images;
[0143] A convolution submodule, used for performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction;
[0144] A generation submodule is used to superimpose the starburst pattern, the brightness data and the image to obtain a rendered image of the image.
[0145] In a possible implementation manner, the first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
[0146] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0147] Figure 6 1 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0148] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0149] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0150] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, optical disk, or graphene memory.
[0151] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0152] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0153] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting an audio signal.
[0154] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0155] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or the electronic device 600 component, the presence or absence of contact between the user and the electronic device 600, the device 600 orientation or acceleration / deceleration and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0156] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0157] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0158] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by the processor 620 of the electronic device 600 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0159] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions. The instructions can be executed by the processor 620 of the electronic device 600 to complete the above method.
[0160] Figure 7 7 is a block diagram of a server 700 according to an exemplary embodiment. For example, the server 700 may be a server. Figure 7 The server 700 includes a processing component 720, which further includes one or more processors, and a memory resource represented by a memory 722 for storing instructions, such as applications, that can be executed by the processing component 720. The application stored in the memory 722 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 720 is configured to execute instructions to perform the above method.
[0161] The server 700 may also include a power supply component 724 configured to perform power management of the server 700, a wired or wireless network interface 726 configured to connect the server 700 to a network, and an input / output (I / O) interface 728. The server 700 may operate based on an operating system stored in the memory 722, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0162] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 722 including instructions, and the above instructions can be executed by a processor of the server 700 to complete the above method. The storage medium can be a computer-readable storage medium, for example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0163] In an exemplary embodiment, a computer program product is also provided. The computer program product includes instructions, and the instructions can be executed by a processor of the server 700 to implement the above method.
[0164] It should be noted that the above-mentioned devices, electronic devices, computer-readable storage media, computer program products, etc. may also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments, which will not be described one by one here.
[0165] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0166] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image rendering method, characterized in that: include: Acquire brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types; Along a preset direction of the first noise image, the starting sampling position is offset by a preset distance each time, and the first noise image is sampled multiple times to obtain multiple sub-images; The method of sampling the first noise image multiple times by shifting the starting sampling position by a preset distance each time along the preset direction of the first noise image to obtain multiple sub-images includes: obtaining the starting sampling position of the previous sampling period, shifting the starting sampling position of the current sampling period by a preset distance along the preset direction of the first noise image; sampling the data after the starting sampling position of the first noise image starting from the starting sampling position of the current sampling period; and sampling the first noise image starting from the preset position of the first noise image until the number of the sub-images reaches a preset value when the sampling result does not meet the preset size of the sub-image. Each sub-image of the multiple sub-images is sequentially superimposed with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
2. The method according to claim 1, characterized in that The step of acquiring brightness data of an image comprises: Respectively obtain first brightness data of the image in the first color space and second brightness data of the image in the second color space; A weighted sum is performed on the first brightness data and the second brightness data to obtain brightness data of the image.
3. The method according to claim 2, characterized in that The step of performing weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image includes: adjusting the first brightness data according to the first contrast coefficient, and adjusting the second brightness data according to the second contrast coefficient; The adjusted first brightness data and the adjusted second brightness data are weightedly summed to obtain brightness data of the image.
4. The method according to claim 1, characterized in that: The method for acquiring the first noise image and the second noise image includes: Acquire a first original image of a first noise and a second original image of a second noise; The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
5. The method according to claim 1, characterized in that The number of the sub-images corresponds to the number of sampling periods.
6. The method according to claim 1, characterized in that The step of sequentially superimposing each of the plurality of sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image includes: sequentially superimposing each of the plurality of sub-images with the second noise image to obtain a plurality of initial starburst images; Performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction; The starburst pattern, the brightness data and the image are superimposed to obtain a rendered image of the image.
7. The method according to any one of claims 1 to 6, characterized in that The first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
8. An image rendering device, characterized in that: include: An acquisition module, used for acquiring brightness data of an image, a first noise image, and a second noise image, wherein the first noise image and the second noise image have different noise types; A sampling module, configured to sample the first noise image multiple times by shifting a starting sampling position by a preset distance each time along a preset direction of the first noise image to obtain multiple sub-images; The sampling module includes: a second acquisition submodule, used to acquire the starting sampling position of the previous sampling period, and offset the first noise image by a preset distance along the preset direction to obtain the starting sampling position of the current sampling period; a first sampling submodule, used to start from the starting sampling position of the current sampling period and sample the data after the starting sampling position of the first noise image; a second sampling submodule, used to sample the first noise image from the preset position of the first noise image when the sampling result does not meet the preset size of the sub-image, until the number of the sub-images reaches a preset value; A generating module is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image, the brightness data, and the image to obtain a rendered image of the image.
9. The device according to claim 8, characterized in that The acquisition module comprises: A first acquisition submodule, used to respectively acquire first brightness data of an image in a first color space and second brightness data of an image in a second color space; The first processing submodule is used to perform weighted summation on the first brightness data and the second brightness data to obtain brightness data of the image.
10. The device according to claim 9, characterized in that The processing submodule comprises: an adjusting unit, configured to adjust the first brightness data according to the first contrast coefficient, and to adjust the second brightness data according to the second contrast coefficient; The processing unit is used to perform weighted summation on the adjusted first brightness data and the adjusted second brightness data to obtain brightness data of the image.
11. The device according to claim 8, characterized in that The method for acquiring the first noise image and the second noise image includes: Acquire a first original image of a first noise and a second original image of a second noise; The first original image and the second original image are respectively subjected to contrast amplification processing and pixel value amplification processing in sequence to obtain a first noise image and a second noise image.
12. The device according to claim 8, characterized in that: The number of the sub-images corresponds to the number of sampling periods.
13. The device according to claim 8, characterized in that The generation module comprises: A second processing submodule is used to sequentially superimpose each sub-image of the multiple sub-images with the second noise image to obtain multiple initial starburst images; A convolution submodule, used for performing convolution sampling processing on the initial starburst image according to a preset convolution kernel to obtain a starburst pattern, wherein the convolution kernel is set to have a weight decreasing in sequence from the center of the convolution kernel to the diagonal direction; The generating submodule is used to superimpose the starburst pattern, the brightness data and the image to obtain a rendered image of the image.
14. The device according to claim 8, characterized in that ,The first noise image includes a Perlin noise image, and the second noise image includes a Gaussian noise image.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image rendering method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image rendering method according to any one of claims 1 to 7.
17. A computer program product, comprising instructions, characterized in that: When the instruction is executed by a processor of an electronic device, the electronic device is enabled to execute the image rendering method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Dim small celestial body optical navigation feature imaging simulation method
CN110455281A
Image rendering method, device and equipment and storage medium
CN110827391A
