[go: up one dir, main page]

CN115797496B - Dotted line drawing method and related device - Google Patents

Dotted line drawing method and related device Download PDF

Info

Publication number
CN115797496B
CN115797496B CN202211325623.7A CN202211325623A CN115797496B CN 115797496 B CN115797496 B CN 115797496B CN 202211325623 A CN202211325623 A CN 202211325623A CN 115797496 B CN115797496 B CN 115797496B
Authority
CN
China
Prior art keywords
line
target
pixel point
opacity
projection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211325623.7A
Other languages
Chinese (zh)
Other versions
CN115797496A (en
Inventor
周涤非
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ouye Semiconductor Co ltd
Original Assignee
Shenzhen Ouye Semiconductor Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Ouye Semiconductor Co ltd filed Critical Shenzhen Ouye Semiconductor Co ltd
Priority to CN202211325623.7A priority Critical patent/CN115797496B/en
Publication of CN115797496A publication Critical patent/CN115797496A/en
Application granted granted Critical
Publication of CN115797496B publication Critical patent/CN115797496B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)

Abstract

The application discloses a dotted line drawing method and a related device, wherein the method comprises the steps of traversing pixel points in a target image along a preset traversing path; calculating the projection proportion of the projection vector of the traversed pixel point on the target virtual line relative to the target virtual line; determining the line segment part where the pixel point is located according to the projection proportion and the line segment number of the target dotted line; when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the directed field distance; when the line segment portion is a broken line portion, the opacity of the pixel point is configured to be 0; the pixel points are rendered based on the opacity. According to the method and the device, the opacity of the pixel point is determined through the directed field distance, and the pixel point is rendered based on the opacity, so that the drawing sequence of image drawing is consistent with the processing sequence of image signals, the processing complexity of line segment drawing is reduced, and the efficiency of image drawing is improved.

Description

Dotted line drawing method and related device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for drawing a dotted line.
Background
The embedded device processes the image signal in such a manner that each pixel is sequentially rendered in a row-column order from the upper left pixel as the start point, and thus, when the image is processed, it is also necessary to process the image in a row-column order from the upper left pixel as the start point. However, the existing dotted line drawing method uses one end of the dotted line as a starting point, and renders pixels to the other end of the line segment one by one along the line segment, so that the line segment drawing logic is inconsistent with the processing logic of the embedded device on the image signal, the processing complexity of the embedded device is increased, and the drawing efficiency of the line segment is further affected.
There is thus a need for improvements and improvements in the art.
Disclosure of Invention
The technical problem to be solved by the application is to provide a method and a related device for drawing a dotted line aiming at the defects of the prior art.
In order to solve the above technical problem, a first aspect of an embodiment of the present application provides a method for drawing a dotted line, where the method includes:
acquiring a target image and a capsule body corresponding to a target dotted line, wherein the target dotted line is used for drawing on the target image;
traversing the pixel points in the target image along a preset traversing path;
for each traversed pixel point, calculating the projection proportion of the projection vector of the pixel point on the target virtual line relative to the target virtual line;
acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments;
when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance;
when the line segment portion is a broken line portion, configuring the opacity of the pixel point to be 0;
and rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line.
In one implementation, the preset traversal path is determined based on an image signal processing sequence corresponding to the target image.
In one implementation manner, the calculating the directed field distance between the pixel point and the capsule body according to the projection ratio specifically includes:
determining a projection point of the pixel point on the target virtual line according to the starting point, the ending point and the projection proportion of the target virtual line;
and acquiring the distance between the pixel point and the projection point, and taking the difference value between the distance and the capsule radius of the capsule body as the directed field distance between the pixel point and the capsule body.
In one implementation manner, the determining, according to the projection ratio and the line segment number, the line segment portion where the pixel point is located specifically includes:
determining a target value based on the number of line segments and the projection ratio, wherein the target value=the number of line segments×the projection ratio×2;
obtaining the remainder of the target value relative to 2;
when the remainder is 0, determining that the pixel point is positioned in a solid line part;
and when the remainder is not 0, determining that the pixel point is positioned at the dotted line part.
In one implementation manner, before the pixel point is rendered based on the opacity, the method further includes an antialiasing operation, where the antialiasing operation specifically includes:
acquiring a decimal part of the target value of the pixel point;
if the decimal part is smaller than a preset threshold value, taking 0.5 as the transparency of the pixel point;
and if the decimal part is greater than or equal to a preset threshold value, keeping the opacity of the pixel point unchanged.
In one implementation, the determining the opacity of the pixel point based on the calculated directed field distance specifically includes:
calculating a target difference value between a first threshold value and the directed field distance;
when the target difference value is smaller than or equal to a second threshold value, the second threshold value is used as the opacity of the pixel point, wherein the second threshold value is smaller than the first threshold value;
when the target difference value is larger than a second threshold value and smaller than a third threshold value, taking the target difference value as the opacity of the pixel point, wherein the third threshold value is larger than the first threshold value;
and when the target difference value is greater than or equal to a third threshold value, taking the third threshold value as the opacity of the pixel point.
In one implementation manner, the obtaining the number of the line segments of the dashed line segment specifically includes:
reading the length and width of the broken line segments, and determining the number of candidate line segments based on the length and width of the line segments, wherein the number of candidate line segments=the length/(preset value, the width of the line segments), and the preset value is the ratio of the length of the solid line part to the width of the line segments;
when the number of the candidate line segments is greater than or equal to a number threshold, taking the number threshold as the number of the line segments of the broken line segments;
and when the number of the candidate line segments is smaller than a number threshold value, taking the number of the candidate line segments as the number of the line segments of the broken line segments.
A second aspect of the embodiments of the present application provides a dashed line drawing system, the system including:
the device comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring a target image and a capsule body corresponding to a target dotted line, and the target dotted line is used for drawing on the target image;
the traversing module is used for traversing the pixel points in the target image along a preset traversing path;
the calculation module is used for calculating the projection proportion of the projection vector of each pixel point on the target virtual line relative to the target virtual line for each pixel point traversed;
the first determining module is used for obtaining the number of line segments of the target dotted line and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments;
the second determining module is used for calculating the directed field distance between the pixel point and the capsule body according to the projection proportion when the line segment part is a solid line part, and determining the opacity of the pixel point based on the calculated directed field distance;
a configuration module, configured to configure the opacity of the pixel point to be 0 when the line segment portion is a dotted line portion;
and the rendering module is used for rendering the pixel points based on the opacity so as to obtain a target image drawn with the target dotted line.
A third aspect of the embodiments provides a computer-readable storage medium storing one or more programs executable by one or more processors to implement steps in a method of drawing a dashed line as described in any of the above.
A fourth aspect of the present embodiment provides a terminal device, including: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the steps of the method for drawing a broken line as described in any one of the above are implemented when the processor executes the computer readable program.
The beneficial effects are that: compared with the prior art, the application provides a method for drawing a dotted line and a related device, wherein the method comprises the steps of acquiring a target image and a capsule body corresponding to the target dotted line; traversing the pixel points in the target image along a preset traversing path; calculating the projection proportion of the projection vector of the pixel point on the target virtual line relative to the target virtual line; acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments; when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance; when the line segment portion is a broken line portion, configuring the opacity of the pixel point to be 0; and rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line. According to the method and the device, the opacity of the pixel point is determined through the directed field distance, and the pixel point is rendered based on the opacity, so that the drawing sequence of image drawing is consistent with the processing sequence of image signals, the processing complexity of line segment drawing is reduced, and the efficiency of image drawing is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without creative effort for a person of ordinary skill in the art.
Fig. 1 is a flowchart of a method for drawing a dotted line provided in the present application.
Fig. 2 is a flowchart of one example of a dashed line drawing method provided in the present application.
Fig. 3 is a schematic diagram of a capsule body of a target dotted line in the dotted line drawing method provided in the present application.
Fig. 4 is a schematic diagram of projection of a pixel point P on a target dashed line AB in the dashed line drawing method provided in the present application.
Fig. 5 is a schematic structural diagram of a dashed drawing system provided in the present application.
Fig. 6 is a schematic structural diagram of a terminal device provided in the present application.
Detailed Description
The application provides a method and a related device for drawing a dotted line, and in order to make the purposes, technical schemes and effects of the application clearer and more definite, the application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein includes all or any element and all combination of one or more of the associated listed items.
It will be understood by those skilled in the art that all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs unless defined otherwise. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
It should be understood that the sequence number and the size of each step in this embodiment do not mean the sequence of execution, and the execution sequence of each process is determined by the function and the internal logic of each process, and should not constitute any limitation on the implementation process of the embodiment of the present application.
The inventors have found through studies that the embedding apparatus processes an image signal in such a manner that each pixel is sequentially rendered in a row-column order from the upper left pixel as a start point, and thus, it is necessary to process the image in a row-column order from the upper left pixel as a start point. However, the existing dotted line drawing method uses one end of the dotted line as a starting point, and renders pixels to the other end of the line segment one by one along the line segment, so that the line segment drawing logic is inconsistent with the processing logic of the embedded device on the image signal, the processing complexity of the embedded device is increased, and the drawing efficiency of the line segment is further affected.
In order to solve the above-mentioned problem, in the embodiment of the present application, a target image and a capsule body corresponding to a target dotted line are acquired; traversing the pixel points in the target image along a preset traversing path; calculating the projection proportion of the projection vector of the pixel point on the target virtual line relative to the target virtual line; acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments; when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance; when the line segment portion is a broken line portion, configuring the opacity of the pixel point to be 0; and rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line. According to the method and the device, the opacity of the pixel point is determined through the directed field distance, and the pixel point is rendered based on the opacity, so that the drawing sequence of image drawing is consistent with the processing sequence of image signals, the processing complexity of line segment drawing is reduced, and the efficiency of image drawing is improved.
The application will be further described by the description of embodiments with reference to the accompanying drawings.
The present embodiment provides a broken line drawing method applied to drawing line segments or marking images in a multimedia system (e.g., vehicle-mounted scenes, etc.) by configuring an embedded device with an FPGA, an ARM microprocessor. As shown in fig. 1, the method includes:
s10, acquiring a target image and a capsule body corresponding to the target dotted line.
Specifically, the target dotted line is used to draw on the target image, in other words, by the dotted line drawing method provided in the present embodiment, the target dotted line may be drawn on the target image, where the target image may be an image carrying image content (for example, the target image is an image carrying a puppy, etc.) or may be a blank image. It will be appreciated that the target dashed line may be drawn in the blank image such that the target image carries only the target dashed line, or may be drawn on an image having image content such that the drawn target image carries the target dashed line and the image content carried prior to drawing.
The capsule body may be a cylinder wrapping the target dotted line, wherein the diameter of the cylinder is larger than the width of the target dotted line, and the height of the cylinder is determined according to the length of the target dotted line. In one implementation, as shown in fig. 3, the capsule body has a cylindrical structure with a height equal to the length of the segment of the target dashed line, and the diameter of the cylinder may be a value in the range of 2-16, for example, 6,8,9, etc.
Further, before acquiring the capsule body corresponding to the target dotted line, the image size of the target image and the position information of the target dotted line in the target image need to be acquired, for example, before acquiring the capsule body corresponding to the target dotted line, the start point coordinate and the end point coordinate of the target dotted line in the target image may be acquired. Further, acquiring the target image refers to acquiring image information of the target image, wherein when the target image is a blank image, the image information may include a width and a height of the target image; when the target image is an image carrying image content, the image information is the width and the height of the target image; and image content of the target image. In a typical implementation, the target image is acquired as the width W and the height H of the target image, and before the capsule body of the target dashed line is acquired, the starting point and the ending point of the target dashed line on the target image are known, the capsule body is a cylinder with the length of the line segment of the target dashed line being high, and r being the diameter, wherein the target dashed line is located on the central line of the cylinder, the value range of r is 2-16, and r is greater than half of the line segment width of the target dashed line.
S20, traversing the pixel points in the target image along a preset traversing path.
Specifically, the preset traversal path is a path traversed by pixels in the target image, and it can be understood that when the target dotted line is drawn on the target image, pixel points in the target image are traversed sequentially according to the preset traversal path. The preset traversal path may be determined based on an image signal processing sequence corresponding to the target image, or may be preset. In an exemplary implementation, the preset traversal path may be determined based on an image signal processing order corresponding to the target image. For example, the image signal processing order is in the row-column order from the upper left pixel as the start point, and then the preset traversal path is a path formed in the row-column order from the upper left pixel as the start point.
In addition, as shown in fig. 2, when the pixel points in the target image are traversed along the preset traversing path, a starting pixel point (x=0, y=0) in the preset traversing path may be selected, after the starting pixel point is traversed, the pixel coordinates (x, y) of a next pixel point adjacent to the starting pixel point are obtained according to the preset traversing path, and whether the next pixel point is included in the target image is determined (i.e. it is determined that 0< =x < W and 0< =y < H), when the next pixel point is included in the target image, the step of determining the directed field distance is performed for the next pixel point, and when the next pixel point is not included in the target image, the pixel point traversal is ended.
S30, calculating the projection proportion of the projection vector of each pixel point on the target virtual line relative to the target virtual line for each pixel point traversed.
Specifically, as shown in fig. 4, the projection vector is a vector formed by a starting point of the target dotted line and a projection point of the pixel point on the target dotted line, and the direction of the projection vector is from the starting point of the target dotted line to the projection point. In one implementation, the projection vector calculation formulas are respectively:
Figure BDA0003912285640000081
wherein A represents the starting point of the target dashed line; b represents the ending point of the target dotted line; p represents a pixel point; p' represents the projection point of P on AB.
Further, the projection point P' of the pixel point P may be on the target dashed line AB or may be outside the target dashed line AB, where the projection ratio has a value between 0 and 1 when the projection point is on the target dashed line AB, a projection ratio of 1 when the projection point is at the end point B, a projection ratio of 0 when the projection point is at the start point a, a projection ratio of less than 0 when the projection point is at the left end of the start point a, and a projection ratio of greater than 1 when the projection point is at the right end of the end point B. Thus, limiting the projection point P' to the target dashed line AB can be achieved by controlling the projection ratio to [0,1 ].
Based on this, the calculation formula of the projection ratio may be:
Figure BDA0003912285640000082
wherein t represents the projection ratio; clip (a, b, c) represents a clip function, and when h <0, t=0; when h >1, t=1, when 0< =h < =1, t=h; a represents the starting point of the target dashed line; b represents the ending point of the target dotted line; p represents a pixel point; p' represents the projection point of P on AB.
S40, acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments.
Specifically, the broken line segment includes a solid line portion and a broken line portion, the broken line portion being a non-display portion. Therefore, the opacity of the pixel point positioned in the dotted line part can be directly set to be preset opacity, for example, 0 and the like, without calculating the directed field distance of the pixel point positioned in the dotted line part, so that on one hand, the calculation times of the directed field distance can be reduced to improve the drawing speed of drawing the dotted line, and on the other hand, the drawing of the dotted line part of the target dotted line can be realized.
In one implementation manner, the determining the line segment portion where the pixel point is located according to the projection ratio and the line segment number specifically includes:
s41, determining a target value based on the number of line segments and the projection ratio, wherein the target value=the number of line segments×the projection ratio×2;
s42, obtaining a remainder of the target numerical value relative to 2;
s43, when the remainder is 0, judging that the pixel point is positioned in a solid line part;
and S44, when the remainder is not 0, judging that the pixel point is positioned at the dotted line part.
Specifically, the number of line segments is the number of solid line portions in the broken line segment, that is, the number of line segments of which the broken line segment is acquired refers to the number of solid line portions in the broken line segment. The duty ratio of the solid line portion and the broken line portion in the broken line segment is 1:1, that is, the duty ratio of the solid line portion is 50%. Thus, the segment length of the broken line segment=2×the length of the solid line portion×the number of segments of the solid line portion.
The target value is used to determine the portion where the pixel is located, that is, whether the pixel is located in the solid line portion or the broken line portion can be determined based on the target value, where the target value=the number of line segments×the projection ratio×2. After the target value is determined, whether the pixel point is located in the solid line portion or the broken line portion is determined according to the relationship of the target value and 2. In one implementation, when the remainder of the target value with respect to 2 is 0, the pixel point is determined to be in the solid line portion, when the remainder of the target value with respect to 2 is not 0, the pixel point is determined to be in the dotted line portion, wherein when the pixel point is in the dotted line portion, 0 is taken as the opacity of the pixel point, and when the pixel point is in the solid line portion, the opacity of the pixel point is determined according to the directed field distance. Therefore, the pixel points are positioned at the dotted line part, the step of determining the opacity of the pixel points according to the directed field distance is not needed to be executed, the calculation amount required by the opacity determining process is reduced, the opacity of each pixel point on the dotted line segment is determined, and the drawing efficiency of the line segment is improved. Of course, it should be noted that, in practical application, the initial segment of the target dashed line may be set as a solid line portion, and may also be set as a dashed line portion. Thus, in another implementation, the pixel is determined to be in the dashed line portion when the remainder of the target value with respect to 2 is 0, and the pixel is determined to be in the solid line portion when the remainder of the target value with respect to 2 is not 0.
The number of line segments may be changed according to the change in the length of the line segment of the target broken line, and the ratio of the length of the solid line portion and the width of the solid line portion may be controlled to a preset value (e.g., 3,4, etc.) to improve the drawing effect of the drawn broken line segment. In an exemplary implementation, the acquiring the number of segments of the dashed line segment specifically includes:
reading the length and width of the broken line segments, and determining the number of candidate line segments based on the length and width of the line segments, wherein the number of candidate line segments=the length/(preset value, the width of the line segments), and the preset value is the ratio of the length of the solid line part to the width of the line segments;
when the number of the candidate line segments is greater than or equal to a number threshold, taking the number threshold as the number of the line segments of the broken line segments;
and when the number of the candidate line segments is smaller than a number threshold value, taking the number of the candidate line segments as the number of the line segments of the broken line segments.
Specifically, the duty ratio of the solid line portion in the broken line segment is 50%, so that the segment length of the target broken line is equal to the solid line segment length of the solid line portion by 2×the number of segments, so that the number of segments=the segment length/(2×the solid line segment length). Further, the real line segment length of the solid line portion may be determined based on the line segment width, for example, the ratio of the line segment width to the real line segment length is a preset value d, and then the real line segment length may be determined based on the ratio of the line segment width to the real line segment length after the line segment width is read. Based on this, the number of line segments can be calculated according to the line segment length and the line segment width, where the number of line segments=line segment length/(2×preset value×line segment width), and the preset value is the ratio of the real line segment length to the line segment width. For example, the preset value is 3, then the number of line segments=real line segment length/(6×line segment width). In practical application, in order to avoid that the length of the solid line part is too short to be displayed due to the short length of the broken line, a small limit value of the length of the solid line segment may be set, and after determining a lower limit value of the length of the solid line segment, an upper limit value of the number of line segments may be determined. When the number of the candidate line segments is greater than or equal to the number threshold value, the number threshold value is used as the number of the line segments of the broken line segments; and when the number of the candidate line segments is smaller than a number threshold value, taking the number of the candidate line segments as the number of the line segments of the broken line segments. The number threshold is determined based on the length of the line segment, and may be a preset value, for example, the number threshold=the length of the line segment/20, or the number threshold=20, etc.
And S50, when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance.
Specifically, the directed field distance is a signed distance from a pixel point to a capsule body, wherein the pixel point is in the capsule body, the sign of the directed field distance of the pixel point is a positive sign, and the size is the distance from the pixel point to the boundary of the capsule body; when the pixel point is outside the capsule body, the sign of the directed field distance of the pixel point is a negative value, and the size is the distance between the pixel point and the boundary of the capsule body. It will be appreciated that the pixel location can be determined by the directed field distance as to whether it is inside or outside the capsule.
In one implementation manner, the calculating the directed field distance between the pixel point and the capsule body according to the projection ratio specifically includes:
s51, determining a projection point of the pixel point on the target virtual line according to a starting point, an ending point and the projection proportion of the target virtual line;
s52, obtaining the distance between the pixel point and the projection point, and taking the difference value of the distance and the capsule radius of the capsule body as the directed field distance between the pixel point and the capsule body.
Specifically, after the projection ratio is obtained, the pixel coordinates of the projection point may be determined according to the starting point, the ending point and the projection ratio of the starting target dashed line, where the pixel coordinates of the projection point may be expressed as:
P′=A+(B-A)*t
wherein P' represents a projection point of P on AB, and A represents a starting point of a target dotted line; b represents the ending point of the target dotted line, and t represents the projection ratio.
After the projection point P ' is acquired, a distance between the projection point P ' and the pixel point P is calculated, and for example, the distance may be a euclidean distance between a pixel coordinate of the projection point P ' and a pixel coordinate of the pixel point P. Then, determining a directed field distance based on the distance and the capsule radius, wherein a calculation formula of the directed field distance can be:
s=|P-P′|-r
where s represents the directed field distance, P' represents the projection point, P represents the pixel point, and r represents the capsule radius.
In one implementation, the determining the opacity of the pixel point based on the calculated directed field distance specifically includes:
calculating a target difference value between a first threshold value and the directed field distance;
when the target difference value is smaller than or equal to a second threshold value, the second threshold value is used as the opacity of the pixel point, wherein the second threshold value is smaller than the first threshold value;
when the target difference value is larger than a second threshold value and smaller than a third threshold value, taking the target difference value as the opacity of the pixel point, wherein the third threshold value is larger than the first threshold value;
and when the target difference value is greater than or equal to a third threshold value, taking the third threshold value as the opacity of the pixel point.
Specifically, the first threshold value, the second threshold value and the third threshold value are all opacity threshold values, wherein the first threshold value is smaller than the second threshold value, the second threshold value is smaller than the third threshold value, the first threshold value is the minimum value of the opacity of all pixel points, the third threshold value is the maximum value of the opacity of all pixel points, the second threshold value is used for reflecting the position relation between the pixel points and the target dotted line, and when the center of one pixel is located at the boundary of the target dotted line, the second threshold value is used as the transparency; when a pixel just leaves the target dashed line, a value between the first threshold and the second threshold is taken as opacity; when a pixel just enters the target dashed line, a value between the second threshold and the third threshold is taken as opacity. In this embodiment, the first threshold may be 0, the second threshold may be 0.5, and the third threshold may be 1. Of course, in practical applications, the first threshold, the second threshold, and the third threshold may be determined according to practical situations, which are not specifically limited herein.
And S60, when the line segment part is a dotted line part, configuring the opacity of the pixel point to be 0.
Specifically, the preset opacity is used to make the pixel point located at the dotted line portion not displayed, so that the preset opacity can be set to 0. Of course, in practical application, the preset opacity may be set according to the display effect of the dotted line portion, for example, the preset opacity is set to 0.01,0.05, or the like.
And S70, rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line.
Specifically, rendering the pixel based on the opacity refers to determining a gray level of the pixel based on the opacity, and then filling the pixel with the gray level, wherein the gray level of the pixel=255. Further, when drawing a broken line segment based on opacity, a jaggy phenomenon occurs at the solid line portion and the cutoff of the broken line portion, affecting the drawing effect of the broken line segment. Thus, when drawing a broken line segment based on opacity, a transition band may be added at the cut-off of the solid line portion and the broken line portion to remove the jaggies that may occur at the cut-off. Accordingly, in one implementation, before the rendering the pixel point based on the opacity, the method includes an antialiasing operation, where the antialiasing operation specifically includes:
acquiring a decimal part of the target value of the pixel point;
if the decimal part is smaller than a preset threshold value, taking 0.5 as the transparency of the pixel point;
and if the decimal part is greater than or equal to a preset threshold value, keeping the opacity of the pixel point unchanged.
Specifically, since one pixel is included in the solid line portion and one pixel is included in the broken line portion among two pixels adjacent to the truncated portion, the target value corresponding to one pixel is an odd number and the target value corresponding to one pixel is an even number, that is, the target value changes from a certain odd number to a next even number or from a certain even number to a next odd number, and the fractional portion thereof changes from x.9 to (x+1). 1, where x is an integer. Thus, whether the pixel is in the truncated portion may be determined according to the fractional portion of the target value, wherein when the fractional portion of the target value is less than 0.2, the pixel is in the truncated portion, and may be 0.5 as the transparency of the pixel, whereas when the fractional portion of the target value is greater than or equal to 0.2, the opacity of the pixel may be maintained unchanged.
In summary, the present embodiment provides a method for drawing a dashed line, where the method includes obtaining a target image and a capsule body corresponding to the target dashed line; traversing the pixel points in the target image along a preset traversing path; calculating the projection proportion of the projection vector of the pixel point on the target virtual line relative to the target virtual line; acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments; when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance; when the line segment portion is a broken line portion, configuring the opacity of the pixel point to be 0; and rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line. According to the method and the device, the opacity of the pixel point is determined through the directed field distance, and the pixel point is rendered based on the opacity, so that the drawing sequence of image drawing is consistent with the processing sequence of image signals, the processing complexity of line segment drawing is reduced, and the efficiency of image drawing is improved.
Based on the above-mentioned method for drawing a dotted line, the present embodiment provides a system for drawing a dotted line, as shown in fig. 5, the system includes:
the acquiring module 100 is configured to acquire a target image and a capsule body corresponding to a target dotted line, where the target dotted line is used to be drawn on the target image;
the traversing module 200 is configured to traverse the pixel points in the target image along a preset traversing path;
a calculating module 300, configured to calculate, for each pixel point traversed, a projection ratio of a projection vector of the pixel point on the target virtual line with respect to the target virtual line;
a first determining module 400, configured to obtain the number of line segments of the target dashed line, and determine a line segment portion where the pixel point is located according to the projection ratio and the number of line segments;
a second determining module 500, configured to calculate, when the line segment portion is a solid line portion, a directed field distance between the pixel point and the capsule body according to the projection ratio, and determine an opacity of the pixel point based on the calculated directed field distance;
a configuration module 600, configured to configure the opacity of the pixel point to be 0 when the line segment portion is a dotted line portion;
and the rendering module 700 is used for rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line.
Based on the above-described dotted line drawing method, the present embodiment provides a computer-readable storage medium storing one or more programs executable by one or more processors to implement the steps in the dotted line drawing method as described in the above-described embodiment.
Based on the above-mentioned dotted line drawing method, the present application also provides a terminal device, as shown in fig. 6, which includes at least one processor (processor) 20; a display screen 21; and a memory (memory) 22, which may also include a communication interface (communication interface) 23 and a bus 24. Wherein the processor 20, the display 21, the memory 22 and the communication interface 23 may communicate with each other via a bus 24. The display screen 21 is configured to display a user guidance interface preset in the initial setting mode. The communication interface 23 may transmit information. The processor 20 may invoke logic instructions in the memory 22 to perform the methods of the embodiments described above.
Further, the logic instructions in the memory 22 described above may be implemented in the form of software functional units and stored in a computer readable storage medium when sold or used as a stand alone product.
The memory 22, as a computer readable storage medium, may be configured to store a software program, a computer executable program, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 performs functional applications and data processing, i.e. implements the methods of the embodiments described above, by running software programs, instructions or modules stored in the memory 22.
The memory 22 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the terminal device, etc. In addition, the memory 22 may include high-speed random access memory, and may also include nonvolatile memory. For example, a plurality of media capable of storing program codes such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RandomAccessMemory, RAM), a magnetic disk, or an optical disk, or a transitory storage medium may be used.
In addition, the specific processes that the storage medium and the plurality of instruction processors in the terminal device load and execute are described in detail in the above method, and are not stated here.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (10)

1. A method of drawing a dashed line, the method comprising:
acquiring a target image and a capsule body corresponding to a target dotted line, wherein the target dotted line is used for drawing on the target image;
traversing the pixel points in the target image along a preset traversing path;
for each traversed pixel point, calculating the projection proportion of the projection vector of the pixel point on the target virtual line relative to the target virtual line;
acquiring the number of line segments of the target dotted line, and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments;
when the line segment part is a solid line part, calculating the directed field distance between the pixel point and the capsule body according to the projection proportion, and determining the opacity of the pixel point based on the calculated directed field distance;
when the line segment portion is a broken line portion, configuring the opacity of the pixel point to be 0;
and rendering the pixel points based on the opacity to obtain a target image drawn with the target dotted line.
2. The method according to claim 1, wherein the preset traversal path is determined based on an image signal processing order corresponding to the target image.
3. The method for drawing a dotted line according to claim 1, wherein said calculating the directed field distance between the pixel point and the capsule according to the projection ratio specifically includes:
determining a projection point of the pixel point on the target virtual line according to the starting point, the ending point and the projection proportion of the target virtual line;
and acquiring the distance between the pixel point and the projection point, and taking the difference value between the distance and the capsule radius of the capsule body as the directed field distance between the pixel point and the capsule body.
4. The method for drawing a dotted line according to claim 1, wherein determining the line segment portion where the pixel point is located according to the projection ratio and the number of line segments specifically includes:
determining a target value based on the number of line segments and the projection ratio, wherein the target value=the number of line segments×the projection ratio×2;
obtaining the remainder of the target value relative to 2;
when the remainder is 0, determining that the pixel point is positioned in a solid line part;
and when the remainder is not 0, determining that the pixel point is positioned at the dotted line part.
5. The method of drawing a dotted line according to claim 4, wherein before said rendering the pixel point based on the opacity, the method further comprises an antialiasing operation, wherein the antialiasing operation specifically comprises:
acquiring a decimal part of the target value of the pixel point;
if the decimal part is smaller than a preset threshold value, taking 0.5 as the transparency of the pixel point;
and if the decimal part is greater than or equal to a preset threshold value, keeping the opacity of the pixel point unchanged.
6. The method according to any one of claims 1, 4 or 5, wherein determining the opacity of the pixel point based on the calculated directed field distance specifically includes:
calculating a target difference value between a first threshold value and the directed field distance;
when the target difference value is smaller than or equal to a second threshold value, the second threshold value is used as the opacity of the pixel point, wherein the second threshold value is smaller than the first threshold value;
when the target difference value is larger than a second threshold value and smaller than a third threshold value, taking the target difference value as the opacity of the pixel point, wherein the third threshold value is larger than the first threshold value;
and when the target difference value is greater than or equal to a third threshold value, taking the third threshold value as the opacity of the pixel point.
7. The method for drawing a broken line according to claim 1, wherein the obtaining the number of segments of the broken line segment specifically includes:
reading the length and width of the broken line segments, and determining the number of candidate line segments based on the length and width of the line segments, wherein the number of candidate line segments=the length/(preset value, the width of the line segments), and the preset value is the ratio of the length of the solid line part to the width of the line segments;
when the number of the candidate line segments is greater than or equal to a number threshold, taking the number threshold as the number of the line segments of the broken line segments;
and when the number of the candidate line segments is smaller than a number threshold value, taking the number of the candidate line segments as the number of the line segments of the broken line segments.
8. A system for drawing a dashed line, the system comprising:
the device comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring a target image and a capsule body corresponding to a target dotted line, and the target dotted line is used for drawing on the target image;
the traversing module is used for traversing the pixel points in the target image along a preset traversing path;
the calculation module is used for calculating the projection proportion of the projection vector of each pixel point on the target virtual line relative to the target virtual line for each pixel point traversed;
the first determining module is used for obtaining the number of line segments of the target dotted line and determining the line segment part where the pixel point is located according to the projection proportion and the number of line segments;
the second determining module is used for calculating the directed field distance between the pixel point and the capsule body according to the projection proportion when the line segment part is a solid line part, and determining the opacity of the pixel point based on the calculated directed field distance;
a configuration module, configured to configure the opacity of the pixel point to be 0 when the line segment portion is a dotted line portion;
and the rendering module is used for rendering the pixel points based on the opacity so as to obtain a target image drawn with the target dotted line.
9. A computer-readable storage medium storing one or more programs executable by one or more processors to implement the steps in the method of drawing a dashed line as recited in any one of claims 1-7.
10. A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps of the method for drawing a dashed line according to any of claims 1-7.
CN202211325623.7A 2022-10-27 2022-10-27 Dotted line drawing method and related device Active CN115797496B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211325623.7A CN115797496B (en) 2022-10-27 2022-10-27 Dotted line drawing method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211325623.7A CN115797496B (en) 2022-10-27 2022-10-27 Dotted line drawing method and related device

Publications (2)

Publication Number Publication Date
CN115797496A CN115797496A (en) 2023-03-14
CN115797496B true CN115797496B (en) 2023-05-05

Family

ID=85434068

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211325623.7A Active CN115797496B (en) 2022-10-27 2022-10-27 Dotted line drawing method and related device

Country Status (1)

Country Link
CN (1) CN115797496B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109448088A (en) * 2018-10-22 2019-03-08 广州视源电子科技股份有限公司 Method and device for rendering three-dimensional graphic wire frame, computer equipment and storage medium
CN111369655A (en) * 2020-03-02 2020-07-03 网易(杭州)网络有限公司 Rendering method and device and terminal equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4719603B2 (en) * 2006-03-28 2011-07-06 富士通セミコンダクター株式会社 Drawing apparatus and broken line drawing method
US11914674B2 (en) * 2011-09-24 2024-02-27 Z Advanced Computing, Inc. System and method for extremely efficient image and pattern recognition and artificial intelligence platform

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109448088A (en) * 2018-10-22 2019-03-08 广州视源电子科技股份有限公司 Method and device for rendering three-dimensional graphic wire frame, computer equipment and storage medium
CN111369655A (en) * 2020-03-02 2020-07-03 网易(杭州)网络有限公司 Rendering method and device and terminal equipment

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
The northern-Italy Renaissance in a panel by Defendente Ferrari: A complete study with a multi-analytical investigation;Cavaleri Tiziana等;《Journal of Archaeological Science: Reports》;第46卷;103669 *
城市三维地形模型中的关键技术讨论;李雷等;《北京测绘》(第3期);88-91 *
基于离散LOD-Imposter技术的森林实时渲染算法研究及实现;王道臣;万旺根;丁欢;;计算机应用与软件(第06期);18-20 *

Also Published As

Publication number Publication date
CN115797496A (en) 2023-03-14

Similar Documents

Publication Publication Date Title
JP5593060B2 (en) Image processing apparatus and method of operating image processing apparatus
CN111913659B (en) Block data processing method, device and system and storage medium
CN103390260B (en) A kind of method and image processing apparatus for handling image
US9568333B2 (en) Method and system for selectively blending buildings to improve route visibility in a 3D navigation system
JP2013186624A (en) Image processor and operation method for image processor
CN115797496B (en) Dotted line drawing method and related device
CN114820834A (en) An effect processing method, device, device and storage medium
US20120218261A1 (en) Graphic system comprising a fragment graphic module and relative rendering method
US6747653B2 (en) Efficient object storage for zone rendering
CN116883228A (en) GPU pixel filling rate measuring method
CN112580638B (en) Text detection method and device, storage medium and electronic equipment
US12354570B2 (en) Display screen adjustment method, storage medium and terminal device
CN111583360B (en) Fan-shaped graph generation method and device, computer storage medium and electronic equipment
US20230252715A1 (en) Image processing method, apparatus and device and storage medium
CN110384926B (en) Position determining method and device
CN114820874A (en) A text shadow effect processing method, device, device and storage medium
CN111435416A (en) Barcode image analysis method and device based on multiple pipelines and storage medium
JP2017016511A (en) Distortion-corrected image processing apparatus and program
CN115905237B (en) Image processing method, device, HUD and storage medium
CN109712062B (en) Bitmap drawing method for graphic processor
JP3692639B2 (en) Drawing processor
CN119251840A (en) Lane marking method, device, equipment and medium
CN115249220A (en) Image rendering method, device, electronic device and computer storage medium
CN116266340A (en) Method, device, computer equipment and storage medium for enhanced display of graphic elements
CN115170658A (en) Line identification method and equipment for pixel map of automatic alarm system and storage medium

Legal Events

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