Text stroke method, device and storage medium

By performing alpha channel filtering and color reorganization processing on text images, the problem of excessive consumption of computing resources caused by text strokes is solved, an efficient text stroke effect is achieved, and the problem of reduced screen refresh frequency is avoided.

CN116993860BActive Publication Date: 2024-10-11SHENZHEN HUOZU TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310924064.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-25
Publication Date
2024-10-11
Estimated Expiration
2043-07-25

AI Technical Summary

Technical Problem

In the existing technology, the text stroke special effect consumes too much computing resources, causing all GPU computing units to be temporarily used, causing the screen refresh frequency to be less than 24fps, causing freezes or frame drops.

Method used

By receiving the text image to be stroked, using the preset convolution kernel to perform alpha channel filtering processing, generating filter texture, and performing color reorganization processing according to the preset color assembly algorithm to generate a reorganization vector, and finally performing stroke rendering processing based on the reorganization vector , generate a text image with strokes.

Benefits of technology

Without reducing the rendering quality, it greatly saves the computing power consumption of the GPU, avoids the problem of reduced screen refresh frequency, and achieves an efficient text stroke effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116993860B_ABST
    Figure CN116993860B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of special effects adding, and discloses a text stroke method, device and storage medium. The method comprises: receiving a text image to be stroked and rendered; performing alpha channel filtering on the text image according to a preset convolution kernel to obtain a filter texture; reading a color vector of the filter texture, and performing color reorganization processing on the color vector according to a preset color assembly algorithm to generate a reorganized vector; performing stroke rendering processing on the text image based on the reorganized vector to generate a text image with strokes. In an embodiment of the present invention, the technical problem of excessive consumption of computing resources caused by current text strokes is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of special effect adding, and in particular to a text stroking method, device and storage medium. Background Art

[0002] In the hot short video production field, where content homogeneity is serious, the impact of visual effects is particularly important. Text effects are also an important means for content creators. Some special effects currently on the market greatly affect the relevant rendering efficiency, such as text stroke effects. Every pixel on the image has a position on the image, assumed to be point P (x, y), x represents the horizontal coordinate of the pixel, y represents the vertical coordinate of the pixel, and the image texture satisfies the following properties: pixels covered by the text itself, the alpha channel value is 1.0f, non-covered pixels, the alpha channel (transparent channel: represents the opacity of the current color value) value is 0.0f. Under the above preconditions, we use the pixels of the text itself as the starting point and detect the surrounding pixels in a circular manner (the maximum value of the detection radius is the width of the stroke). The detection process involves the following two situations:

[0003] Case 1: Within the detection radius, pixels with an alpha channel value of 1.0f can be detected, and the pixel at the starting point of the detection needs to be stroked and filled.

[0004] Case 2: If no pixel with an alpha channel value of 1.0f can be detected within the detection radius, the pixel at the starting point of the detection does not need to be stroked or filled.

[0005] Disadvantages of traditional algorithms: As can be seen from the above two situations, when drawing in real time, it is necessary to perform circular detection on each pixel with alpha = 0.0f, and this detection consumes a lot of GPU computing units. When all GPU computing units are temporarily used, the new parallel drawing tasks of the GPU will be temporarily shelved, which will appear to the user as lag, or the screen refresh rate is lower than the minimum refresh rate of the human eye (24fps), which is manifested as frame drops.

[0006] Therefore, a new technology is needed to solve the current technical problem of excessive consumption of computing resources caused by text stroke. Summary of the invention

[0007] The main purpose of the present invention is to solve the technical problem of excessive consumption of computing resources caused by current text stroke.

[0008] A first aspect of the present invention provides a method for stroking a text, the method comprising:

[0009] Receive the text image to be rendered;

[0010] According to a preset convolution kernel, performing alpha channel filtering on the text image to obtain a filtered texture;

[0011] Reading the color vector of the filter texture, and performing color reassembly processing on the color vector according to a preset color assembly algorithm to generate a reassembly vector;

[0012] Based on the reorganized vector, the text image is subjected to stroke rendering processing to generate a text image with stroke.

[0013] Optionally, in a first implementation of the first aspect of the present invention, performing alpha channel filtering on the text image according to a preset convolution kernel to obtain a filtered texture includes:

[0014] Based on the preset detection side length, the preset convolution kernel is weighted and processed to generate a triangular filter;

[0015] Based on the triangular filter, the text image is subjected to alpha channel filtering to obtain a filtered texture.

[0016] Optionally, in a second implementation of the first aspect of the present invention, the step of performing weight distribution processing on a preset convolution kernel based on a preset detection side length to generate a triangular filter includes:

[0017] Based on the preset slope formula, the preset detection side length is substituted to calculate the slope value, wherein the slope formula includes:

[0018] K = -1 / (blursize+1) 2 , where K is the slope value and blursize is the length of the detection edge;

[0019] Based on the preset intercept formula, the preset detection side length is substituted to calculate the intercept value, wherein the intercept formula includes:

[0020] B = 1 / (blursize+1), where B is the intercept value and blursize is the length of the detection side;

[0021] The floating-point parameters are set, and according to a preset filtering framework, the slope value, the intercept value, and the floating-point parameters are substituted to generate a triangular filter, wherein the filtering framework includes:

[0022] R=K*i+B, where R is the weight value, K is the slope value, i is a floating point parameter, and B is the intercept value.

[0023] Optionally, in a third implementation of the first aspect of the present invention, performing alpha channel filtering on the text image based on the triangular filter to obtain a filtered texture includes:

[0024] Determine whether the floating point parameter is greater than a preset detection side length;

[0025] If it is not greater than the preset detection side length, the offset is calculated based on the product of the preset fuzzy direction and the floating point parameter;

[0026] Read the coordinate data of the target pixel and the texture data of the target pixel;

[0027] According to a preset color calculation formula, the texture data, the coordinate data, the weight value, and the offset are substituted to obtain a filtered texture of the alpha channel, and the value of the floating-point parameter is increased to re-judge whether the floating-point parameter is greater than a preset detection side length.

[0028] Optionally, in a fourth implementation of the first aspect of the present invention, the color calculation formula includes:

[0029] Color1=texelFetch(uTexture1,coordI+offset,0)*R;

[0030] Color2=texelFetch(uTexture1,coordI-offset,0)*R;

[0031] Among them, Color1 is the first filtered texture data, Color2 is the second texture data, texelFetch() is the texture extraction function, uTexture1 is the texture data, coordI is the coordinate data, R is the weight value, and offset is the offset.

[0032] Optionally, in a fifth implementation of the first aspect of the present invention, after performing weight distribution processing on a preset convolution kernel based on a preset detection side length to generate a triangular filter, and before performing alpha channel filtering processing on the text image based on the triangular filter to obtain a filtered texture, the method further includes:

[0033] According to the intercept value, the text image is color-enlarged to generate a color-enlarged text image.

[0034] Optionally, in a sixth implementation manner of the first aspect of the present invention, performing color recombination processing on the color vector according to a preset color assembly algorithm to generate a recombination vector includes:

[0035] Reading the RGB components and the alpha component of the color vector to generate a three-dimensional color vector and an alpha vector;

[0036] According to a preset color assignment formula, color recombination processing is performed on the three-dimensional color vector and the alpha vector to generate a recombination vector.

[0037] Optionally, in a seventh implementation manner of the first aspect of the present invention, the preset color assignment formula includes:

[0038] glColor=vec3(vec3(color.rgb), clamp(color.a / m, 0, 1)), where glColor is a reorganized vector, vec3() is a three-dimensional vector creation function, clamp() is a numerical restriction function, color.rgb is a three-dimensional color vector, and color.a is an alpha vector.

[0039] A second aspect of the present invention provides a text stroking device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the instructions in the memory so that the text stroking device executes the above-mentioned text stroking method.

[0040] A third aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned method for stroking text.

[0041] In an embodiment of the present invention, a rendering result is close to that of a traditional equidistant stroke when the stroke width is not large, and a convolution kernel operation is adopted, which only involves a small amount of color reading operations and floating-point calculations, and consumes less computing power of the GPU as a whole, thereby greatly saving computing resources and solving the technical problem of excessive computing resource consumption caused by current text stroke. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a schematic diagram of a first embodiment of a method for stroking text in an embodiment of the present invention;

[0043] Figure 2 Schematic diagram of a second embodiment of the method for stroking text in an embodiment of the present invention;

[0044] Figure 3 Schematic diagram of a third embodiment of the method for stroking text in an embodiment of the present invention;

[0045] Figure 4 Schematic diagram of a fourth embodiment of the method for stroking text in an embodiment of the present invention;

[0046] Figure 5Schematic diagram of a fourth embodiment of the method for stroking text in an embodiment of the present invention;

[0047] Figure 6 A schematic diagram of a graphics rendering effect in an embodiment of the present invention;

[0048] Figure 7 The figure is a schematic diagram of an embodiment of a text stroke device in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The embodiments of the present invention provide a text stroke method, device and storage medium.

[0050] The embodiments disclosed in the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments disclosed in the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments disclosed in the present invention are only for exemplary purposes and are not intended to limit the scope of protection disclosed in the present invention.

[0051] In the description of the embodiments disclosed in the present invention, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0052] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first specific embodiment of the text stroke method in the embodiment of the present invention includes:

[0053] 101. Receive a text image to be stroked and rendered;

[0054] In this embodiment, a text image to be rendered is received, and the text image can be imported into the system by downloading from the cloud, downloading from an H5 page, reading from a local storage address, or the like.

[0055] 102. Perform alpha channel filtering on the text image according to a preset convolution kernel to obtain a filtered texture;

[0056] In this embodiment, the convolution kernel exists as a triangular filter, which is modified into a triangular filter by weights, and then the triangular filter is applied to the alpha channel (the transparency and translucency of an image) of the text image, and the alpha channel is modified and reorganized to generate a filtered texture.

[0057] For details, please refer to Figure 2 , Figure 2 In the second specific embodiment of the method for stroking text in the embodiment of the present invention, the following steps may be performed in step 102:

[0058] 1021. Based on the preset detection side length, weight distribution processing is performed on the preset convolution kernel to generate a triangular filter;

[0059] 1022. Perform alpha channel filtering on the text image based on the triangular filter to obtain a filtered texture.

[0060] In this embodiment, the side length of the preset detection area square is set to blursize, and the detection side length is set to blursize+1.0f (f is a floating point type constant mark). The purpose of 1.0f is to adapt the convolution kernel and finally generate an efficient triangular filter. The specific formula of the triangular filter is as follows:

[0061]

[0062] , where y is the dependent variable, x is the independent variable, and n is the radius of the convolution kernel. The mapping image of the function is a straight line and forms a right triangle with the two axes of the coordinate system. In the convolution kernel scenario, the final figure is an isosceles triangle whose base overlaps the X-axis and the third point overlaps the Y-axis. Since the sum of all weights needs to be normalized in the graphics scenario, it is mapped to the image, and the area of ​​the current triangle is 1.0f. Because this algorithm is not the key point of the present invention, the specific derivation is not explained here.

[0063] For further information, please refer to Figure 3 , Figure 3 This is a third specific embodiment of the method for stroking text in an embodiment of the present invention. In step 1021, the following steps may also be performed:

[0064] 10211. Based on a preset slope formula, substitute the preset detection side length to calculate the slope value, wherein the slope formula includes:

[0065] K = -1 / (blursize+1) 2 , where K is the slope value and blursize is the length of the detection edge;

[0066] 10212. Based on a preset intercept formula, substitute the preset detection side length to calculate the intercept value, wherein the intercept formula includes:

[0067] B = 1 / (blursize+1), where B is the intercept value and blursize is the length of the detection side;

[0068] 10213. Set floating-point parameters, and according to a preset filtering framework, substitute the slope value, the intercept value, and the floating-point parameters to generate a triangular filter, wherein the filtering framework includes:

[0069] R=K*i+B, where R is the weight value, K is the slope value, i is a floating point parameter, and B is the intercept value.

[0070] In 10211-10213, R=K*i+B, where R is the weight value, K is the slope value, i is the floating point parameter, and B is the intercept value. The convolution kernel and filter perform filtering operations on the text texture. During the operation, only the alpha channel of the pixel point is filtered.

[0071] The implementation code can perform the following steps:

[0072] k=-1.0f / ((blurSize+1.0f)*(blurSize+1.0f));

[0073] b = 1.0f / (blurSize+1.0f);

[0074] floatr=k*i+b.

[0075] For further information, please refer to Figure 4 , Figure 4 This is a fourth specific embodiment of the method for stroking text in the embodiment of the present invention. In 1022, the following steps may also be performed:

[0076] 10221. Determine whether the floating point parameter is not greater than a preset detection side length;

[0077] 10222. If it is not greater than the preset detection side length, the offset is calculated based on the product of the preset fuzzy direction and the floating point parameter;

[0078] 10223. Read the coordinate data of the target pixel and the texture data of the target pixel;

[0079] 10224. According to a preset color calculation formula, substitute the texture data, the coordinate data, the weight value, and the offset to obtain the filtered texture of the alpha channel, and increase the value of the floating-point parameter to re-determine whether the floating-point parameter is greater than a preset detection side length.

[0080] In steps 10221-10224, the following code can be used:

[0081] for(floati=1.0; i<=blurSize; i+=1.0)

[0082] {

[0083] ivec2offset=ivec2(uBlurDir*i);

[0084] floatr = k*i+b;

[0085] color+=texelFetch(uTexture1,coordI+offset,0)*r;

[0086] color+=texelFetch(uTexture1,coordI-offset,0)*r;

[0087] }

[0088] The code is interpreted as:

[0089] 1. Initialize the floating point parameter i to 1.0.

[0090] 2. Loop condition: as long as i is less than or equal to the detection edge length blurSize.

[0091] 3. After each loop iteration, increase the value of the floating-point parameter i by 1.0.

[0092] 4. In the loop, first calculate the offset, which is a two-dimensional integer vector obtained by multiplying uBlurDir (blur direction) by the current i.

[0093] 5. Next, sample the pixel in texture uTexture1 by using coordI (which may be the coordinates of the current pixel) and offset.

[0094] 6. After obtaining the sampling results, calculate the weight r, which may be obtained by multiplying some constants k and b with the current i.

[0095] 7. Multiply the sampling result by the weight r and add it to the total color color.

[0096] 8. Similarly, perform the reverse offset operation in the loop, that is, subtract offset from coordI and sample the pixel in texture uTexture1.

[0097] 9. Finally, after all loop iterations have completed, the color variable will contain the result of the blur effect.

[0098] The color calculation formula includes:

[0099] Color1=texelFetch(uTexture1,coordI+offset,0)*R;

[0100] Color2=texelFetch(uTexture1,coordI-offset,0)*R;

[0101] Among them, Color1 is the first filtered texture data, Color2 is the second texture data, texelFetch() is the texture extraction function, uTexture1 is the texture data, coordI is the coordinate data, R is the weight value, and offset is the offset.

[0102] Specifically, after step 1021 and before step 1022, the following steps may be performed:

[0103] 1021X. Perform color amplification processing on the text image according to the intercept value to generate a color amplified text image.

[0104] In step 1021X, a circular assignment method such as color=b*color can be used to amplify the color by the intercept value b times. This operation can be used to scale the color or adjust the brightness. The specific effect depends on the value of b. If b is less than 1, the brightness of the color will be reduced, and if b is greater than 1, the brightness of the color will be increased.

[0105] 103. Read the color vector of the filter texture, and perform color reassembly processing on the color vector according to a preset color assembly algorithm to generate a reassembly vector;

[0106] In this embodiment, the reading of texture color can enable a four-dimensional vector to create a function, and the specific creation and assignment code is as follows:

[0107] glFragColor=vec4(glowColor, color.a)

[0108] This line of code assigns a new color value to glFragColor, which is used in the shader to represent the output color of the current fragment (pixel). Specifically, vec4(glowColor,color.a) creates a four-dimensional vector (vec4), the first three components of which come from the variable glowColor, and the last component (alpha component) comes from the alpha component of the variable color. The meaning of this line of code is to use glowColor as the color value of the fragment and keep the alpha value of the original color unchanged. This can achieve some special effects, such as using glowColor as the color of the fragment when adding a glow effect, while retaining the transparency information of the original color.

[0109] Then, based on the texture change of the Alpha channel in the assigned color vector, color reorganization is performed to generate a reorganized vector.

[0110] For further information, please refer to Figure 5 , Figure 5 This is a fifth specific embodiment of the method for stroking text in the embodiment of the present invention. In step 103, the following steps may also be performed:

[0111] 1031. Read the RGB components and the alpha component of the color vector to generate a three-dimensional color vector and an alpha vector;

[0112] 1032. Perform color recombination processing on the three-dimensional color vector and the alpha vector according to a preset color assignment formula to generate a recombination vector.

[0113] In steps 1031-1032, during the assembly process, the texture sampling function texture(uTexture1,vTexPosition1) first obtains the pixel value corresponding to the texture coordinate vTexPosition1 from the texture uTexture1. The result is saved in the temporary variable color, which is a four-dimensional vector (vec4) containing RGB color components and alpha components. The specific code is as follows:

[0114] vec4color=texture(uTexture1,vTexPosition1).

[0115] Then the color assignment formula is used to perform color recombination processing on the three-dimensional color vector and the alpha vector. The recombination process mainly involves splitting and calculating the three-dimensional color vector RGB and the alpha vector respectively and then combining them to generate a recombined vector.

[0116] Furthermore, the preset color assignment formula includes:

[0117] glColor=vec3(vec3(color.rgb), clamp(color.a / m, 0, 1)), where glColor is a reorganized vector, vec3() is a three-dimensional vector creation function, clamp() is a numerical restriction function, color.rgb is a three-dimensional color vector, and color.a is an alpha vector.

[0118] It should be noted that clamp() is a commonly used mathematical function, which is often used in computer programming. It is used to limit a value within a specified range. If the value exceeds the range, it will be clamped between the minimum and maximum values. The following is the general form of the clamp() function: clamp(value,min,max), parameter description: value is the value to be clamped, min is the minimum value of the restriction, and max is the maximum value of the restriction. The return value of the clamp() function is obtained according to the following rules: If value is less than min, return min. If value is greater than max, return max. Otherwise, return value itself.

[0119] 104. Perform stroke rendering processing on the text image based on the reorganized vector to generate a text image with stroke.

[0120] In this embodiment, glColor as a reorganized vector has RGB channel settings and alpha channel settings. Based on the setting data of the vector, the text image is subjected to stroke rendering processing to generate a text image with strokes. For a specific display effect, please refer to Figure 6 , Figure 6 It is a schematic diagram of the graphics rendering effect in an embodiment of the present invention.

[0121] In an embodiment of the present invention, a rendering result is close to that of a traditional equidistant stroke when the stroke width is not large, and a convolution kernel operation is adopted, which only involves a small amount of color reading operations and floating-point calculations, and consumes less computing power of the GPU as a whole, thereby greatly saving computing resources and solving the technical problem of excessive computing resource consumption caused by current text stroke.

[0122] Figure 7 7 is a schematic diagram of the structure of a text stroking device provided by an embodiment of the present invention. The text stroking device 700 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 710 (for example, one or more processors) and a memory 720, and one or more storage media 730 (for example, one or more mass storage devices) storing application programs 733 or data 732. Among them, the memory 720 and the storage medium 730 can be temporary storage or permanent storage. The program stored in the storage medium 730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the text stroking device 700. Furthermore, the processor 710 can be configured to communicate with the storage medium 730 to execute a series of instruction operations in the storage medium 730 on the text stroking device 700.

[0123] The text-based stroke device 700 may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input and output interfaces 760, and / or one or more operating systems 731, such as Windows Server, Mac OS X, Unix, Linux, Free BSD, etc. It will be appreciated by those skilled in the art that Figure 7 The illustrated text stroke device structure does not constitute a limitation on the text-based stroke device, and may include more or less components than illustrated, or a combination of certain components, or a different arrangement of components.

[0124] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the text stroking method.

[0125] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory, or a computer programmable read-only memory. Optical storage devices, magnetic storage devices, or any suitable combination of the above.

[0126] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.

[0127] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A text stroke method, characterized in that: Includes steps: Receive the text image to be rendered; According to a preset convolution kernel, performing alpha channel filtering on the text image to obtain a filtered texture; Reading the color vector of the filter texture, and performing color reassembly processing on the color vector according to a preset color assembly algorithm to generate a reassembly vector; Based on the reorganized vector, performing stroke rendering processing on the text image to generate a text image with stroke; The step of performing alpha channel filtering on the text image according to a preset convolution kernel to obtain a filtered texture includes: Based on the preset detection side length, the preset convolution kernel is weighted and processed to generate a triangular filter; Based on the triangular filter, performing alpha channel filtering on the text image to obtain a filtered texture; The step of performing weight distribution processing on a preset convolution kernel based on a preset detection side length to generate a triangular filter includes: Based on the preset slope formula, the preset detection side length is substituted to calculate the slope value, wherein the slope formula includes: K = -1 / (blursize+1) 2 , where K is the slope value and blursize is the length of the detection edge; Based on the preset intercept formula, the preset detection side length is substituted to calculate the intercept value, wherein the intercept formula includes: B = 1 / (blursize+1), where B is the intercept value and blursize is the length of the detection side; The floating-point parameters are set, and according to a preset filtering framework, the slope value, the intercept value, and the floating-point parameters are substituted to generate a triangular filter, wherein the filtering framework includes: R=K*i+B, where R is the weight value, K is the slope value, i is a floating point parameter, and B is the intercept value; The step of performing alpha channel filtering on the text image based on the triangular filter to obtain a filtered texture includes: Determine whether the floating point parameter is greater than a preset detection side length; If it is not greater than the preset detection side length, the offset is calculated based on the product of the preset fuzzy direction and the floating point parameter; Read the coordinate data of the target pixel and the texture data of the target pixel; According to a preset color calculation formula, the texture data, the coordinate data, the weight value, and the offset are substituted to obtain a filtered texture of the alpha channel, and the value of the floating-point parameter is increased to re-judge whether the floating-point parameter is greater than a preset detection side length.

2. The method for stroking text according to claim 1, characterized in that: The color calculation formula includes: Color1=texelFetch(uTexture1,coordI+offset,0)*R; Color2=texelFetch(uTexture1,coordI-offset,0)*R; Among them, Color1 is the filtered texture of the first alpha channel, Color2 is the filtered texture of the second alpha channel, texelFetch() is the texture extraction function, uTexture1 is the texture data of the target pixel, coordI is the coordinate data, R is the weight value, and offset is the offset.

3. The method for stroking text according to claim 1, characterized in that: After performing weight distribution processing on the preset convolution kernel based on the preset detection side length to generate a triangular filter, and before performing alpha channel filtering processing on the text image based on the triangular filter to obtain a filtered texture, the method further includes: According to the intercept value, the text image is color-enlarged to generate a color-enlarged text image.

4. The method for stroking text according to claim 1, characterized in that: The step of performing color recombination processing on the color vector according to a preset color assembly algorithm to generate a recombination vector comprises: Reading the RGB components and the alpha component of the color vector to generate a three-dimensional color vector and an alpha vector; According to a preset color assignment formula, color recombination processing is performed on the three-dimensional color vector and the alpha vector to generate a recombination vector.

5. The method for stroking text according to claim 4, characterized in that: The preset color assignment formula includes: glColor=vec3(vec3(color.rgb), clamp(color.a / m, 0, 1)), where glColor is a reorganized vector, vec3() is a three-dimensional vector creation function, clamp() is a numerical restriction function, color.rgb is a three-dimensional color vector, and color.a is an alpha vector.

6. A text tracing device, characterized in that: The text stroke device comprises: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instruction in the memory to enable the text stroking device to execute the text stroking method according to any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text stroke method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • A three-dimensional character stroking drawing method

    CN108986193A

  • Style-controllable image text real-time translation and conversion method

    CN111723585A

  • Method and system for texture mapping a source image to a destination image

    EP1434171A2

  • Spatially varying convolution for rendering effects

    WO2009018487A1