Line drawing method for drawing positioning line
By dividing the positioning line into multiple short-line segments and controlling the drawing step and direction, the problem of jagged sense of positioning line drawing in traditional CT medical imaging is solved, and smoother and more accurate positioning line drawing is achieved, improving the visual effect and interpretation accuracy of the image.
Patent Information
- Application Number
- CN202510508065.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-11
AI Technical Summary
In traditional CT medical imaging, the drawing of the positioning line when tilted at a small angle shows a significant jagged feeling, which affects the visual effect and interpretation of the image.
Divide the positioning line into several short line segments of equal step lengths, and make the adjacent short line segments have overlapping parts. By gradually calculating the starting position and length of each short line segment, all short line segments are drawn in sequence, and the drawing step length and direction are calculated based on the change in the main extension direction and the secondary extension direction.
Significantly reduce the jagged effect, ensure smooth transition and accurate drawing of positioning lines, and improve the accuracy of image interpretation.
Smart Images

Figure CN120284308A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of medical imaging technology, and particularly to a method for drawing positioning lines. Background Art
[0002] In the field of CT medical imaging, the drawing of positioning lines is mainly used to accurately mark the position of a certain tomographic slice on the positioning image, especially to help determine specific structures or regions in three-dimensional imaging data. However, when the traditional drawing method faces a straight line with a small-angle inclination, the vertical distance is short. When the horizontal distance between the two end points is much larger than the vertical distance and there is no overlapping drawing between pixels, a sawtooth effect will inevitably occur. This sawtooth effect affects the visual effect of the image, making the positioning line appear less smooth, which may affect the interpretation and use of the image.
[0003] The generation of the sawtooth effect stems from the traditional image pixelization processing principle. An image is composed of a finite number of pixels, and the pixels themselves cannot exactly represent a continuous straight line, especially when the alignment angle of the straight line with the pixel grid is small. The traditional drawing method will "truncate" the trajectory of the straight line into multiple discrete pixel points, resulting in jagged distortion at the edges.
[0004] Therefore, there is an urgent need for a new method for drawing positioning lines to make the drawing effect closer to a straight line in the sense. Summary of the Invention
[0005] The purpose of the present invention is to provide a method for drawing positioning lines to solve the problem that in the prior art, when the traditional drawing method faces a straight line with a small-angle inclination, obvious sawtooth feeling often appears, thus affecting the interpretation and use of the image.
[0006] To solve the above technical problems, the technical solution adopted by the present invention is:
[0007] A method for drawing positioning lines is realized by dividing the positioning line into several short line segments with equal step lengths and making adjacent short line segments have overlapping parts, and then drawing the several short line segments in sequence; by determining the main extension direction and the secondary extension direction of the positioning line, combining the change amounts of the positioning line in the main extension direction and the secondary extension direction, calculating the drawing step length and the drawing direction, and determining the drawing offsets of the first short line segment and the last short line segment. During the drawing process, the starting positions and lengths of each short line segment are calculated step by step, and all short line segments from the first segment to the last segment are drawn in sequence according to the predetermined drawing step length and drawing direction.
[0008] Further, the specific steps are as follows:
[0009] In the image coordinate system XOY where the positioning line needs to be drawn, determine the main extension direction and the secondary extension direction of the positioning line based on the change amounts of the positioning line in the X direction and the Y direction, and determine the calculation direction and the drawing direction of the positioning line based on the judgment result;
[0010] Define symbolic variables Xsign and Ysign, which respectively represent the extension directions of the positioning line on the X-axis and the Y-axis;
[0011] Define a symbolic variable N, which is used to represent the pixel distance between the two endpoints of the positioning line in the Y direction;
[0012] Based on the pixel distance N between the two endpoints of the positioning line in the Y direction and the absolute value of the change amount in the X direction, estimate a minimum step size and a maximum step size, and take the average value of the minimum step size and the maximum step size as the drawing step size, which is defined as the symbolic variable Length;
[0013] Based on the pixel distance N between the two endpoints of the positioning line in the Y direction, the drawing step size Length, and the absolute value of the change amount of the two endpoints of the positioning line in the X direction, calculate the drawing offset, which is defined as the symbolic variable theta;
[0014] Based on the starting coordinates of the positioning line, the drawing offset theta, the drawing step size Length, and the symbolic variable Xsign, calculate the ending coordinates of the first short line segment, and draw the first short line segment according to the starting coordinates of the positioning line and the ending coordinates of the first short line segment;
[0015] Define symbolic variables Xs and Ys, and (Xs, Ys) is used to represent the starting coordinates of all short line segments from the second short line segment to the last short line segment. Based on the starting coordinates (Xs, Ys), the drawing step size Length, and the symbolic variable Xsign, calculate the ending coordinates of all short line segments between the first short line segment and the last short line segment, draw them in a loop, and after each drawing is completed, update the value of Xs according to the drawing step size Length and the symbolic variable Xsign, and update the value of Ys according to the symbolic variable Ysign;
[0016] Based on the updated starting coordinates (Xs’, Ys’) of the last short line segment, the drawing offset theta, the drawing step size Length, and the symbolic variable Xsign, calculate the ending coordinates of the last short line segment, and draw the last short line segment according to the updated starting coordinates (Xs’, Ys’) of the last short line segment and the ending coordinates of the last short line segment.
[0017] Furthermore, in the image coordinate system XOY where the positioning line needs to be drawn, determine the main extension direction and the secondary extension direction of the positioning line based on the change amounts of the positioning line in the X direction and the Y direction, and determine the calculation direction and the drawing direction of the positioning line based on the judgment result, specifically as follows:
[0018] In the image coordinate system XOY where a positioning line needs to be drawn, set the starting coordinate of the positioning line as (X1, Y1) and the ending coordinate as (X2, Y2). Calculate the coordinate differences between the two endpoints, obtain the change amount of the positioning line in the X direction as |X2 - X1|, and the change amount in the Y direction as |Y2 - Y1|. Compare |X2 - X1| with |Y2 - Y1|;
[0019] If |Y2 - Y1| < |X2 - X1|, then the main extension direction of the positioning line is the X direction, and the secondary extension direction is the Y direction. Directly execute the subsequent steps;
[0020] If |Y2 - Y1| ≥ |X2 - X1|, then the main extension direction of the positioning line is the Y direction, and the secondary extension direction is the X direction. After swapping the values of Y1 and X1, and Y2 and X2, then execute the subsequent steps.
[0021] Furthermore, define symbolic variables Xsign and Ysign, which respectively represent the extension directions of the positioning line on the X - axis and Y - axis, as follows:
[0022] When X2 > X1, the positioning line extends in the positive direction on the X - axis, and Xsign = 1;
[0023] When X2 < X1, the positioning line extends in the negative direction on the X - axis, and Xsign = - 1;
[0024] When Y2 > Y1, the positioning line extends in the positive direction on the Y - axis, and Ysign = 1;
[0025] When Y2 < Y1, the positioning line extends in the negative direction on the Y - axis, and Ysign = - 1.
[0026] Furthermore, estimate a minimum step size, denoted as the symbolic variable minL1 = (|X2 - X1| + 1)×3 / (2×N + 1);
[0027] Estimate a maximum step size, denoted as the symbolic variable maxL1 = (|X2 - X1| + 1)×3 / (2×N - 3).
[0028] Furthermore, draw the offset theta = (|X2 - X1| + 1 - Length×(2 / 3×N - 1)) / 2.
[0029] Furthermore, the ending coordinate of the first short line segment is (X1+(theta + 1 / 3×Length - 1)×Xsign, Y1), and the starting coordinate of the second short line segment is (X1 + theta×Xsign, Y1 + 1×Ysign).
[0030] Further, the end coordinates of all the short line segments between the first short line segment and the last short line segment are (Xs + (Length - 1) × Xsign, Ys).
[0031] Further, update the value of Xs according to the drawing step length Length and the sign variable Xsign, and update the value of Ys according to the sign variable Ysign. Specifically:
[0032] Xs’ = Xs + 2 / 3 × Length × Xsign;
[0033] Ys’ = Ys + 1 × Ysign.
[0034] Further, the end coordinates of the last short line segment are (Xs’ + (theta + 1 / 3 × Length - 1) × Xsign, Ys’).
[0035] Due to the application of the above technical solutions, the beneficial effects of the present application compared with the prior art are as follows:
[0036] The drawing method of the drawing positioning line of the present application divides a long positioning line into multiple short line segments, and there is a certain proportion of overlap between every two adjacent short line segments. These short line segments are connected in sequence for drawing, significantly reducing the common sawtooth effect in the traditional drawing method. By precisely controlling the drawing step length and direction and adapting to small-angle inclination, it ensures the smooth transition and accurate drawing of the positioning line. At the same time, it can avoid discretization errors, improve the accuracy of the positioning line, and enhance the accuracy of image interpretation. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0038] Figure 1 Is the positioning line drawn by the drawing method of the drawing positioning line of the present application;
[0039] Figure 2 Is the positioning line drawn by the traditional method. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the protection scope of this application.
[0041] It should be noted that the terms "first", "second", etc. in the specification, claims and above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances for the embodiments of this application described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0042] In this application, the orientation or positional relationship indicated by the terms "upper", "lower", "left", "right", "front", "rear", "top", "bottom", "inner", "outer", "middle", "vertical", "horizontal", "lateral", "longitudinal", etc. is based on the orientation or positional relationship shown in the accompanying drawings. These terms are mainly used to better describe the present invention and its embodiments, and are not used to limit that the indicated devices, elements or components must have a specific orientation or be constructed and operated in a specific orientation.
[0043] Moreover, in addition to being able to represent an orientation or positional relationship, some of the above terms may also be used to represent other meanings. For example, the term "upper" may also be used to represent a certain attachment relationship or connection relationship in some cases. For those of ordinary skill in the art, the specific meanings of these terms in the present invention can be understood according to specific circumstances.
[0044] In addition, the terms "installed", "set", "provided with", "connected", "connected to", "socketed" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral structure; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or there can be internal communication between two devices, elements or components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0045] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0046] Please refer to Figure 1 and Figure 2 , the present application provides a method for drawing a positioning line, which realizes the drawing of the positioning line by dividing the positioning line into several short line segments with equal step lengths and making adjacent short line segments have overlapping parts, and sequentially drawing several short line segments.
[0047] By determining the main extension direction and the secondary extension direction of the positioning line, combining the change amounts of the positioning line in the main extension direction and the secondary extension direction, calculating the drawing step length and the drawing direction, and determining the drawing offsets of the first short line segment and the last short line segment, during the drawing process, by gradually calculating the starting positions and lengths of each short line segment, according to the predetermined drawing step length and drawing direction, all short line segments from the first segment to the last segment are sequentially drawn.
[0048] The specific steps of the drawing method are as follows:
[0049] Step 1: In the image coordinate system XOY where the positioning line needs to be drawn, judge the main extension direction and the secondary extension direction of the positioning line according to the change amounts of the positioning line in the X direction and the Y direction, and determine the calculation direction and the drawing direction of the positioning line based on the judgment result.
[0050] Specifically, in the image coordinate system XOY where the positioning line needs to be drawn, set the starting coordinate of the positioning line as (X1, Y1), the ending coordinate as (X2, Y2), calculate the coordinate differences between the two endpoints, obtain the change amount of the positioning line in the X direction as |X2 - X1|, and the change amount in the Y direction as
[0051] |Y2 - Y1|, and compare |X2 - X1| with |Y2 - Y1|; if |Y2 - Y1| < |X2 - X1|, then the main extension direction of the positioning line is the X direction, the secondary extension direction is the Y direction, and directly execute the subsequent steps; if |Y2 - Y1| ≥ |X2 - X1|, then the main extension direction of the positioning line is the Y direction, the secondary extension direction is the X direction, exchange the values of Y1 and X1, and the values of Y2 and X2, and then execute the subsequent steps.
[0052] Step 2: Define symbolic variables Xsign and Ysign to represent the extension directions of the positioning line on the X-axis and the Y-axis respectively.
[0053] Specifically, when X2 > X1, the positioning line extends in the positive direction along the X-axis, and Xsign = 1; when X2 < X1, the positioning line extends in the negative direction along the X-axis, and Xsign = -1; when Y2 > Y1, the positioning line extends in the positive direction along the Y-axis, and Ysign = 1; when Y2 < Y1, the positioning line extends in the negative direction along the Y-axis, and Ysign = -1.
[0054] Step 3: Define a symbolic variable N, which is used to represent the pixel distance between the two endpoints of the positioning line in the Y direction. It should be noted that N = |Y2 - Y1| + 1, and in this embodiment, the pixel distance N between the two endpoints of the positioning line in the Y direction is the number of segmented segments of the positioning line.
[0055] Step 4: Based on the pixel distance N between the two endpoints of the positioning line in the Y direction and the absolute value of the change amount in the X direction, estimate a minimum step size and a maximum step size, and take the average value of the minimum step size and the maximum step size as the drawing step size, which is defined as the symbolic variable Length.
[0056] Specifically, estimate a minimum step size, set as the symbolic variable minL1 = (|X2 - X1| + 1) × 3 / (2 × N + 1); estimate a maximum step size, set as the symbolic variable maxL1 = (|X2 - X1| + 1) × 3 / (2 × N - 3).
[0057] It should be noted that |X2 - X1| + 1 is the total length of the positioning line in the X direction. In this embodiment, there is an overlapping part of 1 / 3 between each adjacent short line segment, so the length of each small segment is (|X2 - X1| + 1) / (2 / 3 × N). Since the larger the denominator, the smaller the value, and the smaller the denominator, the larger the value, it can be inferred that (|X2 - X1| + 1) / (2 / 3 × N + 1 / 3) < (|X2 - X1| + 1) / (2 / 3 × N) < (|X2 - X1| + 1) / (2 / 3 × N - 1). After sorting out this inequality, we get minL1 = (|X2 - X1| + 1) × 3 / (2 × N + 1), and maxL1 = (|X2 - X1| + 1) × 3 / (2 × N - 3).
[0058] Step 5: Based on the pixel distance N between the two endpoints of the positioning line in the Y direction, the drawing step size Length, and the absolute value of the change amount in the X direction between the two endpoints of the positioning line, calculate the drawing offset, which is defined as the symbolic variable theta.
[0059] Specifically, the drawing offset theta = (|X2 - X1| + 1 - Length × (2 / 3 × N - 1)) / 2.
[0060] Step 6: Calculate the end coordinates of the first short line segment based on the starting coordinates of the positioning line, the drawing offset theta, the drawing step length Length, and the sign variable Xsign, and draw the first short line segment according to the starting coordinates of the positioning line and the end coordinates of the first short line segment.
[0061] Specifically, the end coordinates of the first short line segment are (X1 + (theta + 1 / 3 × Length - 1) × Xsign, Y1).
[0062] Step 7: Define the sign variables Xs and Ys. (Xs, Ys) is used to represent the starting coordinates of all short line segments from the second short line segment to the last short line segment. Calculate the end coordinates of all short line segments between the first short line segment and the last short line segment based on the starting coordinates (Xs, Ys), the drawing step length Length, and the sign variable Xsign, and draw them in a loop. After each drawing is completed, update the value of Xs according to the drawing step length Length and the sign variable Xsign, and update the value of Ys according to the sign variable Ysign.
[0063] Specifically, the starting coordinates of the second short line segment are (X1 + theta × Xsign, Y1 + 1 × Ysign), and the end coordinates of all short line segments between the first short line segment and the last short line segment are (Xs + (Length - 1) × Xsign, Ys).
[0064] Step 8: Calculate the end coordinates of the last short line segment based on the updated starting coordinates (Xs’, Ys’) of the last short line segment, the drawing offset theta, the drawing step length Length, and the sign variable Xsign, and draw the last short line segment according to the updated starting coordinates (Xs’, Ys’) of the last short line segment and the end coordinates of the last short line segment.
[0065] Specifically, Xs’ = Xs + 2 / 3 × Length × Xsign, Ys’ = Ys + 1 × Ysign, and the end coordinates of the last short line segment are (Xs’ + (theta + 1 / 3 × Length - 1) × Xsign, Ys’).
[0066] Finally, it should be noted that the above are only the preferred embodiments of the present invention and are not used to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for drawing positioning lines, characterized in that, The drawing of the positioning line is realized by dividing the positioning line into several short line segments of equal step lengths, making adjacent short line segments have overlapping parts, and sequentially drawing several short line segments; by determining the main extension direction and the secondary extension direction of the positioning line, combining the change amounts of the positioning line in the main extension direction and the secondary extension direction, calculating the drawing step length and the drawing direction, and determining the drawing offsets of the first short line segment and the last short line segment. During the drawing process, by gradually calculating the starting positions and lengths of each short line segment, all short line segments from the first segment to the last segment are sequentially drawn according to the predetermined drawing step length and drawing direction.
2. The line drawing method for drawing a positioning line according to claim 1, characterized in that, The specific steps are as follows: In the image coordinate system XOY where the positioning line needs to be drawn, judge the main extension direction and the secondary extension direction of the positioning line according to the change amounts of the positioning line in the X direction and the Y direction, and determine the calculation direction and the drawing direction of the positioning line based on the judgment results; Define symbolic variables Xsign and Ysign, which respectively represent the extension directions of the positioning line on the X-axis and the Y-axis; Define a symbolic variable N, which is used to represent the pixel distance between the two endpoints of the positioning line in the Y direction; Based on the pixel distance N between the two endpoints of the positioning line in the Y direction and the absolute value of the change amount in the X direction, estimate a minimum step length and a maximum step length, and take the average value of the minimum step length and the maximum step length as the drawing step length, defined as the symbolic variable Length; Based on the pixel distance N between the two endpoints of the positioning line in the Y direction, the drawing step length Length, and the absolute value of the change amount of the positioning line in the X direction, calculate the drawing offset, defined as the symbolic variable theta; Based on the starting coordinates of the positioning line, the drawing offset theta, the drawing step length Length, and the symbolic variable Xsign, calculate the end coordinates of the first short line segment, and draw the first short line segment according to the starting coordinates of the positioning line and the end coordinates of the first short line segment; Define symbolic variables Xs and Ys, (Xs, Ys) is used to represent the starting coordinates of all short line segments from the second short line segment to the last short line segment. Based on the starting coordinates (Xs, Ys), the drawing step length Length, and the symbolic variable Xsign, calculate the end coordinates of all short line segments between the first short line segment and the last short line segment, draw them in a loop, and after each drawing is completed, update the value of Xs according to the drawing step length Length and the symbolic variable Xsign, and update the value of Ys according to the symbolic variable Ysign; Based on the updated starting coordinates (Xs’, Ys’) of the last short line segment, the drawing offset theta, the drawing step length Length, and the symbolic variable Xsign, calculate the end coordinates of the last short line segment, and draw the last short line segment according to the updated starting coordinates (Xs’, Ys’) of the last short line segment and the end coordinates of the last short line segment.
3. A method of drawing a positioning line according to claim 2, characterized in that, In the image coordinate system XOY where the positioning line needs to be drawn, judge the main extension direction and the secondary extension direction of the positioning line according to the change amounts of the positioning line in the X direction and the Y direction, and determine the calculation direction and the drawing direction of the positioning line based on the judgment results, specifically as follows: In the image coordinate system XOY where a positioning line needs to be drawn, set the starting coordinate of the positioning line as (X1, Y1) and the ending coordinate as (X2, Y2). Calculate the coordinate differences between the two endpoints, obtain the change amount of the positioning line in the X direction as |X2 - X1|, and the change amount in the Y direction as |Y2 - Y1|. Compare |X2 - X1| with |Y2 - Y1|; If |Y2 - Y1| < |X2 - X1|, then the main extension direction of the positioning line is the X direction and the secondary extension direction is the Y direction, and directly execute the subsequent steps; If |Y2 - Y1| ≥ |X2 - X1|, then the main extension direction of the positioning line is the Y direction and the secondary extension direction is the X direction. After swapping the values of Y1 and X1, and the values of Y2 and X2, then execute the subsequent steps.
4. A method for drawing a positioning line according to claim 3, characterized in that, Define symbolic variables Xsign and Ysign, which respectively represent the extension directions of the positioning line on the X-axis and Y-axis, specifically as follows: When X2 > X1, the positioning line extends in the positive direction on the X-axis, and Xsign = 1; When X2 < X1, the positioning line extends in the negative direction on the X-axis, and Xsign = -1; When Y2 > Y1, the positioning line extends in the positive direction on the Y-axis, and Ysign = 1; When Y2 < Y1, the positioning line extends in the negative direction on the Y-axis, and Ysign = -1.
5. A line drawing method for drawing a positioning line according to claim 4, characterized in that: Estimate a minimum step length, set as the symbolic variable minL1 = (|X2 - X1| + 1) × 3 / (2 × N + 1); Estimate a maximum step length, set as the symbolic variable maxL1 = (|X2 - X1| + 1) × 3 / (2 × N - 3).
6. A method of drawing a positioning line as described in claim 5, characterized in that, Draw the offset theta = (|X2 - X1| + 1 - Length × (2 / 3 × N - 1)) / 2.
7. A method for drawing a positioning line according to claim 6, characterized in that, The ending coordinate of the first short line segment is (X1 + (theta + 1 / 3 × Length - 1) × Xsign, Y1), and the starting coordinate of the second short line segment is (X1 + theta × Xsign, Y1 + 1 × Ysign).
8. A method of drawing a positioning line as claimed in claim 7, characterized in that, The ending coordinates of all short line segments between the first short line segment and the last short line segment are (Xs + (Length - 1) × Xsign, Ys).
9. The method of drawing a positioning line according to claim 8, characterized in that, Update the value of Xs according to the drawing step length Length and the symbolic variable Xsign, and update the value of Ys according to the symbolic variable Ysign. Specifically: Xs’ = Xs + 2 / 3 × Length × Xsign; Ys’ = Ys + 1 × Ysign.
10. A method for drawing a positioning line as claimed in claim 9, characterized in that, The ending coordinate of the last short line segment is (Xs’ + (theta + 1 / 3 × Length - 1) × Xsign, Ys’).