Image generation method and device, nonvolatile storage medium and computer equipment

By obtaining image brightness values and edge detection algorithms to identify target edge pixel points, adjust the color values based on the halo color input by the user, and generate an image that simulates edge luminous effects, solving the problem of fixed flood effect library, realizing the flexibility and customization ability of image generation.

CN120355835APending Publication Date: 2025-07-22CHINA TELECOM BESTPAY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510442120.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

The existing flood effect library is relatively fixed, with limited customization capabilities, and it is difficult to adapt to the needs of different scenarios, and has low flexibility.

Method used

By obtaining the brightness value of the initial image, an edge detection algorithm is applied to identify the target edge pixel point, and receive the halo color input by the user, adjusting the color value of the edge pixel point to generate an image that simulates the edge luminous effect.

Benefits of technology

It realizes flexible adjustment of floodlight effects, improves the flexibility of image generation, and meets the diverse needs of users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120355835A_ABST
    Figure CN120355835A_ABST
Patent Text Reader

Abstract

The invention discloses an image generation method and device, a nonvolatile storage medium and computer equipment. The method comprises the following steps: acquiring an initial image; determining brightness values corresponding to a plurality of pixel points in the initial image; determining a target edge pixel point in the initial image based on the brightness values corresponding to the plurality of pixel points and a preset edge detection algorithm; receiving a halo color input based on the target account; based on the halo color, color values corresponding to the target edge pixel points are adjusted to obtain a target image, and the target image is an initial image under the simulated edge light-emitting effect. The technical problems that an existing floodlight effect library is generally relatively fixed, the customization capability is limited, the requirements of different scenes are difficult to adapt, and the flexibility is relatively low are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular, to an image generation method, apparatus, non-volatile storage medium, and computer device. Background Art

[0002] On the browser side, the implementation of the image skeleton bloom effect relies on shader technology and is rendered in real time through GPU acceleration. Although this effect is widely used in fields such as games and movies, it is still relatively rare in browsers. The main reason is that the technical threshold for developing the bloom effect is relatively high, involving multiple image processing processes such as brightness extraction and blur processing, and requires developers to have solid knowledge of graphics. At the same time, the current bloom effect libraries and engines are usually relatively fixed, with limited customization capabilities and difficult to meet the requirements of different scenarios.

[0003] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention

[0004] Embodiments of the present invention provide an image generation method, apparatus, non-volatile storage medium, and computer device to at least solve the technical problems that the current bloom effect library is usually relatively fixed, with limited customization capabilities, difficult to meet the requirements of different scenarios, and low flexibility.

[0005] According to one aspect of the embodiments of the present invention, an image generation method is provided, including: obtaining an initial image; determining the respective brightness values of a plurality of pixel points in the initial image; determining target edge pixel points in the initial image based on the respective brightness values of the plurality of pixel points and a preset edge detection algorithm; receiving a halo color input based on a target account; and adjusting the color value corresponding to the target edge pixel points based on the halo color to obtain a target image, where the target image is the initial image under the simulated edge glow effect.

[0006] Optionally, determining the respective brightness values of a plurality of pixel points in the initial image includes: collecting the respective color values of the plurality of pixel points, where the color value includes the numerical values corresponding to the red, green, and blue channels respectively; and calculating the weighted average of the respective color values of the plurality of pixel points as the respective brightness values of the plurality of pixel points based on preset weights, where the weights include the weights corresponding to the red, green, and blue channels respectively.

[0007] Optionally, based on the brightness values corresponding to multiple pixel points and a preset edge detection algorithm, determine the target edge pixel points in the initial image. In the case where the edge detection algorithm is the Sobel detection algorithm, it includes: based on the initial image, establish a two-dimensional coordinate system; based on the convolution kernel in the Sobel detection algorithm and the brightness values corresponding to multiple pixel points, perform a convolution operation on the multiple pixel points to obtain the gradient values of the multiple pixel points in the x-direction and y-direction in the two-dimensional coordinate system; based on the gradient values of the multiple pixel points in the x-direction and y-direction, determine the target edge pixel points.

[0008] Optionally, based on the brightness values corresponding to multiple pixel points and a preset edge detection algorithm, determine the target edge pixel points in the initial image, including: based on the initial image, establish a two-dimensional coordinate system; based on the brightness values corresponding to multiple pixel points and a preset edge detection algorithm, determine the initial edge pixel points in the initial image; in the two-dimensional coordinate system, determine the pixel points among the initial edge pixel points whose abscissa is greater than the preset threshold as the target edge pixel points.

[0009] Optionally, the method for determining the preset threshold includes: setting a time variable; based on the time variable, determine the kernel offset; determine the sine value corresponding to the kernel offset as the preset threshold.

[0010] Optionally, based on the halo color, adjust the color values corresponding to the target edge pixel points to obtain the target image, where the target image is the initial image under the simulated edge glow effect, including: receiving the halo width input based on the target account; based on the halo width and the target edge pixel points, determine the halo pixel points; based on the halo color, adjust the color values corresponding to the target edge pixel points and the halo pixel points to obtain the target image.

[0011] Optionally, based on the Vue framework, set a custom directive, where the custom directive is used to indicate the generation of the target image.

[0012] According to another aspect of the embodiments of the present invention, there is also provided an image generation device, including: an acquisition module for acquiring an initial image; a first determination module for determining the brightness values corresponding to multiple pixel points in the initial image; a second determination module for determining the target edge pixel points in the initial image based on the brightness values corresponding to multiple pixel points and a preset edge detection algorithm; a reception module for receiving the halo color input based on the target account; an adjustment module for adjusting the color values corresponding to the target edge pixel points based on the halo color to obtain the target image, where the target image is the initial image under the simulated edge glow effect.

[0013] According to another aspect of the embodiments of the present invention, a non-volatile storage medium is further provided. The non-volatile storage medium includes a stored program, wherein when the program runs, it controls the device where the non-volatile storage medium is located to execute any one of the above image generation methods.

[0014] According to still another aspect of the embodiments of the present invention, a computer device is further provided. The computer device includes a processor for running a program, wherein when the program runs, it executes any one of the above image generation methods.

[0015] In the embodiments of the present invention, by adopting the image generation method, an initial image is obtained; the brightness values corresponding to multiple pixel points in the initial image are determined; based on the brightness values corresponding to the multiple pixel points and a preset edge detection algorithm, the target edge pixel points in the initial image are determined; the halo color input based on the target account is received; based on the halo color, the color value corresponding to the target edge pixel points is adjusted to obtain a target image, where the target image is the initial image under the simulated edge light-emitting effect, achieving the purpose of flexibly adjusting the bloom effect, thereby realizing the technical effects of improving the flexibility of image generation and better meeting the needs of users, and further solving the technical problems that the current bloom effect library is usually relatively fixed, with limited customization ability, difficult to adapt to the needs of different scenarios, and low flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:

[0017] Figure 1 A hardware structure block diagram of a computer terminal for implementing the image generation method is shown;

[0018] Figure 2 is a flowchart of the image generation method provided by the embodiments of the present invention;

[0019] Figure 3 is a schematic diagram of the initial image and the target image of the image generation method provided by the optional embodiments of the present invention;

[0020] Figure 4 is a block diagram of the structure of the image generation device provided by the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] To enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative work shall fall within the scope of protection of the present invention.

[0022] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned accompanying drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order different from those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0023] According to an embodiment of the present invention, a method embodiment of an image generation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.

[0024] The method embodiment provided in the first embodiment of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal for implementing the image generation method is shown. As Figure 1 shown, the computer terminal 10 may include one or more (shown as 102a, 102b,..., 102n in the figure) processors (the processor may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown in Figure 1The different configurations shown.

[0025] It should be noted that one or more of the above-mentioned processors and / or other data processing circuits can generally be referred to as "data processing circuits" herein. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10. As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistance terminal path connected to an interface).

[0026] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the image generation method in the embodiments of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the image generation method of the above application program. The memory 104 can include high-speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 can further include a memory remotely set relative to the processor, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0027] The display can be, for example, a touch-screen liquid crystal display (LCD), and the liquid crystal display enables a user to interact with the user interface of the computer terminal 10.

[0028] Figure 2 is a schematic flowchart of the image generation method provided according to the embodiments of the present invention, as Figure 2 shown, the method includes the following steps:

[0029] Step S202, obtain an initial image.

[0030] In this step, the obtained initial image can be an image for which an edge glow effect is to be generated. Specifically, it can be determined by the user.

[0031] Step S204, determine the brightness value corresponding to each of a plurality of pixel points in the initial image.

[0032] In this step, usually the image is in color, and each pixel is defined by the values of three color channels: Red, Green, and Blue. Usually, the range of these values is from 0 to 255. Since each pixel of a color image contains information of three color channels, and image processing algorithms such as edge detection are usually performed on grayscale images, it is necessary to convert the RGB values of each pixel into a brightness or grayscale value. The calculation of the brightness value takes into account the human eye's perception sensitivity to different colors. For each pixel, a brightness calculation formula is applied to determine its brightness value. This formula is based on the visual characteristics of the human eye and usually takes the form of weighted average, where the weight of green is the highest because the human eye is most sensitive to green, followed by red, and the weight of blue is the lowest. The above brightness calculation steps are repeated for each pixel in the image, and each pixel will obtain a corresponding brightness value. These brightness values constitute the brightness distribution information of the image, and this step provides a data basis for subsequent image processing.

[0033] Through the above steps, the brightness value of each pixel in the initial image can be determined, providing accurate data support for subsequent image processing and effect generation. The calculation of the brightness value not only simplifies the image data, making it easier to process, but also retains the key features of the image, such as edges, contours, and textures, which is crucial for generating high-quality image skeleton floodlight effects. In implementation, this process usually utilizes the parallel computing power of modern graphics processing units (GPUs) and is efficiently completed in a WebGL environment through a shader language (such as GLSL) to achieve real-time rendering and dynamic effects.

[0034] Step S206: Based on the brightness values corresponding to multiple pixels and a preset edge detection algorithm, determine the target edge pixels in the initial image.

[0035] In this step, the edge detection algorithm is used to identify the regions in the image where the brightness values change sharply, and these regions often correspond to the boundaries of objects. Common edge detection algorithms include the Sobel operator, Canny edge detection, Prewitt operator, Roberts operator, etc. Each algorithm has its specific calculation method and advantages, but their common goal is to identify the pixel regions with large brightness gradients or changes. The selected edge detection algorithm is applied to each pixel of the image. The algorithm analyzes the brightness values of the pixel and its neighborhood and determines which pixels are edge points by calculating the gradient (brightness change rate). For example, the Sobel operator convolves the brightness values in the X and Y directions respectively to detect edges in the horizontal and vertical directions. After applying the edge detection algorithm, those pixel points whose gradient values (i.e., the degree of brightness change) exceed a certain threshold are regarded as target edge pixels. The selection of the threshold is usually based on the image content and the required accuracy of edge detection.

[0036] Through the above process, the boundaries of the object, i.e., the target edge pixel points, can be accurately identified from the initial image. These edge information are the basis for many vision tasks, including but not limited to image segmentation, feature point detection, glow effect generation, etc. In the patented technical solution you proposed, this process is particularly important because it provides the necessary edge information for generating the glow effect of the image edge. By accurately identifying the edges, it can ensure that the glow effect properly highlights the object contour while avoiding excessive noise and false edges, thereby improving the naturalness and attractiveness of the visual effect.

[0037] Step S208: Receive the glow color input based on the target account.

[0038] In this step, the glow color input by the user can be received and adjusted according to the user's needs, which can better meet the user's requirements. Before generating the glow effect, the color of the glow needs to be determined. The choice of the glow color depends on the desired visual effect and the color tone of the original image. It can be a single color, or it can be automatically generated according to the image content, or it can be user-defined. The glow color is usually brighter or more vivid than the edge color in the original image to simulate the effect of glowing or "overflowing".

[0039] Step S210: Based on the glow color, adjust the color values corresponding to the target edge pixel points to obtain a target image, where the target image is the initial image under the simulation of the edge glow effect.

[0040] In this step, the color values of the identified edge pixel points are adjusted to add the glow effect. The adjustment methods usually include: for example, increasing the brightness of the edge pixel points to make them look brighter or glowing. This can be achieved by simply increasing the brightness component (i.e., adding a constant value based on the weighted brightness formula). Mix the glow color with the original pixel color. The mixing ratio and method can be adjusted according to the edge strength and the needs of the glow effect. Edges with higher strength will receive more glow color, resulting in a more obvious glowing effect. To make the glow look natural, the color values of the pixel points near the edge pixels may also be slightly adjusted to simulate the diffusion of light. This process is usually achieved through a blur filter (such as Gaussian blur), which "diffuses" the color values in the edge area to the surrounding pixels, creating a gradual glowing effect. After adjusting the color values of all target edge pixel points and their surrounding areas, a target image simulating the edge glow effect is obtained. This image retains most of the visual information of the original image, but adds an additional glowing or glow effect in the edge area, enhancing the visual attractiveness and artistic expressiveness of the image.

[0041] The key to this process lies in precisely adjusting the brightness and color of edge pixels and their neighborhoods to simulate the scattering and reflection behavior of natural light. The degree and scope of adjustment need to be fine-tuned according to different visual requirements and application scenarios to achieve the best visual effects. This process can utilize the parallel computing power of the GPU and be efficiently completed in a WebGL environment through a shader language (such as GLSL), ensuring real-time performance and high-quality visual effects.

[0042] Through the above steps, the purpose of flexibly adjusting the bloom effect is achieved, thus achieving the technical effect of improving the flexibility of image generation and better meeting the needs of users. Furthermore, the technical problem that the current bloom effect library is usually relatively fixed, with limited customization capabilities and difficulty in adapting to the needs of different scenarios and low flexibility is solved.

[0043] As an optional embodiment, determining the brightness values corresponding to multiple pixel points in the initial image includes: collecting the color values corresponding to multiple pixel points, where the color values include the numerical values corresponding to the red, green, and blue channels respectively; calculating the weighted average of the color values corresponding to multiple pixel points as the brightness values corresponding to multiple pixel points based on preset weights, where the weights include the weights corresponding to the red, green, and blue channels respectively.

[0044] Optionally, collect the color value of each pixel point from the initial image. Each pixel in a color image is defined by the numerical values of the red (R), green (G), and blue (B) color channels. These numerical values are usually between 0 and 255, representing the intensity of the color. For example, a completely red pixel may be represented as (R:255, G:0, B:0), while a gray pixel may be represented as (R:128, G:128, B:128). Then determine the preset weights used to calculate the brightness value. These weights reflect the human eye's perception sensitivity to different colors. In standard brightness calculations, the weight of the green channel is the highest, followed by the red channel, and the weight of the blue channel is the lowest. This is because the human eye is most sensitive to green, less sensitive to red, and least sensitive to blue. A common weight assignment is: the weight of the red channel: 0.2126, the weight of the green channel: 0.7152, the weight of the blue channel: 0.0722. These weights are based on the standards of the CIE XYZ color space and have been widely accepted and used. For each pixel point, use the numerical values of its red, green, and blue color channels and combine them with the preset weights to calculate the weighted average brightness value. The formula for calculating the brightness value is:

[0045] L = 0.2126 * R + 0.7152 * G + 0.0722 * B

[0046] Among them, L is the calculated brightness value, and R, G, and B are the intensity values of the red, green, and blue color channels of the pixel respectively. Through the above formula, each pixel will obtain a corresponding brightness value, which will be closer to the human eye's perception of the image brightness. Repeat the above calculation process to calculate the brightness value of each pixel in the image. Finally, an image containing all pixel brightness values will be obtained, that is, the brightness image or grayscale image. This image retains the structure and features of the original image, but replaces the original RGB values with a single brightness value, thus simplifying the image data and making it more suitable for subsequent processing such as edge detection and feature recognition.

[0047] The whole process aims to simplify the information of the color image into brightness information for the application of subsequent image processing algorithms. By correctly calculating the brightness value of each pixel, the naturalness and accuracy of the image processing result can be ensured while reducing the processing complexity.

[0048] As an optional embodiment, based on the brightness values corresponding to multiple pixel points and a preset edge detection algorithm, the target edge pixel points in the initial image are determined. In the case where the edge detection algorithm is the Sobel detection algorithm, it includes: establishing a two-dimensional coordinate system based on the initial image; performing a convolution operation on multiple pixel points based on the convolution kernels in the Sobel detection algorithm and the brightness values corresponding to multiple pixel points respectively to obtain the gradient values in the x-direction and y-direction in the two-dimensional coordinate system corresponding to multiple pixel points respectively; determining the target edge pixel points based on the gradient values in the x-direction and y-direction corresponding to multiple pixel points respectively.

[0049] Optionally, when processing an image, the image is usually regarded as a two-dimensional coordinate system, where each pixel has a unique coordinate position. The origin of the coordinate system is located at the upper left corner of the image, and the coordinate values change with the position of the pixel in the image. The horizontal direction is the x-axis, and the vertical direction is the y-axis. The Sobel operator detects the edges of the image through two 3x3 convolution kernels. These two kernels are used to detect the gradients in the x-direction and y-direction respectively. The convolution kernels are as follows: The Sobel kernel in the X direction: The Sobel kernel in the Y direction: Apply the convolution kernels of the Sobel operator to each pixel in the image to perform the convolution operation. The convolution operation will analyze the brightness values of the current pixel and its surrounding 8 adjacent pixel points, and use G x and G yTwo kernels are used to calculate the gradient values in the x and y directions. The gradient value reflects the rate of change of the luminance value, that is, the luminance difference between this pixel and its surrounding pixels in the x and y directions. By convolving the Sobel kernel with the image luminance values, the gradient values of each pixel in the x and y directions can be obtained. The magnitude of the gradient value reflects the amplitude of the change in the luminance value. A large gradient value usually indicates the presence of an edge because an edge is an area where the image luminance value changes sharply. After obtaining the gradient values of each pixel in the x and y directions, the target edge pixels can be determined by combining these two gradient values. The following formula is usually used to calculate the total gradient value of each pixel: According to the calculated total gradient value, a threshold is set, and all pixels whose gradient values exceed this threshold will be identified as target edge pixels. The selection of this threshold depends on the specific image content and the required edge detection accuracy.

[0050] Through the above process, it is possible to accurately determine which pixels are target edge pixels from the initial image luminance values based on the Sobel operator. The Sobel operator is widely used because of its simplicity and efficiency. It can effectively detect edges in the horizontal and vertical directions and plays an important role in the extraction of image skeletons and the generation of the bloom effect. In your patented technical solution, this process is a step to identify the image skeleton and prepare key information for subsequent bloom generation. By accurately calculating the edge intensity, it can ensure that the bloom effect appropriately highlights the contours in the image, thus enhancing the visual effect.

[0051] As an alternative embodiment, to determine the target edge pixels in the initial image based on the luminance values corresponding to multiple pixels and a preset edge detection algorithm, it includes: establishing a two-dimensional coordinate system based on the initial image; determining the initial edge pixels in the initial image based on the luminance values corresponding to multiple pixels and the preset edge detection algorithm; in the two-dimensional coordinate system, determining the pixels whose abscissas are greater than the preset threshold among the initial edge pixels as the target edge pixels.

[0052] Optionally, a preset edge detection algorithm (such as the Sobel algorithm, the Canny algorithm, etc.) is used to identify pixels with a large brightness gradient change based on the brightness value of each pixel in the image. These pixels constitute the initial edge of the image. After obtaining a set of all candidate edge pixels, it may be necessary to further screen these edge points in order to meet specific visual effects or processing requirements. To this end, a preset threshold of the horizontal coordinate is introduced, and only those pixels whose horizontal coordinates are greater than the threshold are retained as target edge pixels. The selection of the horizontal coordinate threshold may be based on the image content, the characteristics of the display device, or the needs of the user. It can focus on a specific part of the image, such as the right area in the horizontal direction. This method ensures the flexibility and pertinence of edge detection, and helps to obtain better results in different visual processing tasks, such as the generation of floodlight effects at the edges of images.

[0053] Figure 3 is a schematic diagram of an initial image and a target image according to an image generation method provided in an optional embodiment of the present invention, such as Figure 3 As shown in the figure, the original image is the initial image, and the other three images are the target images corresponding to different thresholds.

[0054] As an optional embodiment, the method for determining the preset threshold includes: setting a time variable; determining a core offset based on the time variable; and determining a sine value corresponding to the core offset as the preset threshold.

[0055] Optionally, when processing an image, the introduction of a time variable enables the visual effect to change over time, thereby achieving a dynamic or animated effect. The time variable is usually represented as t, which can be the actual time of the program running, or the number of frames, loop counts, etc. of the animation. The use of time variables enables the image processing algorithm to produce time-related outputs, increasing the dynamics and ornamental nature of the visual effect. The kernel offset refers to the offset used to control the algorithm kernel relative to the pixel position when applying certain image processing algorithms (such as edge detection, blur effects, etc.). In the generation of dynamic effects, the kernel offset can change with the change of the time variable. For example, the kernel offset can be a function of the time variable, such as a sine function or a cosine function, which can achieve a periodic dynamic effect. Specifically, the kernel offset may affect the direction of the gradient calculation in the edge detection algorithm or the range and direction of the filter in the blur effect. After the introduction of the time variable and the kernel offset, the determination of the preset threshold becomes dynamic and variable. Here, the preset threshold is determined based on the sine value corresponding to the kernel offset. The use of the sine function can produce periodic changes, thereby providing dynamic adjustment for the threshold of the image processing algorithm. For example, if the nuclear offset varies with a time variable, the preset threshold may be set to the output value of a sine function.

[0056] By using time variables and time-based mathematical functions (such as sine functions), it is possible to dynamically adjust the parameters of image processing algorithms, such as thresholds or kernel offsets, thereby generating visual effects that change over time. The dynamic change of the preset threshold can achieve fluctuations or pulsations in the effect, such as the intensity of edge detection changing over time, or the diffusion range of the halo effect dynamically adjusting over time, enhancing the dynamic and artistic nature of the visual effect.

[0057] As an alternative embodiment, based on the halo color, the color values corresponding to the target edge pixels are adjusted to obtain a target image, where the target image is the initial image under the simulated edge glow effect, including: receiving the halo width input based on the target account; determining the halo pixels based on the halo width and the target edge pixels; adjusting the color values corresponding to the target edge pixels and the halo pixels based on the halo color to obtain the target image.

[0058] Optionally, receive the halo width input based on user or system parameters. The halo width is a key parameter that defines the degree of diffusion of the edge glow effect in the image. A larger halo width means that the glow effect will cover a wider edge area, and vice versa, it will be focused within a narrower range. The halo width can be adjusted by the user according to needs or automatically calculated based on the image content of a specific scene. After receiving the halo width, the next step is to determine which pixels will be given the halo effect. This usually involves expanding the adjacent area of the target edge pixels. For each target edge pixel, the pixels within a certain distance (i.e., half of the halo width) around it will be identified as halo pixels. These pixels, together with the target edge pixels, will become the objects of subsequent processing to simulate the glow effect. Next, based on the preset halo color, the color values of the target edge pixels and the halo pixels are adjusted to produce the edge glow effect. The methods of color adjustment usually include: Brightness enhancement: Increase the brightness values of the edge and halo pixels to make them appear brighter or glowing. This can be achieved by mixing the halo color with the original color or simply adding a value representing the halo intensity to the brightness component. Color mixing: Mix or superimpose the halo color with the original color of the edge pixels. The mixing ratio and method depend on the intensity and diffusion degree of the halo. Usually, the color at the center of the halo (i.e., the target edge pixel) is mixed with the halo color the most, while the color of the halo pixels around the edge pixels gradually weakens to create a gradient glow effect.

[0059] After adjusting the color values of all target edge pixels and halo pixels, a target image with a simulated edge glow effect is obtained. This image visually retains the content of the original image but adds a halo or glow effect in the edge area, thereby enhancing the visual attraction and artistic expressiveness of the image. The intensity and diffusion range of the halo effect depend on the halo width and the parameter settings during the color adjustment process.

[0060] As an alternative embodiment, based on the Vue framework, custom directives are set, where the custom directives are used to indicate the generation of a target image.

[0061] Optionally, in the Vue framework, Vue Custom Directives are a very powerful tool that allows developers to add special behaviors to elements in Vue templates. Custom directives can be defined in the global or local context of a Vue application. The directive needs to be explicitly registered in a Vue instance or component. A custom directive is represented by an object that can contain multiple hook functions, such as mounted, updated, etc., for performing specific operations at different lifecycle stages. In the mounted hook of the custom directive, initialization operations are performed, such as obtaining the WebGL context, creating a shader program, setting buffers and textures, etc. This stage is when the custom directive is called for the first time after the element is inserted into the DOM. In the updated hook, the update of the element data or state is processed. For example, when the bound value changes (such as the glow width or color), the corresponding WebGL state is updated and the image is re-rendered. The updated hook is called every time the element is updated. In the Vue template, a custom directive such as v-light can be used. The directive can be bound to a canvas element and parameters can be passed, such as the initial image, glow width, and color, etc. In the hook function of the custom directive, the generation algorithm for the image skeleton glow effect is executed. This may include steps such as calculating luminance values, edge detection, adjusting color values, etc., and finally obtaining the target image with an edge glow effect. Every time there is an update or user interaction, the custom directive can automatically re-render the image and apply the latest parameter values to ensure the dynamics and real-time nature of the glow effect.

[0062] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0063] Through the description of the above embodiments, those skilled in the art can clearly understand that the image generation method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0064] According to an embodiment of the present invention, there is also provided an image generation device for implementing the above image generation method. Figure 4 According to the structural block diagram of the image generation device provided by the embodiment of the present invention, as Figure 4 shown, the image generation device includes: an acquisition module 402, a first determination module 404, a second determination module 406, a reception module 408, and an adjustment module 410. The image generation device will be described below.

[0065] The acquisition module 402 is configured to acquire an initial image.

[0066] The first determination module 404 is connected to the acquisition module 402 and is configured to determine the brightness values respectively corresponding to multiple pixel points in the initial image.

[0067] The second determination module 406 is connected to the first determination module 404 and is configured to determine the target edge pixel points in the initial image based on the brightness values respectively corresponding to the multiple pixel points and a preset edge detection algorithm.

[0068] The reception module 408 is connected to the second determination module 406 and is configured to receive the halo color input based on the target account.

[0069] The adjustment module 410 is connected to the reception module 408 and is configured to adjust the color values corresponding to the target edge pixel points based on the halo color to obtain a target image, where the target image is the initial image under the simulated edge light-emitting effect.

[0070] Optionally, the first determination module is configured to determine the brightness values respectively corresponding to multiple pixel points in the initial image, including: an acquisition unit configured to acquire the color values respectively corresponding to the multiple pixel points, where the color values include the values respectively corresponding to the red, green, and blue channels; a calculation unit configured to calculate the weighted average of the color values respectively corresponding to the multiple pixel points as the brightness values respectively corresponding to the multiple pixel points based on a preset weight, where the weight includes the weights respectively corresponding to the red, green, and blue channels.

[0071] Optionally, the second determination module is configured to determine target edge pixels in the initial image based on the luminance values corresponding to multiple pixel points and a preset edge detection algorithm. In the case where the edge detection algorithm is the Sobel detection algorithm, it includes: a construction unit configured to construct a two-dimensional coordinate system based on the initial image; a convolution unit configured to perform a convolution operation on multiple pixel points based on the convolution kernel in the Sobel detection algorithm and the luminance values corresponding to the multiple pixel points, to obtain the gradient values of the multiple pixel points in the x direction and the y direction in the two-dimensional coordinate system; a first determination unit configured to determine the target edge pixels based on the gradient values of the multiple pixel points in the x direction and the y direction.

[0072] Optionally, the second determination unit is configured to determine target edge pixels in the initial image based on the luminance values corresponding to multiple pixel points and a preset edge detection algorithm, including: a construction unit configured to construct a two-dimensional coordinate system based on the initial image; a second determination unit configured to determine initial edge pixels in the initial image based on the luminance values corresponding to the multiple pixel points and the preset edge detection algorithm; a third determination unit configured to, in the two-dimensional coordinate system, determine the pixels whose abscissa is greater than a preset threshold among the initial edge pixels as the target edge pixels.

[0073] Optionally, the determination device for the preset threshold includes: a setting module configured to set a time variable; a third determination module configured to determine a kernel offset based on the time variable; a fourth determination module configured to determine the sine value corresponding to the kernel offset as the preset threshold.

[0074] Optionally, the adjustment module is configured to adjust the color value corresponding to the target edge pixels based on the halo color to obtain a target image, where the target image is the initial image under the simulated edge glow effect, including: a receiving unit configured to receive a halo width input based on the target account; a fourth determination unit configured to determine halo pixels based on the halo width and the target edge pixels; an adjustment unit configured to adjust the color values corresponding to the target edge pixels and the halo pixels based on the halo color to obtain the target image.

[0075] Optionally, the above device further includes a definition module configured to set a custom instruction based on the Vue framework, where the custom instruction is used to indicate the generation of the target image.

[0076] It should be noted here that the above acquisition module 402, the first determination module 404, the second determination module 406, the receiving module 408, and the adjustment module 410 correspond to steps S202 to S210 in the embodiment. The instances and application scenarios implemented by the multiple modules and the corresponding steps are the same, but are not limited to the content disclosed in the above embodiment. It should be noted that the above modules, as part of the device, can run in the computer terminal 10 provided in the embodiment.

[0077] Embodiments of the present invention can provide a computer device. Optionally, in this embodiment, the above computer device can be at least one network device among multiple network devices in a computer network. The computer device includes a memory and a processor.

[0078] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the image generation method and device in the embodiments of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the above image generation method. The memory can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory can further include a memory remotely set relative to the processor, and these remote memories can be connected to the computer terminal through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0079] The processor can call the information and application programs stored in the memory through a transmission device to perform the following steps: obtain an initial image; determine the brightness values corresponding to each of the multiple pixel points in the initial image; based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determine the target edge pixel points in the initial image; receive the halo color input based on the target account; based on the halo color, adjust the color values corresponding to the target edge pixel points to obtain a target image, where the target image is the initial image under the simulated edge glow effect.

[0080] By adopting the embodiments of the present invention, a way of an image generation method is provided. By obtaining an initial image; determining the brightness values corresponding to each of the multiple pixel points in the initial image; based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determining the target edge pixel points in the initial image; receiving the halo color input based on the target account; based on the halo color, adjusting the color values corresponding to the target edge pixel points to obtain a target image, where the target image is the initial image under the simulated edge glow effect, the purpose of flexibly adjusting the glow effect is achieved, thereby realizing the technical effects of improving the flexibility of image generation and better meeting the needs of users, and further solving the technical problems that the current glow effect library is usually relatively fixed, the customization ability is limited, it is difficult to adapt to the needs of different scenarios, and the flexibility is low.

[0081] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and this program can be stored in a non-volatile storage medium, which can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, etc.

[0082] An embodiment of the present invention also provides a non-volatile storage medium. Optionally, in this embodiment, the above non-volatile storage medium can be used to store the program code executed by the image generation method provided in the above embodiment.

[0083] Optionally, in this embodiment, the above non-volatile storage medium can be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.

[0084] Optionally, in this embodiment, the non-volatile storage medium is set to store program code for performing the following steps: obtaining an initial image; determining the respective brightness values of multiple pixel points in the initial image; based on the respective brightness values of the multiple pixel points and a preset edge detection algorithm, determining target edge pixel points in the initial image; receiving a halo color input based on a target account; and adjusting the color value corresponding to the target edge pixel points based on the halo color to obtain a target image, where the target image is the initial image under the simulated edge light-emitting effect.

[0085] An embodiment of the present invention also provides a computer program product, including a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, it can implement: obtaining an initial image; determining the respective brightness values of multiple pixel points in the initial image; based on the respective brightness values of the multiple pixel points and a preset edge detection algorithm, determining target edge pixel points in the initial image; receiving a halo color input based on a target account; and adjusting the color value corresponding to the target edge pixel points based on the halo color to obtain a target image, where the target image is the initial image under the simulated edge light-emitting effect.

[0086] The above serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0087] In the above embodiments of the present invention, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0088] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.

[0089] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0090] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0091] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. And the aforementioned storage medium includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks or optical discs and other various media that can store program codes.

[0092] The above is only the preferred embodiment of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be regarded as the protection scope of the present invention.

Claims

1. An image generation method, characterized in that, including: Obtain an initial image; Determine the brightness value corresponding to each of multiple pixel points in the initial image; Based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determine the target edge pixel points in the initial image; Receive the halo color input based on a target account; Based on the halo color, adjust the color values corresponding to the target edge pixel points to obtain a target image, where the target image is the initial image under a simulated edge glow effect.

2. The method according to claim 1, wherein The determining the brightness value corresponding to each of multiple pixel points in the initial image includes: Collect the color values corresponding to each of the multiple pixel points, where the color values include the values corresponding to the red, green, and blue channels respectively; Based on preset weights, calculate the weighted average of the color values corresponding to each of the multiple pixel points as the brightness value corresponding to each of the multiple pixel points, where the weights include the weights corresponding to the red, green, and blue channels respectively.

3. The method according to claim 1, wherein The based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determining the target edge pixel points in the initial image, in the case where the edge detection algorithm is the Sobel detection algorithm, includes: Based on the initial image, establish a two-dimensional coordinate system; Based on the convolution kernel in the Sobel detection algorithm and the brightness values corresponding to each of the multiple pixel points, perform a convolution operation on the multiple pixel points to obtain the gradient values of each of the multiple pixel points in the x direction and y direction in the two-dimensional coordinate system; Based on the gradient values of each of the multiple pixel points in the x direction and y direction, determine the target edge pixel points.

4. The method according to claim 1, wherein The based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determining the target edge pixel points in the initial image includes: Based on the initial image, establish a two-dimensional coordinate system; Based on the brightness values corresponding to each of the multiple pixel points and a preset edge detection algorithm, determine the initial edge pixel points in the initial image; In the two-dimensional coordinate system, determine the pixel points with abscissas greater than a preset threshold among the initial edge pixel points as the target edge pixel points.

5. The method according to claim 4, wherein The method for determining the preset threshold includes: Set a time variable; Based on the time variable, determine a kernel offset; Determine the sine value corresponding to the kernel offset as the preset threshold.

6. The method according to claim 1, characterized in that, The based on the halo color, adjusting the color values corresponding to the target edge pixel points to obtain a target image, where the target image is the initial image under a simulated edge glow effect, includes: Receive the halo width input based on the target account; Based on the halo width and the target edge pixel points, determine halo pixel points; Based on the halo color, adjust the color values corresponding to the target edge pixel points and the halo pixel points to obtain the target image.

7. The method according to any one of claims 1 to 6, characterized in that, It further includes: Based on the Vue framework, set a custom directive, where the custom directive is used to indicate the generation of the target image.

8. An image generation device, characterized in that, including: An acquisition module for acquiring an initial image; A first determination module for determining the brightness value corresponding to each of multiple pixel points in the initial image; A second determination module, configured to determine target edge pixel points in the initial image based on the brightness values corresponding to the multiple pixel points and a preset edge detection algorithm; A receiving module, configured to receive a halo color input based on a target account; An adjustment module, configured to adjust the color values corresponding to the target edge pixel points based on the halo color to obtain a target image, where the target image is the initial image under a simulated edge light-emitting effect.

9. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, where when the program runs, it controls the device where the non-volatile storage medium is located to execute the image generation method according to any one of claims 1 to 7.

10. A computer device, characterized in that, Comprising: A memory and a processor, The memory stores a computer program; The processor is configured to execute the computer program stored in the memory, and when the computer program runs, it causes the processor to execute the image generation method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Image processing method and device, electronic equipment and computer readable storage medium

    CN121707845A