Polygon trapezoidal segmentation method and device based on double scanning lines, medium, terminal and program product

By using a dual-scan-line polygon trapezoidal segmentation method, the problem of single-direction scan lines being unable to incorporate constraints is solved, and constraints on side length and area are achieved during polygon trapezoidal segmentation, thus meeting actual industrial needs.

CN121353299APending Publication Date: 2026-01-16HUAXINCHENG (HANGZHOU) TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511906931.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

Existing polygon trapezoidalization algorithms can only be based on a unidirectional scan line strategy, which cannot incorporate constraints during the segmentation process, resulting in segmentation results that cannot meet the needs of practical applications.

Method used

A polygon trapezoidal segmentation method based on dual scanning lines is adopted. The polygon vertices are sorted in both directions, and the first and second scanning lines are issued to traverse the vertices respectively. The processing results are judged to determine whether they meet the preset constraints, such as the shortest side of the trapezoid and the minimum area, and the optimal segmentation method is selected.

Benefits of technology

It incorporates engineering constraints into the polygon trapezoidal segmentation process to ensure that the segmentation results meet actual industrial needs, such as trapezoidal side length and area thresholds, thereby improving algorithm efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121353299A_ABST
    Figure CN121353299A_ABST
Patent Text Reader

Abstract

The invention provides a polygon trapezoidal segmentation method and device based on double scanning lines, a medium, a terminal and a program product, and the method comprises the steps: carrying out the sorting of all vertexes of an obtained polygon according to a preset sorting standard, so as to obtain first sorting data and second sorting data; simultaneously emitting a first scanning line and a second scanning line, and respectively traversing vertexes in the first sorting data and the second sorting data according to a preset scanning direction for processing; whether the first processing result and the second processing result meet preset constraint conditions or not is judged, and if the first processing result meets the constraint conditions, the first processing result is selected as an optimal result; and if the second processing result meets the constraint condition, selecting the second processing result as an optimal result. According to the method, the to-be-segmented polygon is subjected to trapezoidal segmentation based on the double scanning lines, and the constraint condition is fused in the segmentation process, so that the segmentation mode meeting the constraint condition is selected, and the actual application requirement is better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer image processing technology, and in particular to a method, apparatus, medium, terminal and program product for polygon trapezoidal segmentation based on dual scan lines. Background Technology

[0002] Polygon trapezoidation is a fundamental and important technique in computational geometry. Its goal is to divide simple polygons (i.e., non-self-intersecting polygons) into a set of trapezoids (including degenerate trapezoids such as triangles). The basic idea is to introduce a scan line along a horizontal or vertical direction. When the scan line passes through a vertex of the polygon, an event is triggered. The algorithm maintains the state of the scan line and processes these events, inserting vertical (or horizontal) line segments inside the polygon, thus dividing it into trapezoids. The core value of this process lies in decomposing complex polygons into simple, easily processed basic units, simplifying subsequent geometric calculations and analysis. It is mainly applied in scanline rendering in computer graphics and rendering, spatial analysis and region division in geographic information systems, machining path planning in computer-aided design, and geometric preparation before graphic engraving in EDA (Electronic Design Automation) fields.

[0003] However, existing polygon trapezoidalization algorithms are generally based on a single-direction scan line strategy. That is, the algorithm can only perform trapezoidalization along the horizontal or vertical direction. This single-direction scan trapezoidalization can only simply and crudely segment polygons into trapezoids, without incorporating constraints into the segmentation process, resulting in segmentation results that cannot meet the needs of practical applications.

[0004] Therefore, it is necessary to provide a polygon trapezoidal segmentation method, apparatus, medium, terminal, and program product based on dual scanning lines to solve the above-mentioned problems existing in the prior art. Summary of the Invention

[0005] In view of the shortcomings of the prior art described above, the purpose of this application is to provide a polygon trapezoidal segmentation method, device, medium, terminal and program product based on dual scanning lines, to solve the technical problems inherent in the prior art of unidirectional scanning and the inability to incorporate constraints into the segmentation process.

[0006] To achieve the above and other related objectives, the first aspect of this application provides a polygon trapezoidal segmentation method based on dual scan lines, comprising:

[0007] Obtain the polygon to be segmented, and sort each vertex of the obtained polygon according to a preset first sorting standard and a second sorting standard to obtain first sorting data and second sorting data.

[0008] A first scan line is sent out to traverse the vertices in the first sorted data in a first preset scan direction to process them and obtain a first processing result; at the same time, a second scan line is sent out to traverse the vertices in the second sorted data in a second preset scan direction to process them and obtain a second processing result.

[0009] Determine whether the first processing result and the second processing result meet the preset constraints. If the first processing result meets the constraints, then the first processing result is selected as the optimal result; if the second processing result meets the constraints, then the second processing result is selected as the optimal result.

[0010] In some embodiments of the first aspect of this application, the specific process of sorting each vertex of the obtained polygon according to a preset first sorting standard and a second sorting standard to obtain first sorted data and second sorted data includes: sorting each vertex of the polygon according to a first sorting standard where the vertical coordinate of a specified coordinate axis is from largest to smallest and the horizontal coordinate is from smallest to largest, and storing the sorted data to obtain the first sorted data; and sorting each vertex of the polygon according to a second sorting standard where the horizontal coordinate of a specified coordinate axis is from smallest to largest and the vertical coordinate is from largest to smallest, and storing the sorted data to obtain the second sorted data.

[0011] In some embodiments of the first aspect of this application, the step of issuing a first scan line to traverse the vertices in the first sorted data according to a first preset scan direction to obtain a first processing result specifically includes: issuing a first scan line according to the first preset scan direction, moving sequentially to the vertices in the first sorted data, and performing the following steps at each vertex: storing the line segment connected to the vertex and projected in the first preset scan direction, and determining whether there is a ray in the second preset scan direction at the vertex; if there is no ray in the second preset scan direction at the vertex, no processing is required; if there is a ray in the second preset scan direction at the vertex, and the projection point of the ray falls on another vertex of the stored line segment, then connecting the two vertices to form a first internal line segment to obtain the first processing result; repeating the above execution steps at each vertex until all vertices in the first sorted data have been traversed.

[0012] In some embodiments of the first aspect of this application, the step of issuing a second scan line to traverse the vertices in the second sorted data according to a second preset scan direction to obtain a second processing result includes: issuing a second scan line according to the second preset scan direction, moving sequentially to the vertices in the second sorted data, and performing the following steps at each vertex: storing the line segment connected to the current vertex and projected in the second preset scan direction, and determining whether there is a ray in the first preset scan direction at the current vertex; if there is no ray in the first preset scan direction at the current vertex, no processing is required; if there is a ray in the first preset scan direction at the current vertex, and the projection point of the ray falls on another vertex of the stored line segment, then connecting these two vertices to form a second internal line segment to obtain a second processing result; repeating the above execution steps at each vertex until all vertices in the second sorted data have been traversed.

[0013] In some embodiments of the first aspect of this application, the constraints include one or more of the following: the shortest side of the trapezoid, the minimum area of ​​the trapezoid, and a threshold for the number of trapezoids.

[0014] In some embodiments of the first aspect of this application, when the constraint condition is the shortest side of the trapezoid, it is determined whether the internal line segments obtained by scanning the first scan line and the second scan line to the same vertex satisfy the shortest side of the trapezoid; if the internal line segments obtained by scanning the first scan line satisfy the shortest side of the trapezoid, then the segmentation method of scanning the first scan line is the optimal segmentation method; if the internal line segments obtained by scanning the second scan line satisfy the shortest side of the trapezoid, then the segmentation method of scanning the second scan line is the optimal segmentation method.

[0015] To achieve the above and other related objectives, a second aspect of this application provides a polygon trapezoidal segmentation device based on dual scanning lines, comprising:

[0016] The sorting module is used to acquire the polygon to be segmented and sort each vertex of the acquired polygon according to a preset first sorting standard and a second sorting standard to obtain first sorting data and second sorting data.

[0017] The dual-scan-line processing module is used to send out a first scan line to traverse the vertices in the first sorted data according to a first preset scan direction to process them and obtain a first processing result; at the same time, it sends out a second scan line to traverse the vertices in the second sorted data according to a second preset scan direction to process them and obtain a second processing result.

[0018] The judgment module is used to determine whether the first processing result and the second processing result meet the preset constraints. If the first processing result meets the constraints, the first processing result is selected as the optimal result; if the second processing result meets the constraints, the second processing result is selected as the optimal result.

[0019] To achieve the above and other related objectives, a third aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method.

[0020] To achieve the above and other related objectives, a fourth aspect of this application provides a computer program product comprising computer program code that, when executed on a computer, causes the computer to implement the method.

[0021] To achieve the above and other related objectives, a fifth aspect of this application provides an electronic terminal, including a memory, a processor, and a computer program stored in the memory; the processor executes the computer program to implement the method.

[0022] As described above, the polygon trapezoidal segmentation method, apparatus, medium, terminal, and program product based on dual scan lines of this application have the following beneficial effects:

[0023] The process involves sorting the vertices of the polygon to be segmented according to a first and a second preset sorting standard to obtain first and second sorted data. Then, a first and a second scan line are simultaneously emitted. The first scan line traverses the vertices in the first sorted data one by one according to a first preset scan direction to obtain a first processing result. Similarly, the second scan line traverses the vertices in the second sorted data one by one according to a second preset scan direction to obtain a second processing result. Finally, based on pre-set constraints, it is determined whether the first processing result obtained by the first scan line segmentation and the second processing result obtained by the second scan line segmentation satisfy the constraints. This allows the optimal segmentation method to be selected based on the constraints incorporated into the trapezoidal segmentation process, ensuring that the final processing result better meets the needs of practical applications. Attached Figure Description

[0024] Figure 1 The diagram shown is a flowchart of a polygon trapezoidal segmentation method based on dual scan lines in one embodiment of this application.

[0025] Figure 2 The diagram shown is a schematic representation of a polygon to be segmented in one embodiment of this application.

[0026] Figure 3The image shown is processed using a polygon trapezoidal segmentation method based on dual scan lines in one embodiment of this application. Figure 2 A schematic diagram of the polygon to be divided in the image.

[0027] Figure 4 The image shown is processed using a polygon trapezoidal segmentation method based on dual scan lines in one embodiment of this application. Figure 2 A schematic diagram of vertex C in the diagram.

[0028] Figure 5 The diagram shown is a block diagram of a polygon trapezoidal segmentation device based on dual scanning lines according to an embodiment of this application.

[0029] Figure 6 The diagram shown is a structural schematic of an electronic terminal according to an embodiment of this application. Detailed Implementation

[0030] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.

[0031] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. For example, "first XX" and "second XX" are merely used to distinguish different XXs and do not limit their order. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.

[0032] It should be noted that, in the embodiments of this application, the words "exemplary" or "for example" indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0033] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0034] Before providing a further detailed description of the present invention, the nouns and terms used in the embodiments of the present invention are explained, and the nouns and terms used in the embodiments of the present invention are subject to the following interpretations:

[0035] <1> A stack is a linear list with restricted operations, where insertion and deletion operations are limited to the end of the list, called the top of the stack, and the other end is called the bottom of the stack. Inserting a new element into a stack is called pushing onto the stack, which places the new element on top of the existing top element. Deleting an element from a stack is called popping from the stack, which removes the existing top element and makes its adjacent element the new top element.

[0036] <2> Interior and exterior angles: Traverse the edges of the polygon in a counter-clockwise order. For any vertex, the two edges that form the angle are: the edge reached first is the front line segment, and the edge reached later is the back line segment. Angles with an angle less than 180° between the front and back line segments are interior angles; angles with an angle greater than 180° between the front and back line segments are exterior angles.

[0037] <3> Manhattan polygon: refers to a polygon formed by line segments connected according to certain rules on a plane. Its name comes from the urban layout of Manhattan, New York City, where the road grid presents a regular rectangular shape, hence the name Manhattan pattern.

[0038] Existing polygon trapezoidal segmentation algorithms generally employ a single-direction scanline strategy, allowing only horizontal or vertical segmentation. This results in a simplistic segmentation scheme, mechanically dividing polygons into trapezoids without incorporating any engineering constraints. For instance, due to machine limitations, trapezoid side lengths must meet specified minimum lengths, and trapezoid areas must satisfy certain minimum thresholds. Therefore, trapezoid segmentation should avoid creating trapezoids with side lengths or areas smaller than these minimums, and the number of resulting trapezoids should be minimized. Single-direction trapezoidal segmentation falls far short of these requirements. Therefore, this application provides a polygon trapezoidal segmentation method, apparatus, medium, terminal, and program product based on dual scanlines. Different segmentation methods are used in each polygon trapezoidal segmentation process. The optimal segmentation method that satisfies the constraints is selected from these methods, ensuring the final processing result meets practical industrial needs.

[0039] To facilitate understanding of the embodiments of this application, firstly, in conjunction with Figure 1 Detailed explanation. Figure 1 This document illustrates a flowchart of a polygon trapezoidal segmentation method based on dual scan lines, as described in an embodiment of the present invention. The polygon trapezoidal segmentation method based on dual scan lines in this embodiment includes the following steps:

[0040] Step S11: Obtain the polygon to be segmented, and sort each vertex of the obtained polygon according to the preset first sorting standard and the second sorting standard to obtain the first sorting data and the second sorting data.

[0041] In some embodiments of this application, the process of sorting the vertices of the obtained polygon according to a preset first sorting standard and a second sorting standard to obtain first sorted data and second sorted data specifically includes: sorting the vertices of the polygon according to the first sorting standard of descending vertical coordinates and ascending horizontal coordinates of a specified coordinate axis, and storing the sorted data to obtain the first sorted data; and sorting the vertices of the polygon according to the second sorting standard of ascending horizontal coordinates and descending vertical coordinates of a specified coordinate axis, and storing the sorted data to obtain the second sorted data. By sorting the vertices of the polygon according to the first sorting standard of descending vertical coordinates and ascending horizontal coordinates of a specified coordinate axis, and by sorting the vertices of the polygon according to the second sorting standard of ascending horizontal coordinates and descending vertical coordinates of a specified coordinate axis, the order of processing each vertex is clearly defined for the first and second scan lines, ensuring correct trapezoidal segmentation and improving algorithm efficiency.

[0042] The following text will be based on Figure 2The polygon to be segmented is shown as an example. Specifically, the vertices of the polygon are sorted according to a first sorting criterion: the ordinate (Y-axis) from largest to smallest and the abscissa (X-axis) from smallest to largest. The resulting sorted vertices are: ABECDFGHIJKL. This sorted result is stored in a data structure to obtain the first sorted data, meaning the first scan line processes each vertex sequentially according to the order ABECDFGHIJKL. The vertices are then sorted according to a second sorting criterion: the abscissa (X-axis) from smallest to largest and the ordinate (Y-axis) from largest to smallest. The resulting sorted vertices are: EGACHKBDILFJ. This sorted result is also stored in a data structure to obtain the second sorted data, meaning the second scan line processes each vertex sequentially according to the order EGACHKBDILFJ. For example, a stack is used to store the sorted results.

[0043] Step S12: A first scan line is sent out to traverse the vertices in the first sorted data according to a first preset scan direction to process them and obtain a first processing result; at the same time, a second scan line is sent out to traverse the vertices in the second sorted data according to a second preset scan direction to process them and obtain a second processing result.

[0044] In some embodiments of this application, the step of issuing a first scan line to traverse the vertices in the first sorted data according to a first preset scan direction to obtain a first processing result includes: issuing a first scan line according to the first preset scan direction, moving sequentially to the vertices in the first sorted data, and performing the following steps at each vertex: storing the line segment connected to the vertex and projected in the first preset scan direction, and determining whether there is a ray in the second preset scan direction at the vertex; if there is no ray in the second preset scan direction at the vertex, no processing is required; if there is a ray in the second preset scan direction at the vertex, and the projection point of the ray falls on another vertex of the stored line segment, then connecting the two vertices forms a first internal line segment to obtain the first processing result; repeating the above execution steps at each vertex until all vertices in the first sorted data have been traversed.

[0045] like Figure 2 and Figure 3 As shown, exemplarily, the first scan line is a horizontal scan line, and the first preset scan direction is downward. Figure 2 and Figure 3The horizontal scan line is a vertical scan line, and the second preset scan direction is to the right. The horizontal scan line is used to calculate the ray projection of each vertex in the left and right directions and control the processing order of the vertices. The vertical scan line is used to calculate the ray projection of each vertex in the up and down directions. Specifically, each horizontal scan line moves downwards to the vertex in the first sorted data for processing. The vertices on each horizontal scan line downwards are AB, ECDF, GHIJ, and KL. At each vertex on each horizontal scan line, the following steps are performed: the line segment connected to the vertex and projected downwards is stored, and it is determined whether there is a ray to the right at the vertex. If there is no ray to the right at the vertex, no processing is required; if there is a ray to the right at the vertex, and the projection point of the ray falls on another vertex of the stored line segment, the two vertices are connected to form the first internal line segment to obtain the first processing result. The above execution steps at each vertex are repeated until all vertices in the first sorted data have been traversed.

[0046] Specifically, when processing vertices (A, B) on the first horizontal scan line, the line segments (AC, BD) connected to vertices A and B and projecting downwards are pushed onto the stack. Vertices A and B are external angles and do not have rays pointing to the right, so no processing is needed; the first sorted data is directly popped.

[0047] When processing the vertices (E, C, D, F) on the second horizontal scan line, taking vertex C as an example, vertex C is an interior angle and has a ray pointing to the right. Therefore, a ray is emitted from vertex C to find the projection point that falls on vertex D of line segment BD in the stack. Connecting vertex C and vertex D forms the first internal line segment CD. At this time, the first internal line segment CD divides the polygon into the ABCD part and the EFGHIJKL part, where the ABCD part is the smallest unit after the trapezoidal segmentation is completed. After processing the second horizontal scan line, all data above the second horizontal scan line is popped from the stack, and the relevant line segments of the second horizontal scan line, that is, the line segments (EG, FJ) connected to vertices E and F and projected downwards, are pushed onto the stack. At this time, the line segments in the stack are (EG, FJ).

[0048] When processing vertices (G, H, I, J) on the third horizontal scan line, the relevant segments of the third horizontal scan line, namely the segments (HK, IL) connected to vertices H and I and projected downwards, are pushed onto the stack. The specific vertex processing method is the same as above, and will not be repeated here.

[0049] When processing the vertex (K, L) on the fourth horizontal scan line, there is no line segment connected to that vertex that projects downwards. The specific vertex processing method is the same as above, and will not be repeated here.

[0050] The horizontal scan line completes the polygon segmentation process until no vertices remain in the first sorted data.

[0051] In some embodiments of this application, the step of issuing a second scan line to traverse the vertices in the second sorted data according to a second preset scan direction to obtain a second processing result includes: issuing a second scan line according to the second preset scan direction, moving sequentially to the vertices in the second sorted data, and performing the following steps at each vertex: storing the line segment connected to the current vertex and projected in the second preset scan direction, and determining whether there is a ray in the first preset scan direction at the current vertex; if there is no ray in the first preset scan direction at the current vertex, no processing is required; if there is a ray in the first preset scan direction at the current vertex, and the projection point of the ray falls on another vertex of the stored line segment, then connecting these two vertices to form a second internal line segment to obtain a second processing result; repeating the above execution steps at each vertex until all vertices in the second sorted data have been traversed.

[0052] like Figure 2 and Figure 3 As shown, each vertical scan line moves to the right along the vertex in the second sorted data for processing. The vertices on each vertical scan line along the right direction are: EG, ACHK, BDIL, and FJ. For each vertex on each vertical scan line, the following steps are performed: the line segment connected to the current vertex and projected to the right is stored, and it is determined whether there is a downward ray at the current vertex. If there is no downward ray at the current vertex, no processing is required; if there is a downward ray at the current vertex, and the projection point of this ray falls on another vertex of the stored line segment, then these two vertices are connected to form a second internal line segment to obtain the second processing result. The above steps for each vertex are repeated until all vertices in the second sorted data have been traversed.

[0053] Specifically, when processing vertices (E, G) on the first vertical scan line, the relevant line segments of the first vertical scan line, namely the line segments (EC, GH) connected to vertices E and G and projected to the right, are pushed onto the stack. Vertices E and G are exterior angles and do not have rays pointing downwards, so no processing is needed at this time, and the second sorted data is directly popped.

[0054] When processing the vertices (A, C, H, K) on the second vertical scan line, the relevant line segments of the second vertical scan line, namely the line segments (AB, KL) connected to vertices A and K and projected to the right, are pushed onto the stack. Taking vertex C as an example, vertex C is an interior angle and has a downward ray. A ray is emitted downward from vertex C, and its projection point falls on vertex H of line segment GH in the stack. Connecting vertex C and vertex H forms the second internal line segment CH. At this time, the second internal line segment CH divides the polygon into the EGCH part and the AKBDILFJ part, where the EGCH part is the smallest unit (trapezoidal or triangular) after trapezoidal segmentation. If it is not the smallest unit, recursive segmentation is required.

[0055] When processing vertices (B, D, I, L) on the third vertical scan line, the relevant segments of the third vertical scan line, namely the segments (DF, IJ) connected to vertices D and I and projected to the right, are pushed onto the stack. The specific vertex processing method is the same as above, and will not be repeated here.

[0056] When processing the vertex (F, J) on the fourth vertical scan line, there is no line segment connected to that vertex that projects to the right. The specific vertex processing method is the same as above, and will not be repeated here.

[0057] The vertical scan line completes the polygon segmentation process until no vertices remain in the second sorted data.

[0058] Step S13: Determine whether the first processing result and the second processing result satisfy the preset constraints. If the first processing result satisfies the constraints, then select the first processing result as the optimal result; if the second processing result satisfies the constraints, then select the second processing result as the optimal result.

[0059] In some embodiments of this application, the constraints include one or more of the following: the shortest side of the trapezoid, the minimum area of ​​the trapezoid, and a threshold for the number of trapezoids. By incorporating constraints into the polygon trapezoidal segmentation process, the segmentation process does not only consider the processing results of a single scan line, but also combines the processing results of the first and second scan lines according to the constraints to determine an optimal segmentation method that meets the needs of practical industrial applications.

[0060] It should be noted that the constraints can be designed specifically according to the actual application requirements, and the corresponding loss function can be designed to calculate the loss of the tangent based on the different constraints. This application does not make any specific restrictions on this.

[0061] In some embodiments of this application, when the constraint condition is the shortest side of the trapezoid, it is determined whether the internal line segments obtained by scanning the first scan line and the second scan line to the same vertex satisfy the shortest side of the trapezoid; if the internal line segments obtained by scanning the first scan line satisfy the shortest side of the trapezoid, then the segmentation method of scanning the first scan line is the optimal segmentation method; if the internal line segments obtained by scanning the second scan line satisfy the shortest side of the trapezoid, then the segmentation method of scanning the second scan line is the optimal segmentation method.

[0062] Specifically, the constraint is designed as the shortest side of the trapezoid, requiring that the length of the resulting trapezoid's side be greater than or equal to the threshold of the shortest side. When using horizontal and vertical scan lines for parallel computation, the processed results must satisfy this shortest side constraint. Previously, the horizontal scan line was used to process vertex C to obtain the first internal line segment CD, and the vertical scan line was used to process vertex C to obtain the second internal line segment CH. Now, the segmentation loss for the first internal line segment CD and the second internal line segment CH is calculated according to the set loss function. The formula for the specific tangent loss function is as follows:

[0063] ;Formula (1)

[0064] in, The loss function is the one for the shortest side of the trapezoid. The side length of the trapezoid is less than or equal to the threshold of the shortest side length; It is an ordinal number.

[0065] Assuming the side lengths of line segments AC and BD are both less than the threshold of the shortest side of the trapezoid, the segmentation loss of the first internal line segment CD is... Therefore, the first internal line segment CD suffers a significant loss. The second internal line segment CH connects the short sides AC and HK, extending them, thus eliminating any loss in CH. Therefore, selecting the second internal line segment CH as the tangent at vertex C, i.e., using a vertical scan line for segmentation, is superior. In this case, the second internal line segment CH obtained through vertical scan line segmentation is chosen as the optimal processing result.

[0066] The constraint is designed as the minimum area of ​​the trapezoid, meaning the area of ​​the resulting trapezoid must be greater than or equal to a threshold value representing the minimum area of ​​the trapezoid. For vertex C, the horizontal scan line divides the area into ABCD region, the area of ​​which is... If the area is less than the assumed minimum area threshold of the trapezoid, its loss function is... However, there is a loss. The EGCH portion obtained by vertical scan line segmentation has an area greater than the assumed minimum trapezoidal area threshold, so there is no loss. Therefore, vertical scan line segmentation is superior, and the second internal line segment CH obtained by vertical scan line segmentation is selected as the optimal processing result.

[0067] The polygon trapezoidal segmentation method based on dual scanning lines proposed in this application is applicable to Manhattan polygons. It performs horizontal and vertical segmentation at each vertex and calculates the loss of the segmentation results of the two segmentation schemes to select the segmentation method that meets the constraints, so that the segmented line segments can better meet the needs of practical applications.

[0068] Figure 5 This is a schematic block diagram of a polygon trapezoidal segmentation device based on dual scanning lines provided in an embodiment of this application. Figure 5 As shown, the polygon trapezoidal segmentation device 500 based on dual scan lines includes:

[0069] The sorting module 501 is used to acquire the polygon to be segmented and sort each vertex of the acquired polygon according to a preset first sorting standard and a second sorting standard to obtain first sorting data and second sorting data.

[0070] The dual-scan-line processing module 502 is used to send out a first scan line to traverse the vertices in the first sorted data according to a first preset scan direction to process them and obtain a first processing result; at the same time, it sends out a second scan line to traverse the vertices in the second sorted data according to a second preset scan direction to process them and obtain a second processing result.

[0071] The judgment module 503 is used to judge whether the first processing result and the second processing result meet the preset constraints. If the first processing result meets the constraints, the first processing result is selected as the optimal result; if the second processing result meets the constraints, the second processing result is selected as the optimal result.

[0072] It should be understood that the specific process of each module performing the above-mentioned steps has been described in detail in the above method embodiments, and will not be repeated here for the sake of brevity.

[0073] It should also be understood that the module division in the embodiments of this application is illustrative and only represents a logical functional division; in actual implementation, there may be other division methods. Furthermore, the functional modules in the various embodiments of this application can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0074] Figure 6 This is a schematic block diagram of the electronic terminal provided in an embodiment of this application. Figure 6 As shown, the electronic terminal 600 includes at least one processor 601, a memory 602, at least one network interface 603, and a user interface 605. The various components in the electronic terminal 600 are coupled together via a bus system 604. It is understood that the bus system 604 is used to implement communication between these components. In addition to a data bus, the bus system 604 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 6 The general will label all buses as bus systems.

[0075] The user interface 605 may include a monitor, keyboard, mouse, trackball, clicker, button, touchpad, or touch screen.

[0076] It is understood that memory 602 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM) or programmable read-only memory (PROM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM) and synchronous static random access memory (SSRAM). The memories described in the embodiments of this invention are intended to include, but are not limited to, these and any other suitable categories of memory.

[0077] In this embodiment of the invention, the memory 602 is used to store various types of data to support the operation of the electronic terminal 600. Examples of this data include: any executable program for operation on the electronic terminal 600, such as the operating system 6021 and application programs 6022; the operating system 6021 contains various system programs, such as the framework layer, core library layer, driver layer, etc., for implementing various basic services and handling hardware-based tasks. The application program 6022 may contain various applications, such as a media player, browser, etc., for implementing various application services. The methods provided in this embodiment of the invention can be included in the application program 6022.

[0078] The methods disclosed in the above embodiments of the present invention can be applied to processor 601, or implemented by processor 601. Processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 601 or by instructions in the form of software. The processor 601 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 601 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. General-purpose processor 601 may be a microprocessor or any conventional processor, etc. The steps of the accessory optimization method provided in the embodiments of the present invention can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in memory. The processor reads the information in the memory and combines it with its hardware to complete the steps of the aforementioned method.

[0079] In an exemplary embodiment, the electronic terminal 600 may be used by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), or complex programmable logic devices (CPLDs) to perform the aforementioned method.

[0080] According to the method provided in the embodiments of this application, this application also provides a computer program product, which includes: computer program code, which, when run on a computer, causes the computer to execute... Figures 1 to 4 The method of any of the embodiments shown.

[0081] According to the method provided in the embodiments of this application, this application also provides a computer-readable storage medium storing program code, which, when executed on a computer, causes the computer to perform... Figures 1 to 4 The method of any of the embodiments shown.

[0082] As used in this specification, the terms "component," "module," "system," etc., are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process and / or an execution thread, and components may be located on a single computer and / or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, and / or a network, such as the Internet interacting with other systems via signals).

[0083] Those skilled in the art will recognize that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0084] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0085] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0086] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0087] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0088] In the above embodiments, the functions of each functional unit can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. A computer program product includes one or more computer instructions (programs). When the computer program instructions (programs) are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs, DVDs), or semiconductor media (e.g., solid-state disks, SSDs, etc.).

[0089] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0090] In summary, addressing the inherent limitations of unidirectional scanning and the inability to incorporate constraints into the segmentation process in existing technologies, this application provides a polygon trapezoidal segmentation method, apparatus, medium, terminal, and program product based on dual scan lines. The method involves sorting the vertices of the polygon to be segmented according to a preset first and second sorting criteria to obtain first and second sorted data. Then, first and second scan lines are simultaneously emitted. Each first scan line traverses the vertices in the first sorted data according to a first preset scanning direction to obtain a first processing result. Similarly, each second scan line traverses the vertices in the second sorted data according to a second preset scanning direction to obtain a second processing result. Finally, based on pre-set constraints, it is determined whether the first and second processing results obtained from the first scan line segmentation satisfy the constraints. This allows for the selection of the optimal segmentation method based on the constraints incorporated into the trapezoidal segmentation process, ensuring that the final processing result better meets practical application requirements. Therefore, this application effectively overcomes the various shortcomings of existing technologies and possesses high industrial applicability.

[0091] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A method for scan line based polygonal trapezoidalization clipping, characterized in that, The method comprises the following steps: acquiring a polygon to be divided, and sorting each vertex of the acquired polygon according to a preset first sorting standard and a second sorting standard respectively to obtain first sorting data and second sorting data; issuing a first scanning line to traverse the vertices in the first sorting data according to a first preset scanning direction to obtain a first processing result; meanwhile, issuing a second scanning line to traverse the vertices in the second sorting data according to a second preset scanning direction to obtain a second processing result; judging whether the first processing result and the second processing result satisfy a preset constraint condition, and if the first processing result satisfies the constraint condition, selecting the first processing result as an optimal result; if the second processing result satisfies the constraint condition, selecting the second processing result as the optimal result.

2. The double scan line based polygon warp slicing method of claim 1, wherein, The sorting of each vertex of the acquired polygon according to a preset first sorting standard and a second sorting standard respectively to obtain first sorting data and second sorting data comprises the following steps: sorting each vertex of the polygon according to a first sorting standard that the longitudinal coordinate of a specified coordinate axis is from large to small and the horizontal coordinate is from small to large, and storing to obtain the first sorting data; sorting each vertex of the polygon according to a second sorting standard that the horizontal coordinate of a specified coordinate axis is from small to large and the longitudinal coordinate is from large to small, and storing to obtain the second sorting data.

3. The double scan line based polygon warp slicing method of claim 2, wherein, The issuing of a first scanning line to traverse the vertices in the first sorting data according to a first preset scanning direction to obtain a first processing result comprises the following steps: issuing a first scanning line according to the first preset scanning direction, and moving to the vertices in the first sorting data in sequence, and performing the following steps at each vertex: storing a line segment connected with the vertex and projected in the first preset scanning direction, and judging whether there is a ray in the second preset scanning direction at the vertex; if there is no ray in the second preset scanning direction at the vertex, no processing is needed; if there is a ray in the second preset scanning direction at the vertex, and the projection point of the ray falls on another vertex of the stored line segment, connecting the two vertices to form a first internal line segment to obtain the first processing result; repeating the execution steps at each vertex until the vertices in the first sorting data are traversed.

4. The double scan line based polygon warp slicing method of claim 3, wherein, The issuing of a second scanning line to traverse the vertices in the second sorting data according to a second preset scanning direction to obtain a second processing result comprises the following steps: issuing a second scanning line according to the second preset scanning direction, and moving to the vertices in the second sorting data in sequence, and performing the following steps at each vertex: storing a line segment connected with the current vertex and projected in the second preset scanning direction, and judging whether there is a ray in the first preset scanning direction at the current vertex; if there is no ray in the first preset scanning direction at the current vertex, no processing is needed; If a ray in the first preset scanning direction exists at the current vertex, and the projection point of the ray falls on another vertex of the stored line segment, then a second internal line segment is formed by connecting the two vertices to obtain a second processing result; The execution steps at each vertex are repeated until all vertices in the second sorting data are traversed.

5. The dual scan line based polygon warp slicing method of claim 4, wherein, The constraint condition includes one or more of a trapezoidal minimum side, a trapezoidal minimum area, and a trapezoidal number threshold.

6. The dual scan line based polygon warp slicing method of claim 5, wherein, In the case where the constraint condition is a trapezoidal minimum side, it is determined whether the internal line segments obtained by scanning the same vertex using the first scanning line and the second scanning line respectively satisfy the trapezoidal minimum side; If the internal line segment obtained by scanning using the first scanning line satisfies the trapezoidal minimum side, then the splitting mode of the first scanning line is the optimal splitting mode; if the internal line segment obtained by scanning using the second scanning line satisfies the trapezoidal minimum side, then the splitting mode of the second scanning line is the optimal splitting mode.

7. A double scan line based polygon rasterization slicing apparatus, characterized by, The method comprises: a sorting module configured to obtain a polygon to be split, and sort each vertex of the obtained polygon according to a first preset sorting standard and a second preset sorting standard to obtain first sorting data and second sorting data; a double scanning line processing module configured to send a first scanning line to traverse the vertices in the first sorting data according to a first preset scanning direction to obtain a first processing result, and simultaneously send a second scanning line to traverse the vertices in the second sorting data according to a second preset scanning direction to obtain a second processing result; a judging module configured to determine whether the first processing result and the second processing result satisfy a preset constraint condition, and select the first processing result as an optimal result if the first processing result satisfies the constraint condition; select the second processing result as the optimal result if the second processing result satisfies the constraint condition.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1 to 6.

9. A computer program product, characterised in that, The computer program product comprises computer program code, which, when executed on a computer, causes the computer to implement the method of any one of claims 1 to 6.

10. An electronic terminal comprising a memory, a processor and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Triangularization method of polygon in computer image processing and system using the same

    CN103164864A

  • Multi-unmanned aerial vehicle cooperative area coverage path planning method based on genetic algorithm

    CN118034378A

  • Polygon processing method and device, equipment and storage medium

    CN119850783A

  • Multi-unmanned aerial vehicle cooperative detection method for urban approaching operation

    CN120469478A