CN114820873B - Sketch regularization method, device and medium based on painting - Google Patents

Sketch regularization method, device and medium based on painting Download PDF

Info

Publication number
CN114820873B
CN114820873B CN202210522373.XA CN202210522373A CN114820873B CN 114820873 B CN114820873 B CN 114820873B CN 202210522373 A CN202210522373 A CN 202210522373A CN 114820873 B CN114820873 B CN 114820873B
Authority
CN
China
Prior art keywords
pixel
triangle
line
black
sketch
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210522373.XA
Other languages
Chinese (zh)
Other versions
CN114820873A (en
Inventor
冯桂焕
骆红艳
姜佳玮
王睿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University
Original Assignee
Nanjing University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University filed Critical Nanjing University
Priority to CN202210522373.XA priority Critical patent/CN114820873B/en
Publication of CN114820873A publication Critical patent/CN114820873A/en
Application granted granted Critical
Publication of CN114820873B publication Critical patent/CN114820873B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/80Creating or modifying a manually drawn or painted image using a manual input device, e.g. mouse, light pen, direction keys on keyboard

Abstract

The invention discloses a sketch regularization method, a device and a medium based on painting, wherein the sketch is triangulated to obtain a triangle set, and the triangle set is automatically painted by using randomly generated colors based on a region growing method, wherein the color of each region is unique; modifying the automatically painted triangle set according to the first input instruction; deleting the corresponding strokes according to the second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map; and generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a Bezier curve, and obtaining a hierarchical picture by using a backtracking method. The invention realizes the simplification and regularization of the strokes of the existing sketch pictures through the interactive clicking of the user, so as to facilitate the subsequent redrawing, color filling, animation processing and the like of the vector diagram, and improve the processing efficiency of the user.

Description

Sketch regularization method, device and medium based on painting
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a sketch regularization method, a sketch regularization device and a sketch regularization medium based on painting.
Background
With the advancement and development of technology, a variety of applications can be installed on the mobile terminal, wherein the image processing application is very popular with users, and the users can adjust some features in the sketch to be processed through the image processing application, for example, color a specific area in the sketch to be processed. However, when the draft is processed at present, when the processed draft needs to be modified, the operation is troublesome, and the processing efficiency of the user needs to be improved.
Disclosure of Invention
The present invention has been made to solve the above-mentioned problems occurring in the prior art. Therefore, a method, a device and a medium for regularizing a sketch based on painting are needed, and the method for simplifying and regularizing strokes of the existing sketch picture can be quickly realized through interactive clicking of a user, so that the subsequent redrawing, color filling, animation processing and the like of a vector diagram can be conveniently realized, and the processing efficiency of the user can be improved.
According to a first aspect of the present invention, there is provided a sketch regularization method based on painting, the method comprising: triangulating the sketch to obtain a triangle set, and automatically painting the triangle set by using randomly generated colors based on a region growing method, wherein the color of each region is unique; modifying the automatically colored triangle set according to the first input instruction; based on the modified triangle set, deleting the corresponding strokes according to a second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map; and generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a Bezier curve, and obtaining a hierarchical picture by using a backtracking method.
Further, triangulating the sketch to obtain a triangle set includes: and carrying out triangulation on the sketch to generate a triangular convex hull, wherein the triangular convex hull comprises a pixel point set of the sketch to extract the outline of the outermost layer of the triangular convex hull to obtain a triangular set.
Further, the automatically painting the triangle set with randomly generated colors based on the region growing method includes: determining a seed triangle, wherein the seed triangle is a triangle with the largest radius of a circumscribed circle in the triangle set; taking the seed triangles as starting points, respectively taking each triangle as a vertex, and generating a Thiessen polygon map, wherein when two triangles are adjacent, the two corresponding vertices in the map are connected; performing expansion operation according to the determined seed triangles; the expanding operation comprises the following steps: color expansion is carried out on the seed triangle to the adjacent triangle, when the side length of the adjacent side is larger than a preset side length parameter, the color is expanded, otherwise, the expansion in the direction is stopped; when the expansion of one area is finished, continuously finding a next seed triangle in all the non-painted triangle sets and repeating the expansion operation until all the triangles are painted or none of the triangles meet the condition that the side length of the adjacent side of the adjacent triangle is larger than a preset side length parameter; in the process of carrying out the expansion operation, recording the color _ flow of each triangle in the same area compared with the seed triangle; the color _ flow is defined as: any one triangle belonging to the same region has the smallest flow in the Thiessen polygon and between the seed triangles.
Further, the modifying the automatically painted triangle set according to the first input instruction includes: and changing the color of the determined area of the selected seed triangle according to the selected seed triangle and/or taking the triangle as a new seed triangle according to any selected triangle, if the color _ flow from a certain triangle to the new seed triangle is larger than the original color _ flow, performing expansion operation, and otherwise, stopping the expansion operation.
Further, based on the modified triangle set, deleting the corresponding strokes according to a second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map, including: obtaining a corresponding pixel matrix based on the modified triangle set; the second input instruction comprises a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are different, and if the second input instruction is the deleted line, the colors of the two sides of the line are the same; searching the whole pixel matrix, and deleting the black lines which are left and right or have the same upper and lower colors and are not black lines; changing any one middle pixel point from the pixel points which are different in left and right colors or upper and lower colors and are not black into black, and supplementing missing lines; converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, wherein a pixel point q in the subset of the black pixel blocks needs to satisfy: the difference between the distances from q to p1 and p2 is smaller than a preset fixed threshold, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black; the simplified pixel matrix is determined from a subset of the black pixel blocks.
Further, the generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a bezier curve, and obtaining a hierarchical picture by using a backtracking method includes: vectorizing the simplified pixel matrix to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines; traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added into the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added into the line, and finally, when all the black pixel points in the simplified pixel matrix are accessed, all the lines are extracted, and a line set is obtained. Fitting each line in the line set by using a Bezier curve; traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel point has a hierarchical structure; and layering the original sketch according to the hierarchical structure to obtain a layered picture.
According to a second aspect of the present invention, there is provided a sketch regularization device based on coloring, characterized in that the device includes: the automatic coloring module is configured for triangulating the sketch to obtain a triangle set and automatically coloring the triangle set by using randomly generated colors based on a region growing method, wherein the color of each region is unique; the interactive painting and region merging module is configured to modify the automatically painted triangle set according to a first input instruction; the stroke simplifying and grouping module based on painting is configured to delete corresponding strokes according to a second input instruction based on the modified triangle set, then supplement missing strokes, and finally simplify coarse-grained lines into the width of one pixel to obtain a simplified pixel map; and the normalized picture generating module is configured to generate a vectorization line network according to the simplified pixel map, fit each vectorization line in the vectorization line network by using a Bezier curve, and obtain a hierarchical picture by using a backtracking method.
Further, the auto-paint module is further configured to: and carrying out triangulation on the sketch to generate a triangular convex hull, wherein the triangular convex hull comprises a pixel point set of the sketch to extract the outline of the outermost layer of the triangular convex hull to obtain a triangular set.
Further, the auto-paint module is further configured to: determining a seed triangle, wherein the seed triangle is a triangle with the largest radius of a circumscribed circle in the triangle set; taking the seed triangles as starting points, respectively taking each triangle as a vertex, and generating a Thiessen polygon map, wherein when two triangles are adjacent, the two corresponding vertices in the map are connected; performing expansion operation according to the determined seed triangles; the expanding operation comprises: color expansion is carried out on the seed triangle to the adjacent triangle, when the side length of the adjacent side is larger than a preset side length parameter, the color is expanded, otherwise, the expansion in the direction is stopped; when the expansion of one area is finished, continuously finding a next seed triangle in all the non-painted triangle sets and repeating the expansion operation until all the triangles are painted or none of the triangles meet the condition that the side length of the adjacent side of the adjacent triangle is larger than a preset side length parameter; in the process of carrying out the expansion operation, recording the color _ flow of each triangle in the same area compared with the seed triangle; the color _ flow is defined as: any one triangle belonging to the same region has the smallest flow in the Thiessen polygon and between the seed triangles.
Further, the interactive painting and region merging module is further configured to: and changing the color of the determined area of the selected seed triangle according to the selected seed triangle and/or taking the triangle as a new seed triangle according to any selected triangle, if the color _ flow from one triangle to the new seed triangle is larger than the original color _ flow, performing expansion operation, and otherwise, stopping the expansion operation.
Further, the paint-based stroke reduction and grouping module is further configured to: obtaining a corresponding pixel matrix based on the modified triangle set; the second input instruction comprises a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are different, and if the second input instruction is the deleted line, the colors of the two sides of the line are the same; searching the whole pixel matrix, and deleting the black lines which are left and right or have the same upper and lower colors and are not black lines; changing any one middle pixel point from the pixel points which are different in left and right colors or upper and lower colors and are not black into black, and supplementing missing lines; converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, wherein pixel points q in the subset of the black pixel blocks need to meet the following requirements: the difference between the distances from q to p1 and p2 is smaller than a preset fixed threshold, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black; the simplified pixel matrix is determined from a subset of the black pixel tiles.
Further, the regularized picture generation module is further configured to: vectorizing the simplified pixel matrix to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines; traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added into the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added into the line, and finally, when all the black pixel points in the simplified pixel matrix are accessed, all the lines are extracted, and a line set is obtained. Fitting each line in the line set by using a Bezier curve; traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel has a hierarchical structure; and layering the original draft according to the hierarchical structure to obtain a layered picture.
Further, a non-transitory computer-readable storage medium is provided that stores instructions that, when executed by a processor, perform a method according to various embodiments of the present invention.
According to the sketch regularization method, the device and the medium based on the color painting of the various schemes of the invention, a user can change the color of one area by simply clicking for several times, and can quickly delete, sort and keep the disordered lines of the sketch. Therefore, the user can simplify the sketch only by clicking the mouse for a plurality of times, the workload of the user is greatly reduced, and the difficulty of picture processing is reduced. In addition, strokes in the sketch are smoothed, picture regularization is quickly realized through line vectorization, a new hierarchical structure is generated through layering, and secondary editing, modification, animation and other processing can be conveniently carried out on the existing picture.
Drawings
In the drawings, which are not necessarily drawn to scale, like reference numerals may describe similar components in different views. Like reference numerals having letter suffixes or different letter suffixes may represent different instances of similar components. The drawings illustrate various embodiments generally, by way of example and not by way of limitation, and together with the description and claims serve to explain the embodiments of the invention. The same reference numbers will be used throughout the drawings to refer to the same or like parts, where appropriate. Such embodiments are illustrative, and are not intended to be exhaustive or exclusive embodiments of the present apparatus or method.
FIG. 1 illustrates a flow diagram of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 2 illustrates a flow diagram of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 3 illustrates a flow diagram of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 4 illustrates a flow chart of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 5 illustrates a flow diagram of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 6 illustrates a flow chart of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 7 illustrates a flow chart of a paint color based sketch regularization method according to an embodiment of the present invention;
FIG. 8 shows a block diagram of a sketch regularization device based on painting according to an embodiment of the present invention and
FIG. 9 shows a schematic diagram of a sketch regularization device based on painting according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following detailed description of the embodiments of the present invention is provided in connection with the accompanying drawings and the specific embodiments, but not intended to limit the invention. The order in which the various steps described herein are described as examples should not be construed as a limitation if there is no requirement for a context relationship between each other, and one skilled in the art would know that sequential adjustments may be made without destroying the logical relationship between each other, rendering the overall process impractical.
Referring to fig. 1, fig. 1 shows a flowchart of a sketch regularization method based on color application according to an embodiment of the present invention. The method comprises the following steps:
step S100, triangulating the sketch to obtain a triangle set, and automatically painting the triangle set by using randomly generated colors based on a region growing method, wherein the color of each region is unique. It should be noted that the "sketch" described herein may be a sketch input by a user, for example, a user input.
And S200, modifying the automatically painted triangle set according to the first input instruction. Wherein the first input instruction is typically input by a user. This step may be implemented in an interactive painting and region merging module. The interactive painting and region merging module is an interactive interface which can provide users with an interactive mode, and the users can change the color of a certain region by clicking and selecting the color. If the user wants to retain a stroke, the colors of the two sides of the stroke are set to different colors. If the user wants to delete a certain stroke, it is set to the same color. The interactive interface mode includes a keyboard and mouse mode, a touch input mode, and the like, which is not limited in this embodiment.
And S300, based on the modified triangle set, deleting the corresponding strokes according to a second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map.
And S400, generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a Bezier curve, and obtaining a hierarchical picture by using a backtracking method. The hierarchical picture can rapidly split the sketch into a plurality of parts, so that the existing picture can be conveniently subjected to secondary editing, modification, animation and other processing, and the sketch processing efficiency is improved.
In some embodiments, referring to fig. 2, fig. 2 is a flowchart illustrating a sketch regularization method based on color painting according to an embodiment of the present invention, where triangulating the sketch to obtain a triangle set includes:
step S1001, carrying out triangulation on a sketch to generate a triangular convex hull, wherein the triangular convex hull comprises a pixel point set of the sketch;
step S1002, extracting the outline of the outermost layer of the triangular convex hull to obtain a triangular set.
In some embodiments, referring to fig. 3, fig. 3 is a flowchart illustrating a sketch regularization method based on color painting, which performs automatic color painting on the triangle set by using randomly generated colors according to an embodiment of the present invention, and includes:
step S101, determining a seed triangle, wherein the seed triangle is a triangle with the largest radius of the circumscribed circle in the triangle set;
and S102, taking the seed triangles as starting points, respectively taking each triangle as a vertex, and generating a Thiessen polygon map, wherein when two triangles are adjacent in the Thiessen polygon map, the two corresponding vertices in the map are connected.
Step S103, performing expansion operation according to the determined seed triangles; the expanding operation comprises: color expansion is carried out on the seed triangle to the adjacent triangle, when the side length of the adjacent side is larger than a preset side length parameter, the color is expanded, otherwise, the expansion in the direction is stopped; in the process of carrying out the expansion operation, recording the color _ flow of each triangle in the same area compared with the seed triangle; the color _ flow is defined as: any one triangle belonging to the same region has the smallest flow in the Thiessen polygon and between the seed triangles.
And step S104, after the expansion of one region is finished, continuously finding the next seed triangle in all the uncolored triangle sets and repeating the expansion operation until all the triangles are colored or no triangles meet the condition that the side length of the adjacent sides of the adjacent triangles is larger than a preset side length parameter.
Illustratively, first, the user uploads a rough sketch for subsequent processing. The system performs Delaunay triangulation on the sketch to generate a triangular convex hull which comprises a pixel point set of the complete sketch. But the triangular convex hull generated at this time includes the part other than the outermost outline of the sketch. And extracting the outline of the outermost layer of the sketch by using a Delauany non-convex hull extraction algorithm to obtain a proper triangle set for subsequent processing.
In some embodiments, the modifying the automatically painted triangle set according to the first input instruction includes: and changing the color of the determined area of the selected seed triangle according to the selected seed triangle and/or taking the triangle as a new seed triangle according to any selected triangle, if the color _ flow from one triangle to the new seed triangle is larger than the original color _ flow, performing expansion operation, and otherwise, stopping the expansion operation.
The interactive painting provides a user with a way to modify the color of the picture region and also provides a basis for subsequent region merging. When a user wants to retain a line and the color of both sides of the line is the same, the color of one side can be temporarily modified. When a user wants to delete a certain line and the colors of the two sides of the line are different, the colors of the two sides of the line can be modified into the same color. In the operation process, whether the colors of the two sides of the line are equal is checked, and if the colors of the two sides of the line are equal, the line is deleted. The step provides a mode for deleting, sorting and keeping the disordered lines of the sketch for the user, and is simple and clear and convenient to operate.
In some embodiments, referring to fig. 4, fig. 4 is a flowchart illustrating a sketch regularization method based on color painting according to an embodiment of the present invention, where based on the modified triangle set, the corresponding strokes are deleted according to the second input instruction, then missing strokes are supplemented, and finally a coarse-grained line is simplified to a width of one pixel, so as to obtain a simplified pixel map, where the method includes:
step S301, based on the modified triangle set, a corresponding pixel matrix is obtained.
Step S302, the second input instruction includes a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are made different, and if the second input instruction is the deleted line, the colors of the two sides of the line are made the same.
Step S303, searching the whole pixel matrix, and deleting the black lines which are the same in left and right or upper and lower colors and are not the black lines; and changing any one of the middle pixel points which are different in left and right or upper and lower colors and are not black into black to supplement the missing lines.
Step S304, converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, where a pixel point q in the subset of black pixel blocks needs to satisfy: the difference of the distances from q to p1 and p2 is smaller than a preset fixed threshold value, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black.
In step S305, a simplified pixel matrix is determined according to the subset of the black pixel blocks.
Referring to FIG. 5, FIG. 5 is a flow chart illustrating a sketch regularization method based on coloring according to an embodiment of the invention. Firstly, processing a user color coating result input in the last step, converting the result into a pixel matrix, searching the whole pixel matrix according to the principle that the colors of two sides of a line are different if the line is to be reserved and the colors of two sides of the line are the same if the line is to be deleted, and regarding a black line as a redundant line and deleting the line, wherein the left side and the right side or the upper side and the lower side of the black line are the same in color and are not black lines; any middle pixel point of the pixel points which are different in left and right colors or in upper and lower colors and are not black is changed into black, and missing lines are supplemented, so that the picture has no redundant lines and is complete. Then, the line of the sketch may have a condition that the line is stacked due to multiple strokes of the same stroke, so that the line is too thick, and therefore, the line needs to be refined, and the thick line needs to be converted into a line structure with a single pixel width. This step converts the pixel matrix processed in the previous step into a binary pixel matrix, thereby extracting a subset of all black pixel blocks, i.e., the refined lines. Wherein, pixel point q in the subset needs to satisfy three point conditions, and the difference between the distances from q to p1 and p2 is less than a fixed threshold, and secondly, the colors of p1 and p2 are different, and thirdly, the line pigment connecting q to p1 and q to p2 can only be black. Thereby extracting simplified lines according to the three-point rule.
In some embodiments, referring to fig. 6, fig. 6 is a flowchart illustrating a sketch regularization method based on color painting according to an embodiment of the present invention, where the generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a bezier curve, and obtaining a hierarchical picture by using a backtracking method includes:
step S401, vectorizing the simplified pixel matrix, and generating a topological graph g = (V, E) of all strokes, where V represents all nodes and E represents all lines;
step S402, traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added to the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added to the line, finally, when all the black pixel points in the simplified pixel matrix are accessed, all the lines are extracted, and a line set is obtained.
Step S403, fitting each line in the line set by using a Bezier curve;
step S404, traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel point has a hierarchical structure; and layering the original sketch according to the hierarchical structure to obtain a layered picture.
After the picture with the hierarchical structure information is obtained according to the steps, the pixel points on the same level can be colored quickly, different levels of the sketch can be extracted, and follow-up movement, video making and other work are facilitated.
Referring to fig. 7, in some embodiments, fig. 7 shows a flow chart of a sketch regularization method based on paint color according to an embodiment of the present invention. Vectorizing the simplified pixel matrix generated in the previous step to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines. And traversing the whole pixel matrix by using a minimum spanning tree algorithm (MST), and adding all pixel points into edge. When the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added into the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added into the line, and finally when all the black pixel points in the pixel matrix are accessed, all the line sets can be extracted. And then, fitting the line set obtained in the previous step by using a Bezier curve to smoothen the lines extracted in the previous step. And finally, traversing the whole pixel matrix by using a backtracking flow-fill algorithm. And giving each newly visited white pixel a new hierarchical structure, recursively traversing surrounding pixels, stopping visiting if a black pixel is encountered, and giving the same hierarchical structure if a white pixel which is not visited is encountered. Finally, all points in the pixel matrix are traversed, and each pixel point has its hierarchical information. Finally, the original drawing can be layered according to the layer information, and the finally input draft is converted into information with a hierarchical structure.
It should be noted that the Flood-fill algorithm is often used in the field of color filling. The central idea of the algorithm is that for an input two-dimensional matrix, the two-dimensional matrix is expanded from a certain point to the periphery until the position can not be expanded any more. The pixel matrix of the input picture is abstracted into the traversal problem of the picture, the filling of the colors is realized, the same color is in the same layer, and the different colors are in different layers.
Referring to fig. 8, fig. 8 is a structural diagram of a sketch regularization device based on color application according to an embodiment of the present invention. The device comprises:
an automatic coloring module 801 configured to triangulate a sketch to obtain a triangle set, and perform automatic coloring on the triangle set by using a randomly generated color based on a region growing method, wherein the color of each region is unique;
an interactive painting and region merging module 802 configured to modify the automatically painted triangle set according to a first input instruction;
the stroke simplifying and grouping module 803 based on painting is configured to delete corresponding strokes according to a second input instruction based on the modified triangle set, then supplement missing strokes, and finally simplify coarse-grained lines into the width of one pixel to obtain a simplified pixel map;
a regularization picture generation module 804 configured to generate a vectorization line network according to the simplified pixel map, fit each vectorization line in the vectorization line network by using a bezier curve, and obtain a hierarchical picture by using a backtracking method.
Referring to fig. 9, in some embodiments, fig. 9 illustrates a schematic diagram of a sketch regularization device based on painting according to an embodiment of the present invention. When the painted sketch regularization device is specifically implemented, the painted sketch regularization device is connected with a user interaction module, the user interaction module comprises an operation module and a display module, the operation mode of the operation module comprises mouse click interaction, and a mouse can be displayed in the display module. The system comprises an automatic painting module based on Delaunay triangulation, an interactive painting and region merging module, a stroke simplifying and grouping module based on painting and a regularized picture generating module, wherein the four modules are connected with a user interaction module. The automatic coloring module based on Delaunay triangulation is mainly used for performing Delaunay triangulation on an input sketch, and the obtained triangles are automatically colored by using randomly generated colors by using a region growing algorithm. Wherein the color of each region is unique. The interactive painting and area merging module provides an interactive interface for a user, and the user can change the color of a certain area by clicking and selecting the color. If the user wants to retain a stroke, the colors of the two sides of the stroke are set to different colors. If the user wants to delete a certain stroke, it is set to the same color. The painting-based stroke simplification and grouping module is divided into three steps based on a painting result input by a user, firstly, strokes which the user wants to delete are deleted, secondly, missing strokes in an original image are supplemented, and finally, coarse-grained lines are simplified into the width of one pixel. The normalized picture generation module comprises three steps, namely generating a vectorization line network according to a simplified pixel graph obtained by stroke simplification, fitting vectorization lines by Bezier curves, and finally obtaining a hierarchical picture by using a backtracking flow-file algorithm, wherein the original picture can be split into a plurality of parts.
In some embodiments, the auto-paint module is further configured to: and carrying out triangulation on the sketch to generate a triangular convex hull, wherein the triangular convex hull comprises a pixel point set of the sketch, and the outermost layer outline of the triangular convex hull is extracted to obtain a triangular set.
In some embodiments, the auto-paint module is further configured to: determining a seed triangle, wherein the seed triangle is a triangle with the largest radius of a circumscribed circle in the triangle set; taking the seed triangles as starting points, respectively taking each triangle as a vertex, and generating a Thiessen polygon map, wherein in the Thiessen polygon map, when two triangles are adjacent, two corresponding vertices in the map are connected; performing expansion operation according to the determined seed triangles; the expanding operation comprises: color expansion is carried out on the seed triangle to the adjacent triangle, when the side length of the adjacent side is larger than a preset side length parameter, the color is expanded, otherwise, the expansion in the direction is stopped; after the expansion of one area is finished, continuously finding the next seed triangle in all the uncolored triangle sets and repeating the expansion operation until all the triangles are colored or no triangles meet the condition that the side length of the adjacent sides of the adjacent triangles is larger than a preset side length parameter; in the process of carrying out the expansion operation, recording the color _ flow of each triangle in the same area compared with the seed triangle; the color _ flow is defined as: any one triangle belonging to the same region has the smallest flow in the Thiessen polygon and between the seed triangles.
In some embodiments, the interactive painting and region merging module is further configured to: and changing the color of the determined area of the selected seed triangle according to the selected seed triangle and/or taking the triangle as a new seed triangle according to any selected triangle, if the color _ flow from one triangle to the new seed triangle is larger than the original color _ flow, performing expansion operation, and otherwise, stopping the expansion operation.
In some embodiments, the paint-based stroke reduction and grouping module is further configured to: obtaining a corresponding pixel matrix based on the modified triangle set; the second input instruction comprises a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are different, and if the second input instruction is the deleted line, the colors of the two sides of the line are the same; searching the whole pixel matrix, and deleting the black lines which are left and right or have the same upper and lower colors and are not the black lines; changing any one middle pixel point from the pixel points which are different in left and right colors or upper and lower colors and are not black into black, and supplementing missing lines; converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, wherein a pixel point q in the subset of the black pixel blocks needs to satisfy: the difference between the distances from q to p1 and p2 is smaller than a preset fixed threshold value, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black; the simplified pixel matrix is determined from a subset of the black pixel tiles.
In some embodiments, the regularized picture generation module is further configured to: vectorizing the simplified pixel matrix to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines; traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added into the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added into the line, and finally, when all the black pixel points in the simplified pixel matrix are accessed, all the lines are extracted, and a line set is obtained. Fitting each line in the line set by using a Bezier curve; traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel has a hierarchical structure; and layering the original sketch according to the hierarchical structure to obtain a layered picture.
Embodiments of the present invention also provide a non-transitory computer readable medium storing instructions that, when executed by a processor, perform a method according to any of the embodiments of the present invention.
Moreover, although exemplary embodiments have been described herein, the scope thereof includes any and all embodiments based on the present invention with equivalent elements, modifications, omissions, combinations (e.g., of various embodiments across), adaptations or alterations. The elements of the claims are to be interpreted broadly based on the language employed in the claims and not limited to examples described in the present specification or during the prosecution of the application, which examples are to be construed as non-exclusive. It is intended, therefore, that the specification and examples be considered as exemplary only, with a true scope and spirit being indicated by the following claims and their full scope of equivalents.
The above description is intended to be illustrative and not restrictive. For example, the above-described examples (or one or more versions thereof) may be used in combination with each other. For example, other embodiments may be used by those of ordinary skill in the art upon reading the above description. In addition, in the above-described embodiments, various features may be grouped together to streamline the disclosure. This should not be interpreted as an intention that features of an invention not claimed are essential to any of the claims. Rather, inventive subject matter may lie in less than all features of a particular inventive embodiment. Thus, the following claims are hereby incorporated into the detailed description as examples or embodiments, with each claim standing on its own as a separate embodiment, and it is contemplated that these embodiments may be combined with each other in various combinations or permutations. The scope of the invention should be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.

Claims (8)

1. A sketch regularization method based on painting, which is characterized by comprising the following steps:
triangulating the sketch to obtain a triangle set, and automatically painting the triangle set by using randomly generated colors based on a region growing method, wherein the color of each region is unique;
modifying the automatically painted triangle set according to the first input instruction;
based on the modified triangle set, deleting the corresponding strokes according to a second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map;
generating a vectorization line network according to the simplified pixel map, fitting each vectorization line in the vectorization line network by using a Bezier curve, and obtaining a layering picture by using a backtracking method;
based on the modified triangle set, deleting the corresponding strokes according to a second input instruction, then supplementing the missing strokes, and finally simplifying the coarse-grained lines into the width of one pixel to obtain a simplified pixel map, wherein the simplified pixel map comprises the following steps:
obtaining a corresponding pixel matrix based on the modified triangle set;
the second input instruction comprises a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are different, and if the second input instruction is the deleted line, the colors of the two sides of the line are the same;
searching the whole pixel matrix, and deleting the black lines which are left and right or have the same upper and lower colors and are not the black lines; changing any one middle pixel point from the pixel points which are different in left and right colors or upper and lower colors and are not black into black, and supplementing missing lines;
converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, wherein a pixel point q in the subset of the black pixel blocks needs to satisfy: the difference between the distances from q to p1 and p2 is smaller than a preset fixed threshold value, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black;
determining a simplified pixel matrix from a subset of the black pixel blocks;
generating a vectorized line network according to the simplified pixel map, comprising:
vectorizing the simplified pixel matrix to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines;
traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when the black pixel points which are not accessed are traversed, if the neighbors are accessed, the pixel points are added into the lines which are accessed and have the neighbor points, if the neighbors are not accessed, a line is newly added, the pixel points are added into the line, and finally, when all the black pixel points in the simplified pixel matrix are accessed, all the lines are extracted, and a line set is obtained.
2. The method of claim 1, wherein triangulating the sketch into a set of triangles comprises:
triangulating the sketch to generate a triangular convex hull, wherein the triangular convex hull comprises a pixel point set of the sketch;
and extracting the outline of the outermost layer of the triangular convex hull to obtain a triangular set.
3. The method of claim 1, wherein the region-based growth method automatically paints the set of triangles using randomly generated colors, comprising:
determining a seed triangle, wherein the seed triangle is a triangle with the largest radius of a circumscribed circle in the triangle set;
taking the seed triangles as starting points, respectively taking each triangle as a vertex, and generating a Thiessen polygon map, wherein when two triangles are adjacent, the two corresponding vertices in the map are connected;
performing expansion operation according to the determined seed triangles;
the expanding operation comprises: color expansion is carried out on the seed triangle to the adjacent triangle, when the side length of the adjacent side is larger than a preset side length parameter, the color is expanded, otherwise, the expansion in the direction is stopped;
after the expansion of one area is finished, continuously finding the next seed triangle in all the uncolored triangle sets and repeating the expansion operation until all the triangles are colored or no triangles meet the condition that the side length of the adjacent sides of the adjacent triangles is larger than a preset side length parameter;
in the process of carrying out the expansion operation, recording the color _ flow of each triangle in the same area compared with the seed triangle; the color _ flow is defined as: any one triangle belonging to the same region has the smallest flow in the Thiessen polygon and between the seed triangles.
4. The method of claim 3, wherein modifying the automatically painted set of triangles according to the first input instruction comprises:
according to the selected seed triangle, the color of the area determined by the selected seed triangle is changed and/or
And according to any selected triangle, taking the triangle as a new seed triangle, if the color _ flow from a certain triangle to the new seed triangle is larger than the original color _ flow, performing expansion operation, and otherwise, stopping the expansion operation.
5. The method of claim 1, wherein obtaining the hierarchical picture using a backtracking method comprises:
traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel has a hierarchical structure; and layering the original sketch according to the hierarchical structure to obtain a layered picture.
6. A sketch regularization device based on painting, characterized in that the device comprises:
the automatic coloring module is configured to triangulate the sketch to obtain a triangle set, and automatically color the triangle set by using randomly generated colors based on a region growing method, wherein the color of each region is unique;
the interactive painting and region merging module is configured to modify the automatically painted triangle set according to a first input instruction;
the stroke simplifying and grouping module based on painting is configured to delete corresponding strokes according to a second input instruction based on the modified triangle set, then supplement missing strokes, and finally simplify coarse-grained lines into the width of one pixel to obtain a simplified pixel map;
the normalized picture generating module is configured to generate a vectorization line network according to the simplified pixel map, fit each vectorization line in the vectorization line network by using a Bezier curve, and obtain a hierarchical picture by using a backtracking method;
vectorizing the simplified pixel matrix to generate a topological graph g = (V, E) of all strokes, wherein V represents all nodes, and E represents all lines;
traversing the whole simplified pixel matrix by using a minimum spanning tree algorithm, and extracting all line sets: when a black pixel point which is not accessed is traversed, if a neighbor is accessed, adding the pixel point into a line which is accessed and has the neighbor point, if the neighbor is not accessed, adding a line newly, adding the pixel point into the line, and finally extracting all lines to obtain a line set when all black pixel points in the simplified pixel matrix are accessed;
the paint-based stroke reduction and grouping module is further configured to:
obtaining a corresponding pixel matrix based on the modified triangle set;
the second input instruction comprises a reserved line and a deleted line, if the second input instruction is the reserved line, the colors of the two sides of the line are different, and if the second input instruction is the deleted line, the colors of the two sides of the line are the same;
searching the whole pixel matrix, and deleting the black lines which are left and right or have the same upper and lower colors and are not the black lines; changing any one middle pixel point from the pixel points which are different in left and right or upper and lower colors and are not black into black, and supplementing the missing lines;
converting the searched pixel matrix into a binary pixel matrix, and extracting a subset of all black pixel blocks, wherein pixel points q in the subset of the black pixel blocks need to meet the following requirements: the difference between the distances from q to p1 and p2 is smaller than a preset fixed threshold, the colors of p1 and p2 are different, and the line pigment connecting q to p1 and q to p2 is black;
the simplified pixel matrix is determined from a subset of the black pixel blocks.
7. The apparatus of claim 6, wherein the regularized picture generation module is further configured to:
traversing the whole pixel matrix according to a backtracking flow-fill algorithm: for each newly visited white pixel point, a new hierarchical structure is given, surrounding pixel points are recursively traversed, if a black pixel point is encountered, the visit is stopped, and if a white pixel point which is not visited is encountered, the same hierarchical structure is given; finally, traversing all the points in the pixel matrix, wherein each pixel has a hierarchical structure; and layering the original sketch according to the hierarchical structure to obtain a layered picture.
8. A non-transitory computer-readable storage medium having stored thereon instructions that, when executed by a processor, perform the method of any one of claims 1-5.
CN202210522373.XA 2022-05-13 2022-05-13 Sketch regularization method, device and medium based on painting Active CN114820873B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210522373.XA CN114820873B (en) 2022-05-13 2022-05-13 Sketch regularization method, device and medium based on painting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210522373.XA CN114820873B (en) 2022-05-13 2022-05-13 Sketch regularization method, device and medium based on painting

Publications (2)

Publication Number Publication Date
CN114820873A CN114820873A (en) 2022-07-29
CN114820873B true CN114820873B (en) 2023-04-07

Family

ID=82514774

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210522373.XA Active CN114820873B (en) 2022-05-13 2022-05-13 Sketch regularization method, device and medium based on painting

Country Status (1)

Country Link
CN (1) CN114820873B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108805957A (en) * 2018-06-07 2018-11-13 青岛九维华盾科技研究院有限公司 A kind of vector drawing generating method and system based on bitmap images adaptivenon-uniform sampling
CN110659644A (en) * 2019-06-26 2020-01-07 西安理工大学 Automatic extraction method for strokes of calligraphy single characters
CN114092952A (en) * 2021-11-23 2022-02-25 华南师范大学 dXF format-based house type graph information extraction and vectorization method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5600524B2 (en) * 2010-08-27 2014-10-01 キヤノン株式会社 Image processing apparatus, image processing method, program, and storage medium
US10521937B2 (en) * 2017-02-28 2019-12-31 Corel Corporation Vector graphics based live sketching methods and systems
CN111260750B (en) * 2020-01-08 2023-07-07 广东三维家信息科技有限公司 Processing method and device for openFL drawing vector graphics and electronic equipment
US11087511B1 (en) * 2020-04-24 2021-08-10 Adobe Inc. Automated vectorization of a raster image using a gradient mesh with arbitrary topology
CN112861709A (en) * 2021-02-05 2021-05-28 金陵科技学院 Hand-drawn sketch recognition method based on simple strokes
CN113706648B (en) * 2021-08-04 2024-03-19 武汉理工大学 Tangka element vectorization method based on diffusion curve

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108805957A (en) * 2018-06-07 2018-11-13 青岛九维华盾科技研究院有限公司 A kind of vector drawing generating method and system based on bitmap images adaptivenon-uniform sampling
CN110659644A (en) * 2019-06-26 2020-01-07 西安理工大学 Automatic extraction method for strokes of calligraphy single characters
CN114092952A (en) * 2021-11-23 2022-02-25 华南师范大学 dXF format-based house type graph information extraction and vectorization method and device

Also Published As

Publication number Publication date
CN114820873A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
US20200258301A1 (en) Generating a customized three-dimensional mesh from a scanned object
Regnauld et al. A synoptic view of generalisation operators
CN110180186B (en) Topographic map conversion method and system
US8457405B2 (en) Example-based procedural synthesis of element arrangements
CN109118588B (en) Automatic color LOD model generation method based on block decomposition
Parakkat et al. A Delaunay triangulation based approach for cleaning rough sketches
CN113192200B (en) Method for constructing urban real scene three-dimensional model based on space-three parallel computing algorithm
CN113487523B (en) Method and device for optimizing graph contour, computer equipment and storage medium
Zeng et al. Interactive shape from shading
Hu et al. Geometric feature enhanced line segment extraction from large-scale point clouds with hierarchical topological optimization
She et al. 3D building model simplification method considering both model mesh and building structure
CN115100652A (en) Electronic map automatic generation method based on high-resolution remote sensing image
CN114820668A (en) End-to-end building regular outline automatic extraction method based on concentric ring convolution
CN114820873B (en) Sketch regularization method, device and medium based on painting
Ng et al. Scalable Feature Extraction with Aerial and Satellite Imagery.
CN117237623A (en) Semantic segmentation method and system for remote sensing image of unmanned aerial vehicle
Szendrei et al. A knowledge-based approach to raster-vector conversion of large scale topographic maps
Bei et al. GeoGlue: Feature matching with self-supervised geometric priors for high-resolution UAV images
CN114863438A (en) Method and system for identifying curves
CN104574429A (en) Automatic selection method for intersection hot spots in panorama roaming
US11107257B1 (en) Systems and methods of generating playful palettes from images
CN114022458A (en) Skeleton detection method and device, electronic equipment and computer readable storage medium
Vasin et al. Geometric modeling of raster images of documents with weakly formalized description of objects
Tian et al. An approach to generate spatial Voronoi Treemaps for points, lines, and polygons
López-Ornelas High resolution images: Segmenting, extracting information and GIS integration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant