Character image sketching method and system and related equipment

By using compute shaders and variant nine-square convolution kernels for edge detection in the GPU, combining the CPU's vertical line scanning method to filter edge pixels, and using point primitives for drawing, the problems of low efficiency and poor effects in character image drawing in existing technologies are solved, achieving more efficient edge recognition and richer rendering effects.

CN120635128APending Publication Date: 2025-09-12SHENZHEN QUTUI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510771129.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

In the existing technology, the traditional edge detection algorithm used in character image outlining special effects is inefficient and the rendering effect is not rich enough, which makes it difficult to meet user needs.

Method used

The GPU uses a compute shader to perform an alpha channel comparison operation based on a variant nine-square grid convolution kernel to obtain an initial edge pixel labeled image. The CPU then uses a reciprocating vertical line scanning method to filter and eliminate the target portrait edge pixels. Finally, the GPU uses point primitives to outline the portrait edge.

Benefits of technology

It realizes the characteristics of efficient GPU and CPU, improves the processing efficiency and rendering effect of edge recognition, and provides richer outlining effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120635128A_ABST
    Figure CN120635128A_ABST
Patent Text Reader

Abstract

The invention provides a figure image sketching method and system and related equipment. The method comprises the following steps: acquiring a figure image of a to-be-sketched edge; performing upper, lower, left and right neighborhood pixel alpha channel value comparison operation of a variant Sudoku convolution kernel on the figure image through a calculation shader in a GPU (Graphics Processing Unit) to obtain an initial edge pixel marking image; mapping the initial edge pixel marked image into a CPU (Central Processing Unit), and screening and rejecting edge pixels of a target portrait through a reciprocating vertical line scanning method to obtain a portrait edge pixel rejected image; and mapping the portrait edge pixel rejected image back to the GPU, and performing portrait edge drawing with sketching characteristics in a point primitive mode to obtain a figure sketching image. According to the method, the characteristics of the GPU and the CPU are fully utilized, the calculation shader is used and matched with the variant Sudoku, only upper, lower, left and right neighborhood pixels are compared, the processing efficiency is high, a vertical line scanning method is used for scanning in a reciprocating mode, edge recognition is more accurate, edge drawing and rendering are carried out in a point primitive mode, and the sketching effect is richer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to a method and system for outlining a human image and related equipment. Background Art

[0002] In the field of short video production, where content homogeneity is prevalent, visual impact is particularly important. Image character outlining effects are a key tool for content creators. However, current market-proven character outlining effects still use traditional edge detection algorithms (such as the Sobel operator) to detect edges. These algorithms are outdated, inefficient, and lack rich rendering effects, failing to meet user needs.

[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the Invention

[0004] The present invention provides a method, system and related equipment for outlining a human image. The main purpose of the present invention is to solve the technical problems mentioned in the background technology of the existing technology.

[0005] A first aspect of the present invention provides a method for drawing a human image, comprising: Obtaining a person image whose edges are to be outlined; In the GPU, a computation shader is used to perform a comparison operation on the alpha channel values ​​of the upper, lower, left, and right neighboring pixels of each pixel of the character image based on a variant nine-square grid convolution kernel to obtain an initial edge pixel marked image; Mapping the initial edge pixel marked image into a CPU, and screening and eliminating target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel eliminated image; The portrait edge pixel culled image is mapped back to the GPU, and the portrait edge drawing with a characteristic is performed on the portrait edge pixel culled image in the form of point primitives in the GPU to obtain a character outline image.

[0006] In an optional embodiment of the first aspect of the present invention, performing a computation shader on each pixel of the character image using a variant nine-square grid convolution kernel and comparing alpha channel values ​​of upper, lower, left, and right neighboring pixels to obtain an initial edge pixel marked image includes: For each pixel of the person image, the pixel itself is used as the center of the nine-square grid convolution kernel, and the color information of all pixels within the nine-square grid is obtained; Obtaining, from the color information of all pixels within the nine-square grid, the alpha channel value of the pixel itself and of each of its neighboring pixels in four directions: above, below, left, and right; Determine whether there is a transparency transition between the pixel itself and the neighboring pixels in four directions of the pixel itself, above, below, left, and right based on the alpha channel value; If there is a transparency transition between the pixel itself and the neighboring pixels in the four directions of the pixel itself, the pixel itself is marked as an edge pixel point.

[0007] In an optional implementation of the first aspect of the present invention, determining whether there is a transparency transition between the pixel itself and the neighboring pixels in four directions of the pixel above, below, left, and right based on the alpha channel value includes: Obtaining a first alpha channel value of the pixel itself, and determining whether the first alpha channel value is zero; If the first alpha channel value is zero, the pixel itself is determined to be a non-edge pixel; If the first alpha channel value is non-zero, further determining whether the second alpha channel values ​​of the neighboring pixels in the four directions of the pixel itself are zero; If the second alpha channel value of the neighboring pixels in at least one direction is zero, the pixel itself is determined to be an edge pixel point; otherwise, the pixel itself is determined to be a non-edge pixel point.

[0008] In an optional implementation of the first aspect of the present invention, mapping the initial edge pixel marked image into a CPU, and screening and removing target portrait edge pixels from the initial edge pixel marked image using a reciprocating vertical line scanning method in the CPU to obtain a portrait edge pixel removed image includes: For the initial edge pixel marked image, obtaining left and right scanning ranges based on the leftmost and rightmost edge pixel points in the initial edge pixel marked image; Using the left and right scanning ranges as reciprocating limits and scanning the initial edge pixel mark image by moving one pixel step each time through vertical line scanning lines; Obtaining a target edge pixel point set capable of forming a closed figure through the reciprocating scanning; All the edge pixel points that can form a closed figure are removed from the initial edge pixel marked image to obtain a portrait edge pixel removed image.

[0009] In an optional embodiment of the first aspect of the present invention, the scanning of the initial edge pixel mark image by moving one pixel step each time using the left and right scanning ranges as reciprocating limits through vertical line scanning lines comprises: In the process of left and right scanning of the vertical line scanning line, each time scanning from top to bottom and without repetition of the neighborhood analysis of one edge pixel point, and establishing the connection relationship of each edge pixel point group by group; For each set of edge pixel points that can form a connection relationship, the last edge pixel point coincides with the first edge pixel point or the last edge pixel point cannot obtain adjacent edge pixels from all four sides as a scanning cutoff condition, so as to proceed with scanning and establishing a connection relationship for the next set of edge pixel points; Collecting the edge pixel sets of each group that can form a connection relationship; A closed detection is performed on each group of edge pixel point sets to obtain a target edge pixel point set that can form a closed figure.

[0010] In an optional implementation of the first aspect of the present invention, performing closure detection on each group of edge pixel points includes: For each set of edge pixel points, obtaining a starting edge pixel point and an ending edge pixel point; Calculating the pixel distance between the starting edge pixel point and the ending edge pixel point; If the pixel distance is less than or equal to a preset threshold, determining that the starting edge pixel point and the ending edge pixel point form a closed figure; If the pixel distance is greater than the preset threshold, it is determined that the starting edge pixel point and the ending edge pixel point do not form a closed figure.

[0011] In an optional implementation manner of the first aspect of the present invention, the step of drawing the portrait edge by outlining the portrait edge pixel culling image in the GPU in the form of point primitives includes: Obtaining a coordinate set of pixels to be removed from the portrait edge pixel removal image; Acquire outline characteristic parameters, wherein the outline characteristic parameters include outline width, outline color, and outline line style; The edge of the portrait is drawn using the coordinate set as vertex data of the point primitive and the drawing characteristic parameters as the drawing configuration.

[0012] A second aspect of the present invention provides a system for outlining a human image, the system comprising: A character portrait acquisition module is used to acquire a character image whose edges are to be outlined; An edge pixel preliminary marking module is used to perform a comparison operation of alpha channel values ​​of upper, lower, left, and right neighboring pixels based on a variant of a nine-square grid convolution kernel on each pixel of the person image through a computational shader in a GPU to obtain an initial edge pixel marked image; a portrait edge pixel removal module, configured to map the initial edge pixel marked image to a CPU, and screen and remove target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel removed image; The portrait edge delineation module is used to map the portrait edge pixel culled image back to the GPU, and perform portrait edge drawing with characteristic features on the portrait edge pixel culled image in the form of point primitives in the GPU to obtain a character delineation image.

[0013] A third aspect of the present invention provides a device for outlining a human image, the device comprising: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a circuit; The at least one processor calls the instructions in the memory to enable the device for drawing a human image to execute the method for drawing a human image as described in any one of the first aspects of the present invention.

[0014] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for drawing a human image as described in any one of the first aspects of the present invention is implemented.

[0015] Beneficial effects: The present invention provides a method, system, and related equipment for outlining a human image. The method comprises obtaining a human image whose edges are to be outlined; performing a comparison operation on the alpha channel values ​​of the upper, lower, left, and right neighboring pixels of a variant nine-square grid convolution kernel on the human image using a computational shader in a GPU to obtain an initial edge pixel marked image; mapping the initial edge pixel marked image to a CPU and screening and eliminating target portrait edge pixels using a reciprocating vertical line scanning method to obtain a portrait edge pixel eliminated image; mapping the portrait edge pixel eliminated image back to the GPU and performing a point primitive method for outlining the edges of the human portrait to obtain a human outline image. The present invention fully utilizes the characteristics of the GPU and CPU, uses a computational shader in conjunction with a variant nine-square grid to only compare the upper, lower, left, and right neighboring pixels, resulting in high processing efficiency, uses a vertical line scanning method for reciprocating scanning to achieve more accurate edge recognition, and uses a point primitive method for edge drawing and rendering to achieve a richer outlining effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1A schematic diagram of an embodiment of a method for drawing a human image according to the present invention; Figure 2 A schematic diagram of an embodiment of a portrait edge pixel extraction effect according to the present invention; Figure 3 A schematic diagram of an embodiment of a portrait edge outlining effect according to the present invention; Figure 4 A schematic diagram of an embodiment of a system for drawing a human image according to the present invention; Figure 5 The figure is a schematic diagram of an embodiment of a device for drawing a human image according to the present invention. DETAILED DESCRIPTION

[0017] The terms "first," "second," "third," "fourth," and so on (if any) in the description and claims of the present invention and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that shown or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, product, or apparatus.

[0018] Currently, existing technologies for edge data acquisition are mostly achieved through traditional edge detection algorithms, such as the classic "Sobel operator", which determines the existence of edges based on the gradient changes of image pixels. The calculated results can usually meet the target requirements, but at the same time there are some fatal flaws.

[0019] First, data accuracy. If the input original person image has a relatively clean background and a single color tone, the current algorithm will work fine. Otherwise, pseudo-edge data or even false noise data (which should not be considered as edges) will appear. This defect is determined by the basic algorithm principle of the Sobel operator.

[0020] Second, speed. The current algorithm requires a lot of edge auxiliary data. It not only needs to obtain pixel texture color, but also needs computing power to support the color data. Under the GPU rendering method, there will be countless repeated pixel color sampling and computing power, which will cause a huge waste of performance and reduce the overall rendering performance.

[0021] Third, the solution lacks advancements. Current algorithms typically rely on fragment shaders in the rendering pipeline, which are much less efficient than compute shaders. Compute shaders are GPU optimizations specifically developed for scenarios that prioritize computation over logic, and offer exceptionally high special effects.

[0022] In order to solve the above-mentioned defects in the prior art, the first aspect of the present invention provides a method for drawing a character image. For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , the method for drawing the character image includes: S100, obtaining a person image whose edges are to be outlined; in the present invention, the person image whose edges are to be outlined may include at least one target person, that is, the technical solution of the present invention can perform image outline processing for a single person or for multiple persons.

[0023] S200. Using a compute shader in a GPU, a computation is performed on each pixel of the person image, comparing the alpha channel values ​​of neighboring pixels above, below, and below, using a variant nine-grid convolution kernel, to obtain an initial edge pixel labeled image. In the present invention, edge data acquisition is performed directly using a compute shader and a variant nine-grid convolution kernel. A conventional nine-grid convolution kernel has nine, while the variant nine-grid has five. Four diagonal grids are removed, and only pixels corresponding to the four upper, lower, and left grids are detected. Diagonal detection is redundant; detection results from any of the upper, lower, and left grids are valid and can be used to determine edge characteristics. This approach directly reduces the computing power required for edge detection by half.

[0024] In an optional implementation of step S200 of the present invention, performing a computation shader on each pixel of the person image using a variant nine-square grid convolution kernel to compare alpha channel values ​​of upper, lower, left, and right neighboring pixels to obtain an initial edge pixel marked image includes: S201. For each pixel of the character image, the pixel itself is used as the center of the nine-square grid convolution kernel, and the color information of all pixels within the nine-square grid is obtained; in the present invention, the color information here mainly includes information of the four color channels of the pixel RGBA.

[0025] S202. Obtain the alpha channel value of the pixel itself and its neighboring pixels in the four directions of the upper, lower, left, and right from the color information of all pixels within the nine-square grid. In the present invention, when performing a comparison operation on the nine-square grid, only the neighboring pixels in the four directions of the upper, lower, left, and right of the pixel itself are compared, and the comparison data also only uses the alpha channel value of each pixel. The alpha channel value represents the opacity of the pixel. There will be an alpha value transition at the edge of the image, so based on this characteristic, it is possible to detect whether the pixel is an edge.

[0026] S203. Determine whether there is a transparency transition between the pixel itself and the neighboring pixels in the four directions of the pixel above, below, left, and right based on the alpha channel value. The alpha channel value of a pixel generally has two values ​​(0 and 1). When the alpha channel value is 1, the pixel is opaque, and when the alpha channel value is 0, the pixel is transparent. In some optional embodiments of the present invention, if the obtained alpha channel value also includes a decimal, an alpha channel value less than or equal to 0.2 is determined to be equivalent to 0, and an alpha channel value greater than 0.2 is determined to be equivalent to 1. The present invention only requires that a pixel itself has a transparency transition with at least one of its neighboring pixels above, below, left, and right to be determined as an edge pixel.

[0027] In the present invention, this step may include: obtaining the first alpha channel value of the pixel itself and determining whether the first alpha channel value is zero; if the first alpha channel value is zero, determining that the pixel itself is a non-edge pixel; if the first alpha channel value is non-zero, further determining whether the second alpha channel values ​​of the neighboring pixels in the four directions of the pixel itself are zero; if the second alpha channel value of the neighboring pixels in at least one direction is zero, determining that the pixel itself is an edge pixel; otherwise, determining that the pixel itself is a non-edge pixel. In this embodiment of the present invention, the transparency transition is mainly determined based on the pixel itself being non-transparent, and the outer edge of the character is mainly obtained. In another embodiment of the present invention, the transparency transition can also be determined based on the pixel itself being transparent to obtain the inner edge of the character. Of course, both methods can also be used simultaneously. Regardless of whether the pixel itself is transparent or non-transparent, as long as there is a transparency transition in the upper, lower, left, and right neighborhood, it is marked as an edge, so that the range of the inner and outer edges can be obtained.

[0028] S204: If there is a transparency transition between the pixel itself and its neighboring pixels in the four directions of the pixel, the pixel itself is marked as an edge pixel. In the technical solution of the present invention, edge pixel detection is performed in the GPU, mainly utilizing the parallelism of the GPU to efficiently complete the alpha channel threshold detection of "current pixel + neighboring pixels in the four directions of the pixel" and output the marking result.

[0029] In an exemplary embodiment of the present invention, the code for obtaining the initial edge pixel marked image may be as follows: ivec2 gid=ivec2(gl_GlobalInvocationID.xy); vec4 color=imageLoad(imgInput, gid); uint globalIndex=uint(fUbo.uTextureSize.x) * gl_GlobalInvocationID.y+ gl_GlobalInvocationID.x; ivec2 offsetArray[count]=ivec2[](ivec2(-0,-1) ,ivec2(-0,1),ivec2(-1,0),ivec2(1,0));vec4 result;result=imageLoad(imgInput,gid);if(result.a>floatOffset){outputBufferData[globalIndex]=ivec2(0,0);return;}for (int index=0;index<count;++index){result=imageLoad(imgInput,gid+offsetArray[index]);if(result.a> floatOffset){outputBufferData[globalIndex]=gid+ivec2(1, 1); return;}}.

[0030] S300, mapping the initial edge pixel marked image to a CPU, and screening and eliminating target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel eliminated image; in step S300 of the present invention, only transition pixels are marked, and the marked transition pixels are not all portrait edge pixels, so the initial edge pixel marked image needs to be processed. The processing method mainly involves scanning, sorting, and connecting edge data and eliminating isolated island data (data that cannot be connected into a closed curve). The principle of the vertical line scanning method of the present invention can be understood as performing a collision test on the edge of the character from left to right through a straight line in the vertical direction, and performing real-time recording and neighborhood analysis on the edge data in the order of collision. When the collision reaches the rightmost side of the character image, the collision test is repeated in the opposite direction. Similarly, after multiple back-and-forth collisions, the edge curves of each group can be obtained, and finally, all edge data in the character image that can form a closed figure are completely eliminated.

[0031] In an optional implementation of step S300 of the present invention, mapping the initial edge pixel marked image to a CPU, and screening and removing target portrait edge pixels from the initial edge pixel marked image using a reciprocating vertical line scanning method in the CPU to obtain a portrait edge pixel removed image includes: S301. For the initial edge pixel marked image, obtain the left and right scanning ranges based on the leftmost and rightmost edge pixel points in the initial edge pixel marked image; in the image, an object of any shape has a minimum rectangular outer frame, that is, there are two left and right endpoints. The present invention mainly limits the left and right movement range of the vertical line scanning line through the leftmost and rightmost edge pixel points.

[0032] S302, using the left and right scanning ranges as reciprocating limits and scanning the initial edge pixel mark image by moving one pixel step each time through vertical line scanning lines; in the present invention, the vertical scanning lines are used from left to right to perform collision scanning with the width of a single pixel as the moving step, which can continuously collide to produce pixel points on the edge curve of the image. Since the curve contour can be extended in the opposite direction, the scanning operation also needs to be performed back and forth until the current scanning point coincides with the starting scanning point or reaches the closing critical value, that is, the scanning of an edge curve is completed, and so on, the same applies to other edge curves.

[0033] That is, in the present invention, step S302 may specifically include: in the process of left and right scanning of the vertical line scanning line, each scan is performed from top to bottom and without repetition of the neighborhood analysis of one edge pixel point, and the connection relationship of each edge pixel point is established group by group; for each group of edge pixel points that can form a connection relationship, the position of the last edge pixel point coincides with the position of the first edge pixel point or the last edge pixel point cannot obtain adjacent edge pixels from all sides as a scanning cutoff condition, so as to scan and establish a connection relationship for the next group of edge pixel points; collect each group of edge pixel points that can form a connection relationship; perform closure detection on each group of edge pixel points to obtain a target edge pixel point set that can form a closed figure. Taking the example of obtaining four points A, B, C and D from a scan line from left to right, the neighborhood analysis process of the present invention can be understood as only analyzing A during the first neighborhood analysis. When the same scan line is scanned again from right to left and A, B, C and D are obtained, the neighborhood analysis will skip A and proceed to analyze B. Similarly, when scanning from left to right to A, B, C and D, neighborhood analysis will be performed on C again. The reciprocating scanning analysis method of the present invention can achieve accurate extraction of the edges of complex contours of portraits.

[0034] In the present invention, the method of performing closed detection on each group of edge pixel points may include: for each group of edge pixel points, obtaining the starting edge pixel point and the ending edge pixel point; calculating the pixel distance between the starting edge pixel point and the ending edge pixel point; if the pixel distance is less than or equal to a preset threshold, determining that the starting edge pixel point and the ending edge pixel point form a closed figure; if the pixel distance is greater than the preset threshold, determining that the starting edge pixel point and the ending edge pixel point do not form a closed figure. In the present invention, the closedness determination of the figure is mainly based on the determination between the starting edge pixel point and the ending edge pixel point. The distance calculation method can use Euclidean distance, and the size of the preset threshold can be set to 1-5 pixels. When the distance between the starting edge pixel point and the ending edge pixel point is less than the preset threshold, it can be considered that the edge pixel point set forms a closed figure.

[0035] S303, obtain the target edge pixel point set that can form a closed figure through the reciprocating scanning. The effect of the present invention of obtaining the target edge pixel point set of a closed figure through the reciprocating scanning is as follows: Figure 2As shown, in another optional embodiment of the present invention, the process of scanning from left to right and the process of scanning from right to left of the present invention can adopt opposite pixel neighborhood analysis methods. For example, when scanning from left to right, each scan adopts a top-to-bottom and non-repetitive neighborhood analysis of one edge pixel point, and the connection relationship of each edge pixel point is established group by group. When scanning from right to left, each scan adopts a bottom-to-top and non-repetitive neighborhood analysis of one edge pixel point, and the connection relationship of each edge pixel point is established group by group. By this means, the efficiency of acquiring edge pixels of simple contour portraits (with few contour bending curves) can be improved, and the number of reciprocating scans required can be reduced. The technical solution of the present invention can select a specific scanning method based on the required scanning accuracy.

[0036] S304: Remove all edge pixels that can form a closed figure from the initial edge pixel marked image to obtain a portrait edge pixel removed image. In the present invention, after obtaining the portrait edge pixels, the portrait edge pixels are removed to prepare for edge effect delineation.

[0037] S400: Mapping the portrait edge pixel-culled image back to the GPU, and performing portrait edge drawing on the portrait edge pixel-culled image in the GPU using point primitives to obtain a portrait outline image. Point primitive drawing uses points as units for drawing, packaging the outline effect into point units. This allows for rapid generation of different portrait outline images by simply preparing point units with different outline effects. Because point primitives encapsulate internal algorithms related to the hardware (GPU) driver, they are a common underlying black box algorithm, facilitating rapid deployment and adjustment.

[0038] In an optional embodiment of step S400 of the present invention, the portrait edge drawing of the portrait edge pixel culled image in the form of point primitives in the GPU includes: obtaining a coordinate set of culled pixels in the portrait edge pixel culled image; obtaining outlining characteristic parameters, the outlining characteristic parameters including outlining width, outlining color and outlining line style; using the coordinate set as vertex data of the point primitive and using the outlining characteristic parameters as outlining configuration to draw the portrait edge. An exemplary character outlining effect of the present invention can be as follows Figure 3 shown.

[0039] See also Figure 4 A second aspect of the present invention provides a system for outlining a human image, the system comprising: A character portrait acquisition module 10 is used to acquire a character image whose edges are to be outlined; The edge pixel preliminary marking module 20 is used to perform a comparison operation of alpha channel values ​​of upper, lower, left, and right neighboring pixels based on a variant of the nine-square grid convolution kernel on each pixel of the character image through a computational shader in the GPU to obtain an initial edge pixel marked image; A portrait edge pixel removal module 30 is configured to map the initial edge pixel marked image to a CPU, and to screen and remove target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel removed image; The portrait edge delineation module 40 is used to map the portrait edge pixel culled image back to the GPU, and perform portrait edge delineation on the portrait edge pixel culled image in the form of point primitives in the GPU to obtain a portrait delineation image.

[0040] In an optional implementation of the second aspect of the present invention, the edge pixel preliminary marking module includes: A color information acquisition unit is configured to use each pixel of the person image as the center of a nine-square grid convolution kernel and acquire color information of all pixels within the nine-square grid; an alpha channel value obtaining unit, configured to obtain, from the color information of all pixels within the nine-square grid, the alpha channel value of the pixel itself and of its neighboring pixels in four directions: above, below, left, and right; a transparency transition judging unit, configured to judge whether there is a transparency transition between the pixel itself and the neighboring pixels in four directions of the pixel above, below, left and right based on the alpha channel value; The edge pixel marking unit is configured to mark the pixel itself as an edge pixel point if there is a transparency transition between the pixel itself and the neighboring pixels in the four directions of the pixel itself, above, below, left, and right.

[0041] In an optional implementation of the second aspect of the present invention, the transparent transition judgment unit includes: a first alpha channel value determination subunit, configured to obtain a first alpha channel value of the pixel itself and determine whether the first alpha channel value is zero; a first determination subunit, configured to determine that the pixel itself is a non-edge pixel if the first alpha channel value is zero; a second alpha channel value determination subunit, configured to further determine whether the second alpha channel values ​​of the neighboring pixels in four directions of the pixel itself, above, below, left, and right, are zero if the first alpha channel value is non-zero; The second determination subunit is configured to determine that the pixel itself is an edge pixel if the second alpha channel value of the neighboring pixels in at least one direction is zero; otherwise, determine that the pixel itself is a non-edge pixel.

[0042] In an optional implementation of the second aspect of the present invention, the portrait edge pixel removal module includes: A scanning range acquiring unit, configured to acquire left and right scanning ranges based on the leftmost and rightmost edge pixel points in the initial edge pixel marked image; A reciprocating scanning unit, configured to scan the initial edge pixel mark image by moving one pixel step each time using the left and right scanning ranges as reciprocating limits through vertical line scanning lines; a target edge pixel point set acquisition unit, configured to acquire a target edge pixel point set capable of forming a closed figure through the reciprocating scanning; The target edge pixel elimination unit is used to eliminate all the edge pixel points that can form a closed figure from the initial edge pixel marked image to obtain a portrait edge pixel eliminated image.

[0043] In an optional implementation of the second aspect of the present invention, the reciprocating scanning unit includes: a neighborhood analysis subunit, configured to perform a non-repeated neighborhood analysis on one edge pixel point each time the vertical line scan line is scanned left and right, and to establish a connection relationship between the edge pixels in groups; a group change judgment subunit, configured to, for each set of edge pixel points that can form a connection relationship, use the overlap between the positions of the last edge pixel point and the first edge pixel point or the inability of the last edge pixel point to obtain adjacent edge pixels from all four sides as a scanning cutoff condition, so as to proceed with scanning and establishing a connection relationship for the next set of edge pixel points; A set collecting subunit, configured to collect sets of edge pixel points that can form a connection relationship; The closed detection subunit is used to perform closed detection on each group of edge pixel point sets to obtain a target edge pixel point set that can form a closed figure.

[0044] In an optional embodiment of the second aspect of the present invention, the closure detection subunit includes: A starting and ending edge pixel acquisition subunit acquires a starting edge pixel point and an ending edge pixel point for each set of edge pixel points; a pixel distance calculation sub-unit, configured to calculate the pixel distance between the starting edge pixel point and the ending edge pixel point; The graphic closure determination subunit is configured to determine that the starting edge pixel point and the ending edge pixel point form a closed graphic if the pixel distance is less than or equal to a preset threshold; and to determine that the starting edge pixel point and the ending edge pixel point do not form a closed graphic if the pixel distance is greater than the preset threshold.

[0045] In an optional implementation of the second aspect of the present invention, the portrait edge delineation module includes: A coordinate set acquisition unit, configured to acquire a coordinate set of pixels to be removed from the portrait edge pixel removal image; A drawing characteristic acquisition unit, configured to acquire drawing characteristic parameters, wherein the drawing characteristic parameters include drawing width, drawing color, and drawing line type; The edge drawing unit is used to draw the edge of the portrait using the coordinate set as vertex data of the point primitive and using the drawing characteristic parameters as the drawing configuration.

[0046] Figure 5 This is a schematic structural diagram of a device for delineating a person's image provided by an embodiment of the present invention. The device for delineating a person's image may vary significantly due to different configurations or performance. The device may include one or more processors 50 (central processing units, CPUs) (e.g., one or more processors) and memory 60, and one or more storage media 70 (e.g., one or more mass storage devices) for storing applications or data. The memory and storage media may be either transient or persistent storage. The program stored on the storage medium may include one or more modules (not shown), each of which may include a series of instruction operations on the device for delineating a person's image. Furthermore, the processor may be configured to communicate with the storage medium to execute the series of instruction operations on the storage medium on the device for delineating a person's image.

[0047] The device for drawing a person image of the present invention may further include one or more power supplies 80, one or more wired or wireless network interfaces 90, one or more input and output interfaces 100, and / or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 5 The structure of the device for drawing a human image shown does not constitute a limitation on the device for drawing a human image, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0048] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the character image drawing system.

[0049] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system or system or unit can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.

[0050] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the 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 for causing a computer device (which can be a personal computer, a device for drawing a person's image, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0051] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for drawing a character image, characterized in that: include: Obtaining a person image whose edges are to be outlined; In the GPU, a computation shader is used to perform a comparison operation on the alpha channel values ​​of the upper, lower, left, and right neighboring pixels of each pixel of the character image based on a variant nine-square grid convolution kernel to obtain an initial edge pixel marked image; Mapping the initial edge pixel marked image into a CPU, and screening and eliminating target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel eliminated image; The portrait edge pixel culled image is mapped back to the GPU, and the portrait edge drawing with a characteristic is performed on the portrait edge pixel culled image in the form of point primitives in the GPU to obtain a character outline image.

2. The method for drawing a character image according to claim 1, wherein: The step of performing a comparison operation of alpha channel values ​​of upper, lower, left, and right neighboring pixels based on a variant nine-square grid convolution kernel on each pixel of the character image by a computation shader in the GPU to obtain an initial edge pixel marked image includes: For each pixel of the person image, the pixel itself is used as the center of the nine-square grid convolution kernel, and the color information of all pixels within the nine-square grid is obtained; Obtaining, from the color information of all pixels within the nine-square grid, the alpha channel value of the pixel itself and of each of its neighboring pixels in four directions: above, below, left, and right; Determine whether there is a transparency transition between the pixel itself and the neighboring pixels in four directions of the pixel itself, above, below, left, and right based on the alpha channel value; If there is a transparency transition between the pixel itself and the neighboring pixels in the four directions of the pixel itself, the pixel itself is marked as an edge pixel point.

3. The method for drawing a character image according to claim 2, wherein: The determining, based on the alpha channel value, whether there is a transparency transition between the pixel itself and the neighboring pixels in four directions of the pixel itself, above, below, left, and right includes: Obtaining a first alpha channel value of the pixel itself, and determining whether the first alpha channel value is zero; If the first alpha channel value is zero, the pixel itself is determined to be a non-edge pixel; If the first alpha channel value is non-zero, further determining whether the second alpha channel values ​​of the neighboring pixels in the four directions of the pixel itself are zero; If the second alpha channel value of the neighboring pixels in at least one direction is zero, the pixel itself is determined to be an edge pixel point; otherwise, the pixel itself is determined to be a non-edge pixel point.

4. The method for drawing a human figure according to claim 1, wherein: Mapping the initial edge pixel marked image to a CPU, and screening and removing target portrait edge pixels from the initial edge pixel marked image by a reciprocating vertical line scanning method in the CPU to obtain a portrait edge pixel removed image includes: For the initial edge pixel marked image, obtaining left and right scanning ranges based on the leftmost and rightmost edge pixel points in the initial edge pixel marked image; Using the left and right scanning ranges as reciprocating limits and scanning the initial edge pixel mark image by moving one pixel step each time through vertical line scanning lines; Obtaining a target edge pixel point set capable of forming a closed figure through the reciprocating scanning; All the edge pixel points that can form a closed figure are removed from the initial edge pixel marked image to obtain a portrait edge pixel removed image.

5. The method for drawing a human figure according to claim 4, wherein: The scanning of the initial edge pixel mark image by moving one pixel step each time using the left and right scanning ranges as reciprocating limits and vertical line scanning lines comprises: In the process of left and right scanning of the vertical line scanning line, each time scanning from top to bottom and without repetition of the neighborhood analysis of one edge pixel point, and establishing the connection relationship of each edge pixel point group by group; For each set of edge pixel points that can form a connection relationship, the last edge pixel point coincides with the first edge pixel point or the last edge pixel point cannot obtain adjacent edge pixels from all four sides as a scanning cutoff condition, so as to proceed with scanning and establishing a connection relationship for the next set of edge pixel points; Collecting the edge pixel sets of each group that can form a connection relationship; A closed detection is performed on each group of edge pixel point sets to obtain a target edge pixel point set that can form a closed figure.

6. The method for drawing a human image according to claim 5, wherein: The performing closed detection on each group of edge pixel points includes: For each set of edge pixel points, obtaining a starting edge pixel point and an ending edge pixel point; Calculating the pixel distance between the starting edge pixel point and the ending edge pixel point; If the pixel distance is less than or equal to a preset threshold, determining that the starting edge pixel point and the ending edge pixel point form a closed figure; If the pixel distance is greater than the preset threshold, it is determined that the starting edge pixel point and the ending edge pixel point do not form a closed figure.

7. The method for drawing a human figure according to claim 1, wherein: The portrait edge drawing of outlining the portrait edge pixel culling image in the form of point primitives in the GPU includes: Obtaining a coordinate set of pixels to be removed from the portrait edge pixel removal image; Acquire outline characteristic parameters, wherein the outline characteristic parameters include outline width, outline color, and outline line style; The edge of the portrait is drawn using the coordinate set as vertex data of the point primitive and the drawing characteristic parameters as the drawing configuration.

8. A system for outlining a human image, characterized in that: The character image drawing system includes: A character portrait acquisition module is used to acquire a character image whose edges are to be outlined; An edge pixel preliminary marking module is used to perform a comparison operation of alpha channel values ​​of upper, lower, left, and right neighboring pixels based on a variant of a nine-square grid convolution kernel on each pixel of the person image through a computational shader in a GPU to obtain an initial edge pixel marked image; a portrait edge pixel removal module, configured to map the initial edge pixel marked image to a CPU, and screen and remove target portrait edge pixels from the initial edge pixel marked image in the CPU using a reciprocating vertical line scanning method to obtain a portrait edge pixel removed image; The portrait edge delineation module is used to map the portrait edge pixel culled image back to the GPU, and perform portrait edge drawing with characteristic features on the portrait edge pixel culled image in the form of point primitives in the GPU to obtain a character delineation image.

9. A device for drawing a human image, characterized in that: The device for drawing a human image comprises: 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 circuit; The at least one processor calls the instructions in the memory to enable the device for drawing a human image to execute the method for drawing a human image according to any one of claims 1 to 7.

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