CN109767479B - Dynamic boundary group sequence-based primitive filling method and system - Google Patents

Dynamic boundary group sequence-based primitive filling method and system Download PDF

Info

Publication number
CN109767479B
CN109767479B CN201811524954.7A CN201811524954A CN109767479B CN 109767479 B CN109767479 B CN 109767479B CN 201811524954 A CN201811524954 A CN 201811524954A CN 109767479 B CN109767479 B CN 109767479B
Authority
CN
China
Prior art keywords
point
filling
boundary
primitive
filled
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
CN201811524954.7A
Other languages
Chinese (zh)
Other versions
CN109767479A (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 SAC Automation Co Ltd
Original Assignee
Nanjing SAC Automation Co Ltd
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 SAC Automation Co Ltd filed Critical Nanjing SAC Automation Co Ltd
Priority to CN201811524954.7A priority Critical patent/CN109767479B/en
Publication of CN109767479A publication Critical patent/CN109767479A/en
Application granted granted Critical
Publication of CN109767479B publication Critical patent/CN109767479B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)

Abstract

The invention discloses a primitive filling method and system based on a dynamic boundary group sequence, wherein the method comprises the following steps: acquiring the coordinates of the starting point of the primitive to be filled; scanning an area where the primitives to be filled are located row by row/column by utilizing a scanning line from a line/column where the starting point is located, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned line/column; acquiring intersection point position coordinates of a scanning line and a boundary of a primitive to be filled, marking the boundary attribute of the scanning line and the boundary, and sequentially pressing the boundary attribute into a preset boundary group sequence stack; combining each intersection point in the boundary group sequence stack according to the stacking sequence and the boundary attribute to generate a single filling point and/or at least 1 filling line segment which takes two adjacent intersection points as two end points; and filling the coordinate area covered by each filling point or each filling line segment with preset colors. The invention can improve the accuracy of the primitive boundary, avoid a large amount of recursion problems in the traditional filling method, save the stack space and improve the primitive filling efficiency.

Description

Dynamic boundary group sequence-based primitive filling method and system
Technical Field
The invention relates to the technical field of primitive drawing in power system visualization engineering, in particular to a primitive filling method and a primitive filling system based on a dynamic boundary group sequence.
Background
Primitive filling refers to a process of filling internal pixels of an irregular primitive into designated filling colors, and the method is widely applied to the field of drawing of the primitives of the power system and is also an important classification in graphic display.
With the rapid development of the power industry, the drawing requirements of system primitives are higher and higher. The color filling of the primitive is taken as an important branch in the drawing, and a complete solution is urgently needed to position the position of the internal area of the primitive and perform the primitive filling efficiently and accurately.
The traditional filling method is roughly divided into two methods, one method is an injection method, which is also called a flood filling method, and the method does not emphasize the boundary position of an area, but sets a pixel point as a filling target color, then judges whether a neighborhood around the pixel point has the same color, if so, sets the pixel point as a specified color from a specified position, and then recurses until all connected pixels of the same color become the specified color, thereby realizing the filling effect; the other is a seed filling method, and the basic idea is to determine the boundary pixel value of each line, designate a pixel point from a certain target area as a filling identifier, fill in the direction from inside to outside with the given pixel value, process each pixel in turn, and stop when the boundary pixel point is met. The injection filling method has the disadvantages that the boundary can not be accurately positioned, and the efficiency is not high; the recursion levels of the seed filling algorithm are increased along with the increase of the filling area, overflow is easily caused, and as many pixel points need to be accessed for many times when a function is called recursively, the space cost is high, and the algorithm efficiency is also low.
Disclosure of Invention
The invention aims to provide a primitive filling method based on a dynamic boundary group sequence, which improves the accuracy of primitive boundaries, avoids a large amount of recursion problems in the traditional filling method, saves stack space and improves primitive filling efficiency.
The technical scheme adopted by the invention is as follows: a primitive filling method based on dynamic boundary group sequence includes:
acquiring the coordinates of the starting point of the primitive to be filled;
scanning an area where the primitives to be filled are located row by row/column by utilizing a scanning line from a line/column where the starting point is located, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned line/column;
acquiring the position coordinates of the intersection points of the scanning lines and the boundaries of the primitives to be filled, marking the boundary attributes of the scanning lines and the boundaries of the primitives to be filled, and sequentially pressing the boundary attributes into a preset boundary group sequence stack;
combining each intersection point in the boundary group sequence stack according to the stacking sequence and the boundary attribute to generate a single filling point and/or at least 1 filling line segment which takes two adjacent intersection points as two end points;
and filling the coordinate area and/or the filling point covered by each filling line segment with preset colors.
When the method is applied, when the last line or column is scanned and then the corresponding filling line segment is filled, the filling of the graphic elements to be filled is also finished. The invention utilizes the scanning line to obtain the boundary point of the primitive filling area, which can improve the accuracy of the primitive boundary, and simultaneously, the invention dynamically stores the primitive area boundary point obtained by each scanning by setting the boundary group sequence stack, thereby converting the filling of the primitive into the filling of the filling line segment, and only identifying two end points of each filling line segment, avoiding the fussy process of judging coordinate points one by one, and greatly improving the efficiency of the primitive filling.
Preferably, the coordinates of the starting point of the primitive to be filled are the coordinates of the vertex of the primitive to be filled, and the obtaining step includes:
s101, obtaining coordinates of any point in a primitive to be filled;
s102, from the point coordinates obtained in S101, traversing from bottom to top to obtain a step point of a first pixel value, and taking the step point as a first boundary point;
and S103, starting from the first boundary point, traversing step points of pixel values upward line by line or points with the same pixel values as the first boundary point until a certain line does not monitor corresponding points any more, taking the leftmost or rightmost point obtained by traversing the previous line as a starting point of filling scanning, and obtaining the coordinates of the point.
The step S101 may be manually specified by clicking with a mouse at will.
In other embodiments, the coordinates of the starting point of the primitive to be filled are the coordinates of the lowest point, the coordinates of the left end vertex or the coordinates of the right end vertex of the primitive to be filled. The acquisition mode can refer to the acquisition step of the vertex and adjust the traversal sequence. When scanning is performed by using the scanning lines, the scanning lines may adopt horizontal lines (the filling starting point is the top point or the lowest point) or vertical lines (the filling starting point is the left top point or the right top point) according to different filling starting points, and the scanning sequence may also be adaptively adjusted.
And when the filling starting point is the top point or the lowest point of the primitive to be filled, the scanning line is a scanning line with the ordinate of y, and each line of the area where the primitive to be filled is located is scanned successively by utilizing the scanning line. In this embodiment, the overall filling order of the primitives to be filled is from top to bottom or from bottom to top.
And when the filling starting point is the top point at the left end or the top point at the right end of the primitive to be filled, the scanning line is a scanning line with the abscissa of x, and the scanning line is utilized to successively scan each column of the area where the primitive to be filled is located. In this embodiment, the overall filling order of the primitives to be filled is from left to right or from right to left.
Preferably, the present invention further comprises: acquiring a starting point pixel value of a primitive to be filled; when scanning is carried out by utilizing a scanning line, judging whether a corresponding point is an intersection point of the scanning line and a boundary of a primitive to be filled according to whether the pixel value of a scanned point is the same as that of a filling starting point; and the boundary attribute of the intersection point is filling start or filling end. If the pixels are the same, the scanned point is a boundary point. The "scanned row or column does not have boundary points of the primitive to be filled" i.e. the corresponding scan line does not intersect the primitive to be filled. The boundary attribute of the intersection point provides basis for the generation of the subsequent filling line segment, the mark of the attribute can be determined according to the number of times of intersection of the current scanning line and the boundary of the primitive to be filled at the point generating moment, the boundary attribute is the filling start for odd times, the boundary attribute is the filling end for even times, and when the filling line segment is generated subsequently, the line segment is filled into a middle coordinate point from the filling start point to the filling end point.
In another embodiment, when scanning is performed by using a scanning line, it is determined whether a current scanned point is a boundary point according to whether pixels of the current scanned point and a previous scanned point have a step. If the previous scanned point is a boundary point and the current scanned point pixel has a step, the current scanned point is a non-boundary point; if the previous scanned point is a non-boundary point and the pixel of the current scanned point has a step, the current scanned point is a boundary point, and if no step occurs, the current scanned point is still a non-boundary point.
Further, when the boundary point identification utilizes a pixel value step rule: when scanning is carried out by using a scanning line, a preset filling flag bit is initialized before each scanning, and the filling flag bit value is correspondingly switched between 0 and 1 once each time a step change occurs to a pixel of a scanned point in the scanning process;
and for each intersection point of the scanning line and the primitive to be filled, writing the corresponding intersection point and a filling flag bit value corresponding to the generation time of the intersection point into the boundary group sequence stack. Therefore, when the filling line segments are generated, the boundary of the primitive to be filled can be identified through the filling mark bits, the coordinate points covered by each filling line segment are all the points inside the primitive to be filled, and the subsequent filling of the filling line segments is ensured to be correct.
As an implementation manner, before scanning each time, initializing a filling flag bit to be 0, setting the filling flag bit to be 1 when the number of times of intersection of the boundary of the current scanning line and the primitive to be filled is odd, and setting the filling flag bit to be 0 when the number of times of intersection is even;
for each intersection pushed into the boundary group sequence stack, according to its corresponding fill flag value: combining every two filling line segments from 1 to 0 based on the pressing sequence to obtain a filling starting point and a filling ending point of each filling line segment; or as a filling point alone for a filling start point where the latter intersection point is still a filling start point. And during subsequent filling, filling is started from the intersection point with the filling flag bit of 1, and is finished to the intersection point with the filling flag bit of 0, and a single filling point is filled according to other boundary points.
Of course, the 0/1 state setting of the padding flag bit is transposable.
The invention also discloses a dynamic boundary group sequence-based primitive filling system, which comprises:
a filling starting point obtaining module for obtaining the starting point coordinates of the graphic primitive to be filled;
the boundary point scanning module is used for scanning an area where the primitives to be filled are located line by line or line by line from a starting point by utilizing a scanning line, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned line or line;
the boundary point coordinate acquisition module is used for acquiring intersection point position coordinates of the scanning line and the graphic primitive to be filled in real time and sequentially pressing the intersection point position coordinates into a preset boundary group sequence stack;
the filling line segment generation module is used for combining every two intersection points in the boundary group sequence stack according to the stacking sequence to obtain at least 1 filling line segment taking the intersection point combination as two end points;
and the color filling module is used for filling preset colors in the coordinate area and/or the filling point covered by each filling line segment.
Advantageous effects
According to the invention, the boundary points of the filling primitives are obtained by utilizing a scanning line algorithm, the dynamic group sequence stack is combined, the filling line segments are generated in real time according to the boundary points, the filling of the filling primitives is converted into the filling of a plurality of filling line segments respectively, the recursion is avoided in the filling process, the problem of large space overhead caused by the fact that a large number of pixel points need to be accessed for many times when the function is called in the traditional method is solved, the filling efficiency is greatly improved, and the loading and displaying time of the picture can be greatly optimized for a circuit diagram with a large number of complicated primitives. Meanwhile, the invention judges the boundary of the filling primitive by combining the scanning line algorithm and the identification bit, improves the filling efficiency, improves the grasp of the boundary and solves the problem of filling boundary crossing.
Drawings
FIG. 1 is a schematic flow chart of the method of the present invention.
Detailed Description
The following further description is made in conjunction with the accompanying drawings and the specific embodiments.
In the process of primitive filling, in order to improve the efficiency of primitive filling, the minimum filling interval of the filling line segment is calculated by acquiring the boundary of the primitive to be filled, instead of performing pixel filling point by point. Meanwhile, in consideration of the shape particularity of the drawing primitive, the invention sets a stack storage space, namely a dynamic boundary group sequence stack, to dynamically store the intersection points of the scanning lines and the boundary of the filling primitive, takes the line segment between every two adjacent intersection points as the filling line segment, and forms a filling target point group sequence by the coordinate points covered by a plurality of filling line segments, so that all unprocessed pixel points around the current area are not required to be pressed into the stack in a recursive mode like other filling algorithms.
The invention scans the area position of the primitive from top to bottom or from left to right by using a scanning line mode, each scanning line generates a series of intersection points with the boundary of the primitive, the intersection points are sequenced according to coordinates, the sequenced points are recombined into a filling line segment, every two points are used as two end points of the filling line segment, and the pixel interval section is sequentially filled according to the coordinate sequence until the two points touch the boundary.
Example 1
The invention relates to a primitive filling method based on a dynamic boundary group sequence, which comprises the following steps:
acquiring the coordinates of the starting point of the primitive to be filled;
scanning an area where the primitives to be filled are located line by line or column by using a scanning line from a starting point, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned line or column;
acquiring intersection point position coordinates of a scanning line and a boundary of a primitive to be filled in real time, and sequentially pressing the intersection point position coordinates into a preset boundary group sequence stack;
combining all intersection points in the boundary group sequence stack according to the stacking sequence to obtain at least 1 filling line segment taking intersection point combination as two end points;
and filling the coordinate area and/or the filling point covered by each filling line segment with preset colors.
The starting point coordinates of the primitive to be filled are the vertex coordinates of the primitive to be filled, and the obtaining step comprises the following steps:
s101, obtaining coordinates of any point in a primitive to be filled;
s102, from the point coordinates obtained in S101, traversing from bottom to top to obtain a step point of a first pixel value, and taking the step point as a first boundary point;
and S103, starting from the first boundary point, traversing step points of pixel values upward line by line or points with the same pixel values as the first boundary point until a certain line does not monitor corresponding points any more, taking the leftmost or rightmost point obtained by traversing the previous line as a starting point of filling scanning, and obtaining the coordinates of the point.
The step S101 may be manually specified by clicking with a mouse at will.
In other embodiments, the coordinates of the starting point of the primitive to be filled are the coordinates of the lowest point, the coordinates of the left end vertex or the coordinates of the right end vertex of the primitive to be filled. The acquisition mode can refer to the acquisition step of the vertex and adjust the traversal sequence. When scanning is performed by using the scanning lines, the scanning lines may adopt horizontal lines (the filling starting point is the top point or the lowest point) or vertical lines (the filling starting point is the left top point or the right top point) according to different filling starting points, and the scanning sequence may also be adaptively adjusted.
And when the filling starting point is the top point or the lowest point of the primitive to be filled, the scanning line is a scanning line with the ordinate of y, and each line of the area where the primitive to be filled is located is scanned successively by utilizing the scanning line. In this embodiment, the overall filling order of the primitives to be filled is from top to bottom or from bottom to top.
And when the filling starting point is the top point at the left end or the top point at the right end of the primitive to be filled, the scanning line is a scanning line with the abscissa of x, and the scanning line is utilized to successively scan each column of the area where the primitive to be filled is located. In this embodiment, the overall filling order of the primitives to be filled is from left to right or from right to left.
Further comprising: acquiring a starting point pixel value of a primitive to be filled; when scanning is carried out by utilizing a scanning line, judging whether a corresponding point is an intersection point of the scanning line and a boundary of a primitive to be filled according to whether the pixel value of a scanned point is the same as that of a filling starting point; and the boundary attribute of the intersection point is filling start or filling end. If the two points are the same, the scanned point is a boundary point. The "scanned row or column does not have boundary points of the primitive to be filled" i.e. the corresponding scan line does not intersect the primitive to be filled.
In another embodiment, when scanning is performed by using a scanning line, it is determined whether a currently scanned point is a boundary point according to whether a step occurs between pixels of the currently scanned point and a pixel of a previously scanned point. If the previous scanned point is a boundary point and the current scanned point pixel has a step, the current scanned point is a non-boundary point; if the previous scanned point is a non-boundary point and the pixel of the current scanned point has a step, the current scanned point is a boundary point, and if no step occurs, the current scanned point is still a non-boundary point.
Further, when the boundary point identification utilizes the pixel value step rule: when scanning is carried out by using a scanning line, a preset filling flag bit is initialized before each scanning, and the filling flag bit value is correspondingly switched between 0 and 1 once each time a step change occurs to a pixel of a scanned point in the scanning process;
and for each intersection point of the scanning line and the primitive to be filled, writing the corresponding intersection point and a filling flag bit value corresponding to the generation time of the intersection point into the boundary group sequence stack. Therefore, when the filling line segments are generated, the boundary of the primitive to be filled can be identified through the filling mark bits, the coordinate points covered by each filling line segment are all the points inside the primitive to be filled, and the subsequent filling of the filling line segments is ensured to be correct.
As an implementation manner, before each scanning, the filling flag bit is initialized to 0, when the number of times of intersection of the boundary of the current scanning line and the primitive to be filled is odd, the filling flag bit is set to 1, and when the number of times of intersection is even, the filling flag bit is set to 0;
for each intersection pushed into the boundary group sequence stack, according to its corresponding fill flag value: combining every two filling line segments from 1 to 0 based on the pressing sequence to obtain a filling starting point and a filling ending point of each filling line segment; or as a filling point alone for a filling start point where the latter intersection point is still a filling start point. During subsequent filling, filling is started from the intersection point with the filling flag bit being 1, and filling is finished to the intersection point with the filling flag bit being 0.
Of course, the 0/1 state setting of the padding flag bit is transposable.
Example 2
Referring to fig. 1, the method for filling primitives based on dynamic boundary group sequences in this embodiment includes the steps of:
s1, acquiring filling starting point coordinates, comprising the following steps:
s101, clicking any point inside a primitive to be filled by using a mouse to obtain coordinates of the point;
s102, traversing from bottom to top from the selected point coordinate to obtain a first upper boundary point of the primitive to be filled in the corresponding column;
s103, traversing from the first upper boundary point to a certain line in a traversing mode from left to right and from bottom to top until the boundary point is no longer monitored, and taking the left boundary point of the previous line of the line as a starting point of filling scanning, namely a scanning line filling starting point, and acquiring the coordinates of the point;
s2, starting from the filling starting point, scanning the pixels from left to right line by using the scanning lines; before each scanning, the filling flag bit is initialized to 0, the first intersection point generated by the intersection of the scanning line and the graphic element is a filling initial point p1, and the filling flag bit flag is correspondingly set to 1;
scanning is continued, each time of scanning is carried out until a scanning line touches the boundary of a corresponding line, a filling flag bit is set to be 1 when the number of times of intersection of the scanning line and the boundary of the primitive is odd, the filling area is indicated to enter, and the number of times of intersection is even, the filling flag bit is set to be 0, and the filling stop point is indicated; starting from the position of the point p1, when the flag is changed into 0, recording the boundary point p2, and repeating the steps until the end of the single scanning to scan the next line;
s3, acquiring intersection points of the scanning lines and the boundaries of the graphic elements, recording the intersection points into a dynamic boundary group sequence, combining end points according to the sequence of the intersection points into the dynamic boundary group sequence and corresponding filling mark positions, and generating a filling line segment from a point P1 to a point P2 if all transverse coordinate points between the point P1 and the point P2 are written into a dynamic coordinate group H for the point P1 and the point P2;
and continuing the scanning judgment of the next interval, setting the corresponding coordinate point of the flag from 0 to 1 as the starting point of the next filling interval until the scanning line touches the next boundary, and sequentially adding the coordinates between the flag marks 1 and 0 into the coordinate group H, and similarly generating all filling line segments. The step improves the accuracy of defining the boundary of the primitive to a certain degree, and particularly can effectively judge irregular primitives so as to avoid filling and crossing the boundary;
and S4, filling the coordinate area and/or the filling point covered by each filling line segment with preset colors.
In this embodiment, after each single-line scanning is completed, the coordinates in the dynamic boundary group sequence H are sequentially drawn in the designated color, and then the y coordinate of the scanning line is added by 1 pixel unit, and the scanning operation is moved to the next line scanning, and the scanning operation is stopped until the pixel area coordinate no longer exists in a certain line.
And after the coordinate sets in the dynamic boundary set sequence are traversed and filled, the primitive filling is completed.
Compared with the prior art, the method avoids a large amount of recursions, saves a large amount of stack space, and shortens the filling time by thirty percent; for the filling of the primitive areas, the problems that the existing method is easy to cause filling out border crossing, dirty points and unfilled corners occur at the corners of the primitive in particular and the like due to the limitation of judging the irregular primitive borders are solved, the accuracy of primitive filling is greatly improved, and the high efficiency of primitive filling is also ensured.
Example 3
The present embodiment is a primitive filling system based on dynamic boundary group sequence, including:
a filling starting point obtaining module for obtaining the starting point coordinates of the graphic primitive to be filled;
the boundary point scanning module is used for scanning an area where the primitives to be filled are located row by row/column by utilizing a scanning line from a row/column where the starting point is located, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned row/column;
the boundary point coordinate acquisition module is used for acquiring intersection point position coordinates of the scanning line and the boundary of the primitive to be filled, marking the boundary attribute of the intersection point position coordinates, and sequentially pressing the intersection point position coordinates into a preset boundary group sequence stack;
the filling line segment generation module is used for combining all intersection points in the boundary group sequence stack according to the sequence of entering the stack and the boundary attribute to generate a single filling point and/or at least 1 filling line segment which takes two adjacent intersection points as two end points;
and the color filling module is used for filling preset colors in the coordinate area and/or the filling point covered by each filling line segment.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the present invention has been described with reference to the particular illustrative embodiments, it is to be understood that the invention is not limited to the disclosed embodiments, but is intended to cover various modifications, equivalent arrangements, and equivalents thereof, which may be made by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (9)

1. A primitive filling method based on dynamic boundary group sequence is characterized by comprising the following steps:
acquiring the coordinates of the starting point of the primitive to be filled;
scanning an area where the primitives to be filled are located row by row/column by utilizing a scanning line from a line/column where the starting point is located, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned line/column;
acquiring intersection point position coordinates of a scanning line and a boundary of a primitive to be filled, marking the boundary attribute of the scanning line and the boundary, and sequentially pressing the boundary attribute into a preset boundary group sequence stack;
combining all intersection points in the boundary group sequence stack according to the sequence of entering the stack and the boundary attribute to generate a single filling point and/or at least 1 filling line segment which takes two adjacent intersection points as two end points;
filling preset colors in the coordinate area and/or the filling points covered by each filling line segment;
the method comprises the following steps of obtaining a primitive to be filled, wherein the coordinates of a starting point of the primitive to be filled are the coordinates of a vertex of the primitive to be filled, and the obtaining step comprises the following steps:
s101, obtaining coordinates of any point in a primitive to be filled;
s102, from the point coordinates obtained in S101, traversing from bottom to top to obtain a step point of a first pixel value, and taking the step point as a first boundary point;
and S103, starting from the first boundary point, traversing step points of pixel values upwards line by line or points with the same pixel values as the first boundary point until a certain line does not monitor corresponding points any more, taking the leftmost or rightmost point obtained by traversing the previous line as a starting point of filling scanning, and acquiring coordinates of the point.
2. The method as claimed in claim 1, wherein the coordinates of the starting point of the primitive to be filled are the coordinates of the lowest point, the coordinates of the left end vertex or the coordinates of the right end vertex of the primitive to be filled.
3. A method as claimed in claim 1, characterized in that the scanning lines are scanning lines with an ordinate y, with which the lines of the area in which the picture elements to be filled are located are scanned one after the other.
4. A method as claimed in claim 1, characterized in that the scanning lines are scanning lines with an x-axis, with which the columns of the area in which the picture elements to be filled are located are scanned one after the other.
5. The method of claim 1, further comprising: acquiring a starting point pixel value of a primitive to be filled; when scanning is carried out by utilizing a scanning line, judging whether a corresponding point is an intersection point of the scanning line and a boundary of a primitive to be filled according to whether the pixel value of a scanned point is the same as that of a filling starting point; and the boundary attribute of the intersection point is filling start or filling end.
6. The method as claimed in claim 1, wherein when scanning with the scan line, it is determined whether the current scanned point is a boundary point based on whether the pixels of the current scanned point and the previous scanned point have a step.
7. The method as claimed in claim 6, wherein, when scanning with the scanning line, the preset filling flag is initialized before each scanning, and during the scanning, the filling flag is correspondingly switched between 0 and 1 each time the step change occurs to the pixel of the scanned point;
and for each intersection point of the scanning line and the primitive to be filled, writing the corresponding intersection point and a filling flag bit value corresponding to the generation time of the intersection point into the boundary group sequence stack.
8. The method as claimed in claim 7, wherein before each scan, the fill flag is initialized to 0, the fill flag is set to 1 when the number of times of intersection of the current scan line with the boundary of the primitive to be filled is odd, and the fill flag is set to 0 when the number of times of intersection is even;
for each intersection pushed into the boundary group sequence stack, according to its corresponding fill flag value: combining every two filling line segments from 1 to 0 based on the pressing sequence to obtain a filling starting point and a filling ending point of each filling line segment; or as a filling point alone for a filling start point where the latter intersection point is still a filling start point.
9. A dynamic boundary group sequence-based primitive filling system, comprising:
a filling starting point obtaining module for obtaining the starting point coordinates of the graphic primitive to be filled;
the boundary point scanning module is used for scanning an area where the primitives to be filled are located row by row/column by utilizing a scanning line from a row/column where the starting point is located, and stopping scanning until the boundary point of the primitives to be filled does not exist in the scanned row/column;
the boundary point coordinate acquisition module is used for acquiring intersection point position coordinates of the scanning line and the boundary of the primitive to be filled, marking the boundary attribute of the intersection point position coordinates, and sequentially pressing the intersection point position coordinates into a preset boundary group sequence stack;
the filling line segment generation module is used for combining all intersection points in the boundary group sequence stack according to the sequence of entering the stack and the boundary attribute to generate a single filling point and/or at least 1 filling line segment which takes two adjacent intersection points as two end points;
the color filling module is used for filling preset colors in the coordinate area and/or the filling point covered by each filling line segment;
the method comprises the following steps of obtaining primitive coordinates to be filled, wherein the starting point coordinates of the primitive to be filled are vertex coordinates of the primitive to be filled, and the obtaining step comprises the following steps:
s101, obtaining coordinates of any point in a primitive to be filled;
s102, from the point coordinates obtained in S101, traversing from bottom to top to obtain a step point of a first pixel value, and taking the step point as a first boundary point;
and S103, starting from the first boundary point, traversing step points of pixel values upward line by line or points with the same pixel values as the first boundary point until a certain line does not monitor corresponding points any more, taking the leftmost or rightmost point obtained by traversing the previous line as a starting point of filling scanning, and obtaining the coordinates of the point.
CN201811524954.7A 2018-12-13 2018-12-13 Dynamic boundary group sequence-based primitive filling method and system Active CN109767479B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811524954.7A CN109767479B (en) 2018-12-13 2018-12-13 Dynamic boundary group sequence-based primitive filling method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811524954.7A CN109767479B (en) 2018-12-13 2018-12-13 Dynamic boundary group sequence-based primitive filling method and system

Publications (2)

Publication Number Publication Date
CN109767479A CN109767479A (en) 2019-05-17
CN109767479B true CN109767479B (en) 2023-03-24

Family

ID=66451808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811524954.7A Active CN109767479B (en) 2018-12-13 2018-12-13 Dynamic boundary group sequence-based primitive filling method and system

Country Status (1)

Country Link
CN (1) CN109767479B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112347727A (en) * 2019-08-08 2021-02-09 深圳市立创软件开发有限公司 Filling type copper-clad method, system, equipment and storage medium supporting arc edges
CN110719129B (en) * 2019-10-14 2020-06-23 沈阳市电信规划设计院股份有限公司 Point location correction system based on communication basic resource intelligent management data
CN112465930A (en) * 2020-11-10 2021-03-09 深圳市益欣网络科技有限公司 Scanning line seed filling method
CN113191311B (en) * 2021-05-19 2024-04-16 广联达科技股份有限公司 Method, device, equipment and storage medium for identifying filling boundary of vector PDF drawing
CN115294235B (en) * 2022-10-08 2023-03-31 广州中望龙腾软件股份有限公司 Bitmap-based graphic filling method, terminal and storage medium
CN115294236B (en) * 2022-10-08 2023-03-10 广州中望龙腾软件股份有限公司 Bitmap filling method, terminal and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101082980A (en) * 2006-06-01 2007-12-05 上海吉量软件科技有限公司 Intersection point matched pair stuffing algorithm
CN101201938A (en) * 2006-12-13 2008-06-18 上海吉量软件科技有限公司 Filling algorithm for rapidly matching pair of left and right boundary point
CN102693525A (en) * 2012-05-08 2012-09-26 北京航空航天大学 Method for solving problem of pixel multiple accesses to stack in seed filling algorithm
CN108961359B (en) * 2018-05-17 2022-06-14 长沙八思量信息技术有限公司 Laser marking system, filling method of closed graph of laser marking system and storage medium

Also Published As

Publication number Publication date
CN109767479A (en) 2019-05-17

Similar Documents

Publication Publication Date Title
CN109767479B (en) Dynamic boundary group sequence-based primitive filling method and system
Wu Adaptive split-and-merge segmentation based on piecewise least-square approximation
JP2019515374A (en) Method and apparatus for recognizing character areas in an image
CN110148137B (en) Image cutting method and system of rotary display screen based on splicing
CN109584366B (en) Terrain rendering method, device, equipment and readable storage medium
JP3586991B2 (en) Texture data reading device and rendering device
JP5254250B2 (en) Method and system for generating boundaries in the process of rasterizing vector graphics, and method for manufacturing the system
CN117292079B (en) Multi-dimensional scene coordinate point position conversion and mapping method applied to digital twin
CN104270624A (en) Region-partitioning 3D video mapping method
CN104318538A (en) Method for splicing two-dimension sequence frame picture into big picture and device
US20120169759A1 (en) Method and apparatus for creating a live artistic sketch of an image
CN117911444A (en) Edge processing-based matting method and system
CN110162285B (en) Distributed image cutting method and system of rotary display screen based on splicing
CN107993246A (en) Image processing equipment and connected component labeling method, system, device, storage medium
CN117058338A (en) CAD-based three-dimensional building model construction method, system, equipment and medium
RU2470368C2 (en) Image processing method
CN111739111B (en) Point cloud projection coding intra-block offset optimization method and system
CN102054280B (en) Method and device for rapidly generating vector diagram
CN116820561B (en) Method for automatically generating interface codes based on interface design diagram
CN117911578B (en) Text rendering method and device, computer equipment and storage medium
CN115168112B (en) Method, device, equipment and medium for restoring section data under dynamic section change
JPH0276073A (en) Plotter
Du et al. Fast seam carving based on direction map
JP7499476B2 (en) DATA CREATION SYSTEM, LEARNING SYSTEM, ESTIMATION SYSTEM, PROCESSING DEVICE, EVALUATION SYSTEM, DATA CREATION METHOD, AND PROGRAM
JPS62170287A (en) Apparatus for forming stitch data of embroidering machine

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