CN1549207A - Method for filling closed area - Google Patents
Method for filling closed area Download PDFInfo
- Publication number
- CN1549207A CN1549207A CNA031367097A CN03136709A CN1549207A CN 1549207 A CN1549207 A CN 1549207A CN A031367097 A CNA031367097 A CN A031367097A CN 03136709 A CN03136709 A CN 03136709A CN 1549207 A CN1549207 A CN 1549207A
- Authority
- CN
- China
- Prior art keywords
- vertex
- ordinate
- path
- linked list
- previous
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 56
- 239000003550 marker Substances 0.000 claims 2
- 238000004364 calculation method Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000003247 decreasing effect Effects 0.000 description 1
Images
Landscapes
- Image Generation (AREA)
Abstract
一种封闭区域的填充方法。封闭区域系包围于由多个顶点形成的封闭路径。本方法包括以下步骤。首先,产生路径链表。路径链表包括多个节点,各节点用以记录封闭路径上的顶点或封闭路径上的各顶点之间的多个中介点。接着,依据路径链表产生填充数组链表。填充数组链表用以记录多个填充线段,各填充线段的两端点是位于封闭路径上,且这些填充线段位于封闭区域内。最后,依据这些填充线段填充此封闭区域。
A method for filling a closed area. The closed area is surrounded by a closed path formed by a plurality of vertices. The method comprises the following steps. First, a path linked list is generated. The path linked list comprises a plurality of nodes, each node being used to record a vertex on the closed path or a plurality of intermediate points between vertices on the closed path. Next, a filling array linked list is generated based on the path linked list. The filling array linked list is used to record a plurality of filling line segments, the two end points of each filling line segment being located on the closed path, and these filling line segments being located within the closed area. Finally, the closed area is filled based on these filling line segments.
Description
技术领域technical field
本发明涉及一种封闭区域的填充方法,且特别涉及一种封闭区域的快速填充方法。The invention relates to a filling method for a closed area, and in particular to a fast filling method for a closed area.
背景技术Background technique
请参照图1,其示出为传统的封闭区域填充方法的流程图。首先,得到路径上的顶点的坐标,如步骤110所示。这些顶点例如是第2图所示的顶点。然后,找出包含所有顶点的最小矩形,如步骤120所示。接着,在内存中开辟一块区域,与顶点所分布的最小矩形的区域相对应(一个byte对应一个像素),如步骤130所示。接着,在内存区域中,将封闭区域之外的所有点、封闭区域之内的所有点、路径的顶点、斜边 (包含垂直边,不包含顶点)和水平边(不包含顶点)以不同的值来标识,如步骤140所示。接着,逐行逐点扫描,根据当前点的位置和当前点所被标识的值来判断是否为填充线段的端点,如步骤150所示。最后,根据上面得到的填充线段的端点的值来填充此封闭区域,如步骤160所示。Please refer to FIG. 1 , which is a flow chart of a traditional closed area filling method. First, the coordinates of the vertices on the path are obtained, as shown in
以一个由100个顶点组成封闭路径为例,这些顶点分布在长宽为100×100(单位:像素)的区域上。在旧算法的第3步中,在判断一个点是否为封闭区域的内部的点时,需要将此点的坐标(共100×100个点)与路径上的所有顶点(共100个顶点)的坐标相比较,看其是否是路径的顶点。仅此一项,就需要判断约(100×100)×100次,即1000000次。大部分时间被消耗在这样的运算上。在步骤150中,判断当前点是否为填充线段的端点时,需要对这100×100个点逐一进行判断,运算量较大。Take a closed path composed of 100 vertices as an example, and these vertices are distributed on an area whose length and width are 100×100 (unit: pixel). In the third step of the old algorithm, when judging whether a point is inside a closed area, it is necessary to compare the coordinates of this point (a total of 100×100 points) with the coordinates of all vertices on the path (a total of 100 vertices) Coordinates are compared to see if they are vertices of the path. For this item alone, it is necessary to judge about (100×100)×100 times, that is, 1,000,000 times. Most of the time is consumed in such operations. In
在步骤130中,需要在内存中开辟一块区域(100×100byte)与顶点所分布的长宽为100×100(单位:像素)的区域对应。当顶点分布的区域很大时,将占用大量的内存空间。In
发明内容Contents of the invention
有鉴于此,本发明的目的就是在提供一种封闭区域的快速填充方法。In view of this, the object of the present invention is to provide a fast filling method for closed areas.
根据本发明的目的,提出一种封闭区域的填充方法。封闭区域是包围在由多个顶点形成的封闭路径。本方法包括以下步骤。首先,产生路径链表。路径链表包括多个节点,各节点用以记录封闭路径上的顶点或封闭路径上的各顶点之间的多个中介点。接着,依据路径链表产生填充数组链表。填充数组链表用以记录多个填充线段,各填充线段的两端点位于封闭路径上,且这些填充线段位于封闭区域内。最后,依据这些填充线段填充此封闭区域。According to the object of the present invention, a method of filling an enclosed area is proposed. A closed region is enclosed in a closed path formed by multiple vertices. The method includes the following steps. First, generate a path linked list. The path link list includes multiple nodes, and each node is used to record vertices on the closed path or multiple intermediate points between vertices on the closed path. Next, a filled array linked list is generated according to the path linked list. The filling array linked list is used to record a plurality of filling line segments, the two ends of each filling line segment are located on the closed path, and these filling line segments are located in the closed area. Finally, fill this closed area according to these filled line segments.
根据本发明的填充方法,具有以下优点:1.降低运算量:According to the filling method of the present invention, it has the following advantages: 1. reduce the amount of computation:
a.不用如同传统方法需对封闭区域内的所有像素逐点判断,而只对封闭路径上的像素进行判断,因此可以降低运算量。b.没有复杂的乘除计算,大多为简单的数值比较,因此可以降低运算量。2.降低内存的需求:传统方法需要一块内存,与包围所有顶点的最小矩形的所有像素对应,因此需要耗费较多的内存。而本方法只需路径链表、填充数组链表等,需要占用的内存较小。a. Instead of judging all the pixels in the closed area point by point as in the traditional method, only the pixels on the closed path are judged, so the amount of computation can be reduced. b. There are no complex multiplication and division calculations, and most of them are simple numerical comparisons, so the amount of calculation can be reduced. 2. Reduce memory requirements: The traditional method requires a block of memory corresponding to all the pixels of the smallest rectangle surrounding all vertices, so more memory is required. However, this method only needs to route the linked list, fill the array linked list, etc., and requires less memory.
附图说明Description of drawings
为让本发明的上述目的、特征、和优点能更明显易懂,下文特举一较佳实施例,并配合所附图式,作详细说明如下:In order to make the above-mentioned purposes, features, and advantages of the present invention more comprehensible, a preferred embodiment is specifically cited below, and in conjunction with the accompanying drawings, the detailed description is as follows:
图1示出为传统的封闭区域填充方法的流程图。FIG. 1 shows a flow chart for a traditional closed area filling method.
图2示出平面上的多个顶点分布图。Fig. 2 shows a graph of distribution of multiple vertices on a plane.
图3示出依照本发明的优选实施例的一种封闭区域的填充方法的流程图。Fig. 3 shows a flowchart of a method for filling a closed area according to a preferred embodiment of the present invention.
图4A示出决定顶点的线标志的流程图。FIG. 4A shows a flowchart for determining the line label of a vertex.
图4B示出决定顶点的点标志的流程图。FIG. 4B shows a flowchart for determining the point label of a vertex.
图4C示出决定顶点的端点标志的方法流程图。FIG. 4C shows a flowchart of a method for determining an endpoint flag of a vertex.
图4D及4E示出产生路径链表的方法流程图。4D and 4E show the flowchart of the method for generating the path link list.
图5A为路径链表P所链接的像素示意图。FIG. 5A is a schematic diagram of pixels linked by the path list P.
图5B为路径链表P中的内容。FIG. 5B shows the content in the path list P.
图6A及6B示出产生填充数组链表的方法流程图。6A and 6B show a flowchart of a method for generating a filled array linked list.
图7为依照第6A及6B图的流程所产生的填充数组链表的内容。FIG. 7 shows the contents of the filled array linked list generated according to the flow in FIGS. 6A and 6B.
图8示出填充后的封闭区域示意图。Fig. 8 shows a schematic diagram of the closed area after filling.
具体实施方式Detailed ways
图2示出平面上的多个顶点分布图。顶点(0)~顶点(10)的坐标分别为(6,0)、(2,4)、(5,4)、(0,8)、(5,8)、(5,12)、(7,12)、(7,8)、(12,8)、(7,4)及(10,4)。最后一个顶点(11)也是顶点(0)。这些顶点围成一封闭路径,封闭路径包围一封闭区域。以下的说明将以第2图的这些顶点为例作说明。图3示出依照本发明的较佳实施例的一种封闭区域的填充方法的流程图。首先接收这些顶点,如步骤300所示。以顶点数组依序记录这些顶点的坐标,且路径的最后一个顶点即为第一个顶点。接着,依据这些顶点计算出封闭路径上的所有介于顶点之间的中介点,并将这些顶点及中介点依封闭路径的顺序存入路径链表(linked list)P,如步骤400所示。然后,依据此路径链表P求得填充数组链表G,如步骤500所示。填充数组链表G即记录所需填充的水平线段的两端的点。最后依据填充数组链表G填充此封闭区域,如步骤600所示。Fig. 2 shows a graph of distribution of multiple vertices on a plane. The coordinates of vertices (0) to (10) are (6, 0), (2, 4), (5, 4), (0, 8), (5, 8), (5, 12), ( 7,12), (7,8), (12,8), (7,4) and (10,4). The last vertex (11) is also vertex (0). These vertices enclose a closed path, and the closed path encloses a closed area. The following description will take these vertices in Fig. 2 as examples. Fig. 3 shows a flowchart of a method for filling a closed area according to a preferred embodiment of the present invention. These vertices are first received, as shown in
在步骤400中,产生路径链表P的方法说明如下。首先,决定各顶点的属性,示于第4A图至4C图的流程图。接着,计算出封闭路径上的所有介于顶点之间的中介点并将这些顶点及中介点依封闭路径的顺序存入路径链表P,示于第4D及4E图的流程图。In
各顶点具有纵坐标x、横坐标y,并且依据顶点与其它顶点的相对位置而有不同的属性,以线标志(flag)F1、点标志Fp及端点标志Fe表示。当前顶点以顶点(r)表示,前一顶点以顶点(r-1)表示,后一顶点以顶点(r+1)表示。若当前顶点(r)为第一个,也就是顶点(0),则顶点(r-1)为顶点(10);同理,若当前顶点(r)为顶点(11),则顶点(r+1)为顶点(1)。r为正整数。Each vertex has an ordinate x and an abscissa y, and has different attributes depending on the relative position of the vertex and other vertices, represented by a line flag (flag) F1, a point flag Fp, and an endpoint flag Fe. The current vertex is represented by vertex (r), the previous vertex is represented by vertex (r-1), and the next vertex is represented by vertex (r+1). If the current vertex (r) is the first one, that is, vertex (0), then vertex (r-1) is vertex (10); similarly, if the current vertex (r) is vertex (11), then vertex (r +1) for vertex (1). r is a positive integer.
图4A示出决定顶点的线标志的流程图。线标志F1是依据当前顶点与前一顶点所形成的线段而决定为水平、垂直或倾斜。首先,检查当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)是否相等,如步骤310所示。若是,表示当前顶点(r)与前一顶点(r-1)的线段为水平,则将当前顶点(r)的线标志F1标示为水平,如步骤312所示,例如顶点(2)。否则检查当前顶点(r)的横坐标x(r)与前一顶点(r-1)的横坐标x(r-1)是否相等,如步骤314所示。若是,则当前顶点(r)的线标志F1标示为垂直,如步骤316所示,例如顶点(5)。若否,表示顶点(r)的横坐标x(r)与纵坐标y(r)分别与前一顶点(r-1)的横坐标x(r-1)与纵坐标y(r-1)不同,则将当前顶点(r)的线标志F1标示为倾斜,如步骤318所示,例如顶点(1)。FIG. 4A shows a flowchart for determining the line label of a vertex. The line flag F1 is determined to be horizontal, vertical or inclined according to the line segment formed by the current vertex and the previous vertex. First, it is checked whether the ordinate y(r) of the current vertex (r) is equal to the ordinate y(r-1) of the previous vertex (r-1), as shown in
图4B示出决定顶点的点标志的流程图。点标志Fp是依据当前顶点(r)与前一顶点(r-1)及后一顶点(r+1)的相对位置而决定为A型、C型、L1型或L2型。首先检查当前顶点(r)的纵坐标y(r)是否同时大于前一顶点(r-1)的纵坐标y(r-1)与后一顶点(r+1)的纵坐标y(r+1),如步骤320所示。若是,则当前顶点(r)的点标志Fp是A型,例如顶点(0)。若否,检查当前顶点(r)的纵坐标y(r)是否同时小于前一顶点(r-1)的纵坐标y(r-1)与后一顶点(r+1)的纵坐标y(r+1),如步骤324所示。若是,则当前顶点(r)的点标志Fp为A型,如步骤322所示。若否,检查当前顶点(r)的纵坐标y是否介于前一顶点(r-1)的纵坐标y(r-1)与后一顶点(r+1)的纵坐标y(r+1)之间,如步骤326所示。若是,则当前顶点(r)的点标志Fp为C型,如步骤328所示。若否,则表示当前顶点(r)的纵坐标与前一顶点(r-1)或后一顶点(r+1)的纵坐标相同。此时,检查当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)是否相同,如步骤330所示。若是则表示当前顶点(r)与前一顶点(r-1)的线段为水平,进行步骤332;否则表示当前顶点(r)与后一顶点(r+1)的线段是水平,进行步骤334。在步骤332中,检查当前顶点(r)的横坐标x是否大于前一顶点(r-1)的横坐标x。若是,则顶点(r)的点标志Fp是L2型,如步骤338所示,例如顶点(2);若否,则当前顶点(r)的点标志Fp是L1型,如步骤336所示。在步骤334中,检查当前顶点(r)的横坐标x(r)是否大于后一顶点(r+1)的横坐标x(r+1)。若是,则当前顶点(r)的点标志Fp是L2型,如步骤338所示;若否,则当前顶点(r)的点标志Fp是L1型,如步骤336所示。FIG. 4B shows a flowchart for determining the point label of a vertex. The point flag Fp is determined as type A, type C, type L1 or type L2 according to the relative positions of the current vertex (r) and the previous vertex (r-1) and the next vertex (r+1). First check whether the ordinate y(r) of the current vertex (r) is greater than the ordinate y(r-1) of the previous vertex (r-1) and the ordinate y(r+) of the next vertex (r+1) at the same time 1), as shown in
图4C示出决定顶点的端点标志的方法流程图。在步骤340中,检查三个条件,若此三个条件之一成立,则表示顶点(r)的端点标志Fe为真(步骤342),否则表示顶点(r)的端点标志Fe为伪(步骤344)。第一条件为:当前顶点(r)的纵坐标y(r)小于后一顶点(r+1)的纵坐标y(r+1),且大于等于前一顶点(r-1)的纵坐标y(r-1)。第二条件为:当前顶点(r)的纵坐标y(r)小于前一顶点(r-1)的纵坐标y(r-1),且大于等于后一顶点(r+1)的纵坐标y(r+1)。第三条件为:当前顶点(r)的点标志Fp为A型或C型。若端点标志Fe为真,表示顶点(r)是填充线段的端点。重复图4A至4C所示的流程,直到所有的顶点皆已求得其线标志F1、点标志Fp及端点标志Fe。FIG. 4C shows a flowchart of a method for determining an endpoint flag of a vertex. In
接下来要计算出封闭路径上的所有介于顶点之间的中介点,并将这些顶点及中介点依封闭路径的顺序存入路径链表P。图4D及4E示出产生路径链表的方法流程图。依据当前顶点(r)的线标志F1而决定求得中介点的方法及插入路径链表P的顺序。在步骤350中,判断当前顶点(r)的线标志F1是否为水平,若是则执行步骤352。在步骤354中,判断当前顶点(r)的线标志F1是否为垂直,若是则执行步骤356~362。若步骤350与354的判断结果皆否,则当前顶点(r)的线标志F1为倾斜,执行步骤363~368。Next, calculate all intermediate points between vertices on the closed path, and store these vertices and intermediate points in the path list P in the order of the closed path. 4D and 4E show the flowchart of the method for generating the path link list. The method of obtaining the intermediate point and the order of inserting into the path list P are determined according to the line flag F1 of the current vertex (r). In
若当前顶点(r)的线标志F1为水平,则将当前顶点(r)插入路径链表P的末尾(步骤352),并执行步骤370以判断当前顶点(r)是否插入路径链表P。也就是说,顶点(r)与顶点(r-1)的线段若为水平,则不将其中介点记录在路径链表P。If the line flag F1 of the current vertex (r) is horizontal, the current vertex (r) is inserted into the end of the path list P (step 352), and step 370 is executed to determine whether the current vertex (r) is inserted into the path list P. That is to say, if the line segment between the vertex (r) and the vertex (r-1) is horizontal, the intermediate point will not be recorded in the path list P.
若当前顶点(r)的线标志F1为垂直,首先在步骤356中判断:当前顶点(r)的纵坐标y(r)是否大于前一顶点(r-1)的纵坐标y(r-1),也就是顶点(r)在顶点(r-1)的下方,且当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)之差大于2,也就是顶点(r)与顶点(r-1)之间有中介点。若是,则依序将顶点(r-1)至顶点(r)之间的中介点插入路径链表P,也就是依纵坐标递增的顺序(步骤358);否则进入步骤360。在步骤360中判断:当前顶点(r)的纵坐标y(r)是否小于前一顶点(r-1)的纵坐标y(r-1),也就是顶点(r)在顶点(r-1)的上方,且当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)之差大于2,也就是顶点(r)与顶点(r-1)之间有中介点。若是则依序将顶点(r-1)至顶点(r)之间的中介点插入路径链表P,也就是依纵坐标递减的顺序(步骤358);否则进入步骤370。If the line mark F1 of current vertex (r) is vertical, at first judge in step 356: Whether the ordinate y (r) of current vertex (r) is greater than the ordinate y (r-1) of previous vertex (r-1) ), that is, the vertex (r) is below the vertex (r-1), and the ordinate y(r) of the current vertex (r) and the ordinate y(r-1) of the previous vertex (r-1) The difference is greater than 2, that is, there is an intermediate point between the vertex (r) and the vertex (r-1). If yes, then sequentially insert the intermediate points between the vertex (r-1) and the vertex (r) into the path list P, that is, in the order of increasing ordinate (step 358); otherwise, go to step 360. Judging in step 360: whether the ordinate y(r) of the current vertex (r) is less than the ordinate y(r-1) of the previous vertex (r-1), that is, the vertex (r) is at the vertex (r-1) ), and the difference between the vertical coordinate y(r) of the current vertex (r) and the vertical coordinate y(r-1) of the previous vertex (r-1) is greater than 2, that is, the difference between the vertex (r) and the vertex (r -1) There is an intermediate point between them. If so, insert the intermediate points between the vertex (r-1) and the vertex (r) into the path list P in order, that is, in the order of decreasing ordinate (step 358); otherwise, go to step 370.
若当前顶点(r)的线标志F1为倾斜,首先在步骤363中判断:当前顶点(r)的纵坐标y(r)是否大于前一顶点(r-1)的纵坐标y(r-1),也就是顶点(r)在顶点(r-1)的下方,且当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)之差大于2,也就是顶点(r)与顶点(r-1)之间有中介点。若是则依序将顶点(r-1)至顶点(r)之间的中介点插入路径链表P,也就是依纵坐标递增的顺序(步骤364);否则进入步骤366。这些中介点是依据顶点(r)与顶点(r-1)的直线方程式求得。在步骤366中判断:当前顶点(r)的纵坐标y(r)是否小于前一顶点(r-1)的纵坐标y(r-1),也就是顶点(r)在顶点(r-1)的上方,且当前顶点(r)的纵坐标y(r)与前一顶点(r-1)的纵坐标y(r-1)之差大于2,也就是顶点(r)与顶点(r-1)之间有中介点。若是则依序将顶点(r-1)至顶点(r)之间的中介点插入路径链表P,也就是依纵坐标递减的顺序(步骤368);否则进入步骤370。这些中介点是依据顶点(r)与顶点(r-1)的直线方程式求得。在步骤370中,若当前顶点(r)并非路径最后的顶点,则将顶点(r)插入路径链表P的末端。重复第4D及4E图所示的方法,直到所有顶点及中介点皆已按照封闭路径的顺序存入路径链表P。If the line mark F1 of current vertex (r) is inclined, at first judge in step 363: Whether the ordinate y (r) of current vertex (r) is greater than the ordinate y (r-1) of previous vertex (r-1) ), that is, the vertex (r) is below the vertex (r-1), and the ordinate y(r) of the current vertex (r) and the ordinate y(r-1) of the previous vertex (r-1) The difference is greater than 2, that is, there is an intermediate point between the vertex (r) and the vertex (r-1). If so, insert the intermediate points between the vertex (r-1) and the vertex (r) into the path list P in order, that is, in the order of increasing ordinate (step 364); otherwise, go to step 366. These intermediary points are obtained according to the straight line equation of the vertex (r) and the vertex (r-1). In
图5A为路径链表P所链接的像素示意图。除了顶点,顶点之间的中介点亦被求出,且水平线上的两顶点是不记录其间的中介点,例如顶点(1)与顶点(2)之间是没有记录中介点。图5B为路径链表P中的内容。路径链表P中的每个元素即对应到一个顶点或一个中介点,每个元素包括有横坐标x、纵坐标y、索引index、点标志Fp、端点标志Fe及指标next。索引index用以记录每个顶点的顺序,中介点的索引index则均为-1,例如顶点(0)的索引index即为0。中介点的点标志Fp皆为C型。端点标志Fe若为真,则在路径链表P中以1表示,否则以0表示。指标next用以指向下一个节点。各元素即依封闭路径的顺序依序链接。FIG. 5A is a schematic diagram of pixels linked by the path list P. In addition to the vertices, the intermediate point between the vertices is also calculated, and the intermediate point between the two vertices on the horizontal line is not recorded, for example, there is no intermediate point recorded between the vertex (1) and the vertex (2). FIG. 5B shows the content in the path list P. Each element in the path list P corresponds to a vertex or an intermediate point, and each element includes an abscissa x, a ordinate y, an index index, a point symbol Fp, an endpoint symbol Fe and an index next. The index index is used to record the order of each vertex, and the index index of the intermediate point is -1, for example, the index index of the vertex (0) is 0. The point markers Fp of the intermediate points are all C-type. If the endpoint flag Fe is true, it will be represented by 1 in the path list P, otherwise it will be represented by 0. The indicator next is used to point to the next node. The elements are linked sequentially in the order of the closed path.
再来将对步骤500中产生填充数组链表的方法作详细说明。首先依据封闭路径的高度h申请一块填充数组链表G。在本例中,h是13。填充数组链表G的每一个数组是对应一个链表,一个链表是对应至同一列的像素。例如G[0]是对应纵坐标y=0的像素,G[1]是对应纵坐标y=1的像素,...,G[12]是对应纵坐标y=12的像素。另外,G[13]所指向的链表则用来记录封闭路径上所有的水平线。每个G[]所指向的链表包括填充线段的两个端点。依据填充线段即可填充这些顶点所包围的封闭区域。图6A及6B示出产生填充数组链表G的方法流程图。封闭路径上的所有顶点及中介点,也就是路径链表P的各节点,都依序依此方法填入填充数组链表G。首先检查节点是否为中介点(步骤512),若是则将此节点依其纵坐标y写入对应的填充数组链表G[y](步骤514),若否表示此节点为顶点。在步骤520中,检查此顶点的点标志Fp是否为A型,若是则依其纵坐标y写入对应的填充数组链表G[y]两次。因点标志Fp若为A型,例如是第2图中的顶点A,表示同一条水平线只有这一点,所以写入两次表示此填充线段的起点与终点是同一点。再来则检查顶点的点标志Fp是否为L1或L2型(步骤530)若是,表示此顶点是位于封闭路径的水平线段上,进行步骤532,否则进行步骤540。在步骤532中,将此顶点写入填充数组链表G[h],接着将填充数组链表G[h]中的此顶点的端点标志Fe改成真(步骤534)。然后检查路径链表P中的此顶点的端点标志Fe是否为真(步骤536),若是则将此顶点依其纵坐标y写入对应的填充数组链表G[y](步骤538)。若顶点的点标志Fp为C型,则将此顶点依其纵坐标y写入对应的填充数组链表G[y](步骤540)。Next, the method for generating the filled array linked list in
图7示出依照图6A及6B的流程所产生的填充数组链表的内容。填充数组链表G[0]是对应至y=0的填充线段(6,0)(6,0),填充数组链表G[1]是对应至y=1的填充线段(5,1)(7,1),填充数组链表G[2]是对应至y=2的填充线段(4,2)(8,2),填充数组链表G[3]是对应至y=3的填充线段(3,3)(9,3),...,填充数组链表G[11]是对应至y=11的填充线段(5,11)(7,11)。填充数组链表G[12]是对应至y=12的填充线段,此处并无填充线段。填充数组链表G[h],也就是G[13],是水平链表,用来记录封闭路径上所有的水平线(2,4)(5,4)、(0,8)(5,8)、(5,12)(7,12)(7,8)(12,8)及(7,4)(10,4)。FIG. 7 shows the content of the filled array linked list generated according to the process of FIGS. 6A and 6B . The filling array linked list G[0] is the filling line segment (6,0)(6,0) corresponding to y=0, and the filling array linked list G[1] is the filling line segment (5,1)(7) corresponding to y=1 , 1), the filling array linked list G[2] is the filling line segment (4,2)(8,2) corresponding to y=2, and the filling array linked list G[3] is the filling line segment (3, 2) corresponding to y=3 3) (9, 3), ..., the filling array linked list G[11] is the filling line segment (5, 11) (7, 11) corresponding to y=11. The filling array linked list G[12] is a filling line segment corresponding to y=12, and there is no filling line segment here. The filled array linked list G[h], that is, G[13], is a horizontal linked list used to record all horizontal lines (2, 4) (5, 4), (0, 8) (5, 8), (5,12)(7,12)(7,8)(12,8) and (7,4)(10,4).
最后依据填充数组链表G填充封闭区域。请参照图8,其示出为填充后的封闭区域示意图。依据填充数组链表G可以得到填充线段的端点坐标,将各填充线段的端点以特定的颜色连接,将所有的填充线段及封闭路径上的水平线段着色完毕,也就完成了封闭区域的填充。Finally, the closed area is filled according to the filled array linked list G. Please refer to FIG. 8 , which is a schematic diagram of the closed area after filling. The end point coordinates of the filled line segments can be obtained according to the filled array linked list G, and the end points of each filled line segment are connected with a specific color, and all the filled line segments and the horizontal line segments on the closed path are colored, and the closed area is filled.
本发明上述实施例所公开的封闭区域的填充方法,具有以下优点:The method for filling the enclosed area disclosed in the above embodiments of the present invention has the following advantages:
1.降低运算量:1. Reduce the amount of computation:
a.不用如同传统方法需对封闭区域内的所有像素逐点判断,而只对封闭路径上的像素进行判断,因此可以降低运算量。a. Instead of judging all the pixels in the closed area point by point as in the traditional method, only the pixels on the closed path are judged, so the amount of computation can be reduced.
b.没有复杂的乘除计算,大多为简单的数值比较,因此可以降低运算量。b. There are no complex multiplication and division calculations, and most of them are simple numerical comparisons, so the amount of calculation can be reduced.
2.降低内存的需求:传统方法需要一块内存,与包围所有顶点的最小矩形的所有像素对应,因此需要耗费较多的内存。而本方法只需路径链表、填充数组链表等,需要占用的内存较小。2. Reduce memory requirements: The traditional method requires a block of memory corresponding to all the pixels of the smallest rectangle surrounding all vertices, so more memory is required. However, this method only needs to route the linked list, fill the array linked list, etc., and requires less memory.
综上所述,虽然本发明按照上述优选实施例公开,然而并非用以限定本发明,任何本领域的技术人员,在不脱离本发明的精神和范围内,可改变或者改进,因此本发明的保护范围以权利要求书所述为准。In summary, although the present invention is disclosed according to the above-mentioned preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can change or improve without departing from the spirit and scope of the present invention. Therefore, the present invention The scope of protection is subject to what is described in the claims.
Claims (22)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB031367097A CN1313978C (en) | 2003-05-21 | 2003-05-21 | Filling methods for closed areas |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB031367097A CN1313978C (en) | 2003-05-21 | 2003-05-21 | Filling methods for closed areas |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1549207A true CN1549207A (en) | 2004-11-24 |
CN1313978C CN1313978C (en) | 2007-05-02 |
Family
ID=34323434
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB031367097A Expired - Fee Related CN1313978C (en) | 2003-05-21 | 2003-05-21 | Filling methods for closed areas |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN1313978C (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2010034267A1 (en) * | 2008-09-28 | 2010-04-01 | 北大方正集团有限公司 | Method and apparatus for simplifying complicated path |
CN101276334B (en) * | 2007-03-29 | 2011-04-06 | 上海新跃仪表厂 | Linked list implementing method for quickly searching data |
CN108096835A (en) * | 2018-01-26 | 2018-06-01 | 珠海金山网络游戏科技有限公司 | The area filling method and device of a kind of map |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1154959C (en) * | 2001-02-15 | 2004-06-23 | 英业达股份有限公司 | System and method for edge covering processing of graphics and characters |
CN1177287C (en) * | 2001-04-18 | 2004-11-24 | 无敌科技(西安)有限公司 | Automatic format setting method for palm-type browser |
-
2003
- 2003-05-21 CN CNB031367097A patent/CN1313978C/en not_active Expired - Fee Related
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101276334B (en) * | 2007-03-29 | 2011-04-06 | 上海新跃仪表厂 | Linked list implementing method for quickly searching data |
WO2010034267A1 (en) * | 2008-09-28 | 2010-04-01 | 北大方正集团有限公司 | Method and apparatus for simplifying complicated path |
US8773440B2 (en) | 2008-09-28 | 2014-07-08 | Peking University Founder Group Co., Ltd | Method and device for simplifying a complex path |
CN108096835A (en) * | 2018-01-26 | 2018-06-01 | 珠海金山网络游戏科技有限公司 | The area filling method and device of a kind of map |
Also Published As
Publication number | Publication date |
---|---|
CN1313978C (en) | 2007-05-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8194071B2 (en) | Tile based graphics rendering | |
CN104778024B (en) | A kind of electronic Chart Display method and system | |
CN105279243A (en) | Spatial data conversion method and system | |
CN108830385B (en) | Deep learning model training method and device and computer readable storage medium | |
US20150084983A1 (en) | Method and apparatus for generating an output surface from one or more input surfaces in data processing systems | |
CN111524211B (en) | Handwriting erasing method, handwriting erasing device and handwriting erasing equipment | |
CN104243820A (en) | Method and device for determining boundary of image | |
Becker et al. | Unsteady flow volumes | |
CN107564077B (en) | method and device for drawing road network | |
CN1313978C (en) | Filling methods for closed areas | |
CN104424841A (en) | Map display apparatus and display method of character strings on map | |
CN105704405B (en) | Image sensing device and defective pixel detection and compensation method | |
CN112069282A (en) | Road zebra crossing generation method, electronic device and storage medium | |
JP5362915B2 (en) | Drawing apparatus and drawing method | |
CN114417998B (en) | Data feature mapping method, device, equipment and storage medium | |
CN116862866A (en) | A method and device for segmentation and detection of pavement cracks | |
CN107832369B (en) | Method and device for generating dynamic particle flow of road conditions | |
CN115964080A (en) | Visual image-based code clone detection method, system, device and medium | |
CN110413714B (en) | Gridding Method of Vector Elements in Topologically Fidelity Global Discrete Grid System | |
CN115063684A (en) | A kind of agricultural machinery trajectory recognition method based on remote sensing image scene division and its application method | |
CN103246689B (en) | The Forecasting Methodology of a kind of raster data and device | |
CN110807113B (en) | Non-iterative elimination method for rectangular primitive overlap in visual layout | |
CN110873896B (en) | Method and system for intelligently analyzing seismic trace head information | |
US7542054B2 (en) | Apparatus and method for image quality improvement while scaling and scrolling the image | |
CN116134488A (en) | Point cloud labeling method, point cloud labeling device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C19 | Lapse of patent right due to non-payment of the annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |