A pixel counting method, device and storage medium for dashed line mask calculation
By processing the slope of line segments differently, the calculation method for dashed line masks is simplified, solving the problems of high computational complexity and inconsistent shapes in existing technologies, and achieving more efficient calculation and energy-saving effects.
Patent Information
- Application Number
- CN202310182432.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-01
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2043-03-01
AI Technical Summary
Existing technologies suffer from high computational complexity, inconsistent shapes in MSAA scenarios, and large computational load when calculating dashed line masks.
We employ a method that considers different line segment slopes to calculate pixel counter values in both non-MSAA and MSAA scenarios. Furthermore, we simplify the calculation in the MSAA scenario using a straight line equation, thereby reducing computational complexity.
It simplifies the computational complexity of dashed line masks, saves computational latency and reduces power consumption, and solves the problem of inconsistent shapes in MSAA scenarios.
Smart Images

Figure CN116137030B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer graphics, and particularly relates to a pixel counting method, device and storage medium for dash line mask calculation. BACKGROUND
[0002] Before calculating the dash line mask, the counter of each pixel needs to be calculated. The current dash line drawing needs to calculate the counter from the first vertex, and each column has the same counter. The corresponding stipple counter is increased by 1 when the coordinate x is offset by 1.
[0003] The current scheme has the following defects: the same counter is used for the same column (x-major) or the same row (y-major), and in the case of MSAA (multisample anti-aliasing) being turned on, the pixels near the vertex will have errors because the drawn dash line should be a rectangle; when the two vertices of the line are reversed in order, the counter of the latter vertex needs to be calculated first, and then the counter is reduced by 1 along with the coordinate offset, resulting in a large amount of calculation; when MSAA is turned on, the periphery of the drawn dash line is a rectangle, and the mask part is a parallelogram, which is not uniform in shape. SUMMARY
[0004] In view of the above problems, the present application provides a pixel counting method, device and storage medium for dash line mask calculation, aiming to reduce the calculation complexity of the dash line mask and unify the pixel counting algorithms of MSAA and non-MSAA.
[0005] In a first aspect, the present application provides a pixel counting method for dash line mask calculation, the method comprising:
[0006] counting the counter of the two vertices of the line segment (x0, y0) and (x1, y1) as follows: x 0 , y 0 x 1 , y 1
[0007] In the non-MSAA scenario, if the slope of the line segment is less than 1, the counter of any pixel coordinate (x, y) on the line segment is: x , y x 0 x 1 x 0 x x - x 0 If the slope of the line segment is greater than 1, the coordinates of any pixel on the line segment are ( x , y ) of counter = ( y 0 > y 1 )?( y 0 - y ):( y - y 0 );
[0008] In the MSAA scenario, let the vertex of the line segment be located at... x coordinate x 0 And the equation of the line perpendicular to the dashed line is A. x +B y +C=0, where A, B, and C are the parameters of the line equation, and the coordinates of any pixel on the line segment ( x , y )of .
[0009] A second aspect of the present invention provides a pixel counting device for calculating dashed line masks, comprising:
[0010] A pixel counting module for non-MSAA scenarios, used to count pixels at two vertices of a line segment in non-MSAA scenarios. x 0 , y 0 ), ( x 1 , y 1 If the slope of the line segment is less than 1, the coordinates of any pixel on the line segment ( x , y ) of counter = ( x 0 > x 1 )?( x 0 - x ):( x - x 0 If the slope of the line segment is greater than 1, the coordinates of any pixel on the line segment are ( x , y ) of counter = ( y 0 > y 1 )?( y 0- y ):( y - y 0 );
[0011] The pixel counting module in the MSAA scene is used to count the pixels between two vertices of a line segment in the MSAA scene. x 0 , y 0 ), ( x 1 , y 1 Let the vertex of the line segment be located at... x coordinate x 0 And the equation of the line perpendicular to the dashed line is A. x +B y +C=0, where A, B, and C are the parameters of the line equation, and the coordinates of any pixel on the line segment ( x , y )of .
[0012] A third aspect of the present invention provides a pixel counting apparatus for calculating a dashed line mask, comprising: a processor; and a memory, wherein the memory stores a computer-executable program, and when the processor executes the computer-executable program, the pixel counting method for calculating the dashed line mask described above is executed.
[0013] A fourth aspect of the present invention is a storage medium having a computer program stored thereon, which, when executed by a processor, implements the pixel counting method described above for calculating a dashed line mask.
[0014] The present invention provides a pixel counting method, device and storage medium for calculating dashed line masks. Its advantages are: the calculation method of the present invention is simple, the complexity of mask calculation is reduced, it is easy to implement in hardware, and it saves calculation latency and reduces power consumption. At the same time, it solves the problems and defects of existing solutions in MSAA scenarios. Attached Figure Description
[0015] Figure 1 This is the overall outline of the offline primitives in non-MSAA and MSAA scenes in the embodiments of the present invention;
[0016] Figure 2 This is a diagram showing the differences between existing solutions and the solution of the present invention in drawing an MSAA scene in the embodiments of the present invention;
[0017] Figure 3 This is a schematic diagram of the pixel counting device structure used for calculating the dashed line mask in an embodiment of the present invention;
[0018] Figure 4 Figure 1 is a schematic diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0019] To further illustrate the technical solutions of the present application, the embodiments are implemented on the premise of the technical solutions of the present application, and detailed implementation manners and specific steps are given.
[0020] The features, structures or characteristics described in this disclosure can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the present disclosure. One skilled in the relevant art will recognize, however, that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations or operations are not shown or described in detail to avoid obscuring aspects of the present disclosure.
[0021] Before the example embodiments are discussed in more detail, it should be mentioned that some of the example embodiments are described as processes or methods depicted as flow charts. While the processes are described in serial, many of the steps can be performed in parallel, concurrently or simultaneously with one another. In addition, the order of the steps can be re-arranged. The processes can be terminated when their operations are completed, but can also have additional steps not included in the figure, which can also be performed after the processes have been terminated. The processes can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0022] The accompanying drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure. In the drawings:
[0023] The embodiments of the present application are directed to a pixel counting method, device and storage medium for dashed line mask calculation, and provide the following embodiments.
[0024] Based on the embodiment 1 of the present application
[0025] The embodiments of the present application provide a pixel counting method for dashed line mask calculation, and the method comprises the following steps.
[0026] For the two vertices of the line segment x 0 , y 0 ),x 1 , y 1 ):
[0027] In non-MSAA scenarios, if the slope of a line segment is less than 1, the coordinates of any pixel on the line segment ( x , y ) of counter = ( x 0 > x 1 )?( x 0 - x ):( x - x 0 If the slope of the line segment is greater than 1, the coordinates of any pixel on the line segment are ( x , y ) of counter = ( y 0 > y 1 )?( y 0 - y ):( y - y 0 );
[0028] In the MSAA scenario, let the vertex of the line segment be located at... x coordinate x 0 And the equation of the line perpendicular to the dashed line is A. x +B y +C=0, where A, B, and C are the parameters of the line equation, and the coordinates of any pixel on the line segment ( x , y )of For the two vertices of the line segment ( x 0 , y 0), ( x 1 , y 1 ), parameter A= y 0- y 1 B= x 1 - x 0 C=( x 0 - x 1 )* y 0-( y 0-y 1 * x 0 ;
[0029] In the implementation process, the mask calculation formula of the dashed line is , wherein the counter is the count of a pixel, the counter of the first vertex is incremented by one until the second vertex as the coordinate offset, and the factor is a configured parameter.
[0030] In the prior scheme, the counter of the pixel in the non-MSAA and MSAA is set to 0. x 0 The counter of the pixel in the same column is calculated by offset, and if the counter of the pixel in the same column is greater than 0, the counter of the pixel in the same column is set to 0. x 1 If the counter of the pixel in the same column is less than 0, the counter of the pixel in the same column is set to 0. x 1 If the counter of the pixel in the same column is less than 0, the counter of the pixel in the same column is set to 0. x 0 The counter of the pixel on the left side is negative. x 1 The counter of the pixel on the right side exceeds a reasonable range, which is inconsistent with common sense.
[0031] Referring to Figure 1 , Figure 2 In the implementation process of the present application, the overall outline of the line primitive in the non-MSAA and MSAA scene is as shown in Figure 1 . Figure 2 The difference between the prior scheme (left) and the present application scheme (right) in drawing the MSAA scene is as shown in Figure 2 . Figure 2 It can be seen that the present application scheme avoids the problems in the prior scheme by a relatively simple calculation algorithm.
[0032] In addition, in the MSAA scene, the counter of the pixel in the same column is the same for a dashed line, so the counter of the pixel in the same column needs to be calculated only once for a dashed line, rather than once for each pixel, thereby greatly reducing the calculation amount.
[0033] Based on the embodiment 2 of the present application
[0034] The pixel counting device 300 for the dashed line mask calculation provided by the embodiment 2 of the present application is as shown in Figure 3 , and includes a pixel counting module 310 in the non-MSAA scene, configured to, in the non-MSAA scene, count the counter of the pixel in the non-MSAA scene according to the two vertices of the line segment. x0 , y 0 , x 1 , y 1 , if the slope of the line segment is less than 1, the counter of any pixel coordinate (x, y) on the line segment is x , y . x 0 x 1 ? x 0 x : x x 0 ; if the slope of the line segment is greater than 1, the counter of any pixel coordinate (x, y) on the line segment is x , y . y 0 y 1 ? y 0 y : y y 0 ;
[0035] The pixel counter module 320 in the MSAA scenario is configured to, in the MSAA scenario, for two vertices (x1, y1) and (x2, y2) of a line segment, let the coordinates of the vertices passing through the line segment be (x, y) and the equation of a straight line perpendicular to the dashed line be Ax + By + C = 0, where A, B and C are parameters of the equation of the straight line, and the counter of any pixel coordinate (x, y) on the line segment is x 0 , y 0 . x 1 , y 1 . x x 0 x y . x y .
[0036] In addition to the above modules, the apparatus 300 can further include other components, however, since these components are irrelevant to the content of the embodiments of the present disclosure, the illustrations and descriptions thereof are omitted here.
[0037] The specific working process of the pixel counting device 300 for the dashed line mask calculation is described with reference to the pixel counting method for the dashed line mask calculation in Embodiment 1 above, and will not be repeated here.
[0038] Based on Embodiment 3 of the present application
[0039] The system according to the present application can also be implemented by means of Figure 4 the architecture of the computing device shown. Figure 4 The architecture of the computing device is shown. As shown in Figure 4 , the computer system 410, the system bus 430, one or more CPUs 440, the input / output 420, the memory 450, etc. The memory 450 can store various data or files used by the computer processing and / or communication and the program instructions executed by the CPU, including the program instructions of the method in Embodiment 1. Figure 4 The architecture shown is only exemplary, and one or more components in Figure 4 may be adjusted according to actual needs when implementing different devices. The memory 450 as a kind of computer readable storage medium can be used to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the pixel counting method for the dashed line mask calculation in the embodiments of the present application (for example, the first pixel counting module 310 in the pixel counting device 300 for the dashed line mask calculation in the non-MSAA scene, the pixel counting module 320 in the MSAA scene and the second pixel counting module 330 in the non-MSAA scene). One or more CPUs 440 execute various functional applications and data processing of the system of the present application by running the software programs, instructions and modules stored in the memory 450, that is, implement the pixel counting method for the dashed line mask calculation described above, which includes:
[0040] For two vertices of the line segment (x0, y0) and (x1, y1): x 0 , y 0 ), x 1 , y 1 ):
[0041] In the non-MSAA scene, if the slope of the line segment is less than 1, the counter of any pixel coordinate (x, y) on the line segment is: x , y ( x 0 ) x 1 ? x 0 - x : x - x0 ) ; if the slope of the line segment is greater than 1, the counter of any pixel coordinate (x, y) on the line segment is x , y ) = ( y 0 y 1 ) ( y 0 y ) ( y y 0 ) ;
[0042] In the MSAA scenario, let the coordinates of the top vertex of the line segment be (x0, y0) and (x1, y1), and the equation of the straight line perpendicular to the dashed line be Ax + By + C = 0, where A, B, and C are parameters of the equation of the straight line, and the counter of any pixel coordinate (x, y) on the line segment is x x 0 x y x , y .
[0043] Of course, the processor of the server provided by the embodiments of the present application is not limited to performing the method operations as described above, but can also perform the related operations in the pixel counting method for dashed line mask calculation provided by any embodiment of the present application.
[0044] The memory 450 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; and the data storage area can store data created according to the use of the terminal and the like. In addition, the memory 450 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state memory device. In some examples, the memory 450 can further include a memory disposed remotely with respect to the one or more CPUs 440, which can be connected to the device through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0045] The input / output 420 can be used to receive input digital or character information, and to generate key signal inputs related to the user settings and function controls of the device. The input / output 420 can also include a display device such as a display screen.
[0046] Based on Embodiment 4 of the present application
[0047] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the pixel counting method for dash line mask calculation in the above embodiment.
[0048] The computer readable storage medium of the embodiment of the present application can adopt any combination of one or more computer readable media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, device or apparatus.
[0049] The computer readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, in which a computer readable program code is borne. Such a propagated data signal can take multiple forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium that is not a storage medium and that can transmit, propagate or transport a program for use by or in connection with an instruction execution system, apparatus or device.
[0050] The program code contained in the storage medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0051] The pixel counting method, device and storage medium for dash line mask calculation provided by the present application are provided by the above embodiments, the calculation method of the present application is simple, the mask calculation complexity is reduced, hardware implementation is facilitated, and the calculation time delay is saved and the power consumption is reduced, and the problems and defects of the existing scheme in the MSAA scene are solved.
[0052] Note that the above merely describes preferred embodiments of the present application and the principles of the technology applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, modifications and substitutions can be made without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A pixel counting method for dashed line mask calculation, characterized in that, The method comprises: For two vertices of a line segment (x1, y1) and (x2, y2) x 0 , y 0 ), (x2, y2) x 1 , y 1 ): In non-MSAA scenarios, if the slope of a line segment is less than 1, the coordinates of any pixel on the line segment ( x , y ) of counter = ( x 0 > x 1 )?( x 0 - x ):( x - x 0 If the slope of the line segment is greater than 1, the coordinates of any pixel on the line segment are ( x , y ) of counter = ( y 0 > y 1 )?( y 0 - y ):( y - y 0 ); In the MSAA scenario, let the coordinates of the top vertex of the line segment be (x, y) x x 0 And the straight line equation perpendicular to the dashed line is A x +B y +C=0, where A, B, and C are parameters of the straight line equation, and the x , y ) of any pixel coordinate on the line segment . 2. A pixel counting device for a dashed line mask calculation, characterized in that, comprising: The pixel counting module under the non-MSAA scene is used for counting the pixels of the line segment in the non-MSAA scene. x 0 , y 0 ),( x 1 , y 1 ), if the slope of the line segment is less than 1, the counter of any pixel coordinate on the line segment is( x , y ) =( x 0 > x 1 )?( x 0 - x ):( x - x 0 ); if the slope of the line segment is greater than 1, the counter of any pixel coordinate on the line segment is( x , y ) =( y 0 > y 1 )?( y 0 - y ):( y - y 0 ). The pixel counting module in the MSAA scene is used to count the pixels between two vertices of a line segment in the MSAA scene. x 0 , y 0 ), ( x 1 , y 1 Let the vertex of the line segment be located at... x coordinate x 0 And the equation of the line perpendicular to the dashed line is A. x +B y +C=0, where A, B, and C are the parameters of the line equation, and the coordinates of any pixel on the line segment ( x , y )of .
3. A pixel counting device for dashed line mask calculation, characterized in that, comprising: a processor; and a memory, wherein the memory has stored therein computer executable programs which, when executed by the processor, perform the pixel counting method for dashed line mask calculation of claim 1.
4. A storage medium having stored thereon a computer program, characterized in that The programs, when executed by the processor, implement the pixel counting method for dashed line mask calculation of claim 1.
Citation Information
Patent Citations
Method for executing conversion from transparency to coverage
CN101393650A
Three-dimensional reconstruction method of building objects based on model prior high-resolution SAR images
CN104200521A