A method for fitting a circular arc based on feature points and restoring an image contour
By fitting circular arcs with feature points, the outline of an image is identified and restored, solving the problem of inaccurate arc recognition in existing technologies and enabling image outline restoration with low data volume and high-speed transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIDIAN UNIV
- Filing Date
- 2023-08-02
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies struggle to accurately identify and fit arcs in image shapes, making it impossible to determine the start and end points of the arcs and affecting the low-data recovery of image shapes.
By identifying the feature point information of the target image, the initial point, intermediate point and termination point of each arc are determined. The cross product of vectors is used to determine the fitting direction, and the angle range is calculated according to the parameterized equation to fit each arc. Finally, the straight line feature points are connected to restore the outline.
It improves the accuracy of arc recognition, reduces the amount of data, and achieves low-data-volume recovery and high-speed transmission of image shape.
Smart Images

Figure CN116958183B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition, specifically relating to a method for fitting circular arcs based on feature points and restoring the outline of an image. Background Technology
[0002] When transmitting image information, it is generally desirable to transmit with the least amount of data but with the smallest possible error. For scenarios involving the real-time transmission of image shape information, it is necessary to transmit the edge contour shape of the image with the smallest possible amount of data. For example, for straight line segments and arc segments, information can be transmitted by selecting straight line feature points and arc feature points from the outline.
[0003] Currently, there are four main approaches to identifying and fitting the circular arcs at the edges of shapes:
[0004] The first method is the Hough transform circle detection method. This method transforms a circle in a two-dimensional image space into a point in a three-dimensional parameter space determined by the circle's radius and the coordinates of its center. Therefore, any circle defined by three points on the circumference should correspond to a single point in the three-dimensional parameter space after the Hough transform. The process iterates through all points on the circumference; any circle defined by three points corresponds to a point in the three-dimensional parameter space. After the iteration, the point with the highest cumulative number of occurrences in the three-dimensional space is considered the feature parameter of the corresponding circle.
[0005] The second method is a circle detection method with a known radius. The idea is to first find the edge points of the image, then use these edge points as centers to find all points on the circumference of the original image as possible center points, incrementing the accumulator for each center point by 1. After traversing all edge points, the point with the largest accumulated number of possible center points is identified as the true center point.
[0006] The third circular arc fitting algorithm is the perpendicular bisector intersection method. The fitting idea of this method is as follows: First, select one line segment from the short line segments that can be fitted into a circular arc by connecting their ends, and draw the perpendicular bisector of this line segment. Then, draw the perpendicular bisectors of the other short line segments, intersecting the perpendicular bisector of the line segment at several points. Among these points, find the point J closest to the line segment and the point Y farthest from the line segment. Use the distance between points J and Y as the length of the rectangle and the line segment as the width of the rectangle to determine the rectangular area. Calculate the average distance from all points within this area to the circular arc points as the approximate radius. Then, calculate the root mean square error of the distance from each point within the rectangle to the other circular arc points and the approximate radius. After traversing all points, find the point with the smallest root mean square error as the center of the circle, and calculate the average distance from the radius.
[0007] The fourth circular arc fitting algorithm is the least squares method. It finds the best function match for a set of data by minimizing the sum of squared errors. The core idea of using the least squares method to fit a circle is to obtain the coordinate data of the vertices of the polyline segments that can be fitted as an arc, and then, based on the principle of minimizing the sum of squared errors, find the best function match for these data, i.e., the best-fit circle.
[0008] In existing technologies, it is possible to identify and fit circles, but the final fitted result is a circle, not an arc, meaning the starting and ending points of the arc cannot be determined. Although the center and radius are determined, and a circle can be defined using its center and radius, an arc requires more constraints to be determined, such as the starting and ending points, and the order of rotation during the fitting process.
[0009] Therefore, how to improve the accuracy of arc recognition, thereby enhancing the arc fitting capability and completing the low-data-volume recovery of image shape, is an urgent problem to be solved in the field of image recognition. Summary of the Invention
[0010] To address the aforementioned problems in the prior art, this invention provides a method, apparatus, electronic device, and storage medium for fitting circular arcs based on feature points and recovering the outline of an image. The technical problem to be solved by this invention is achieved through the following technical solution:
[0011] In a first aspect, embodiments of the present invention provide a method for fitting an arc based on feature points and restoring the outline of an image, the method comprising:
[0012] Based on the feature point information of the obtained target image's outline, identify each arc segment and determine the position information of each arc segment, including information about the initial point, intermediate point, and termination point.
[0013] The center and radius of the circle are determined by the initial point, midpoint, and end point of the arc.
[0014] Using the initial point, midpoint, and center of the arc segment, the fitting direction of the arc segment is determined by the vector cross product;
[0015] The arc segment is represented parametrically, and the range of the corresponding angle of the arc segment is calculated based on the fitted direction of the arc segment.
[0016] The arc is fitted based on the center, radius, and corresponding angle range of the arc segment;
[0017] After each arc segment is fitted, the remaining straight line feature points are connected by straight lines to restore the outline of the target image.
[0018] In one embodiment of the present invention, the step of identifying each arc segment and determining the position information of each arc segment based on the feature point information of the acquired target image's outline includes:
[0019] Obtain the position and category of each feature point contained in the feature point information; wherein, the position of the feature point represents the horizontal and vertical coordinates of the pixel; the category of the feature point includes straight line feature points and circular arc feature points; all feature points are represented in the form of a feature point sequence;
[0020] Mark the straight line feature points as the first value and the circular arc feature points as the second value;
[0021] Based on the continuous arrangement of the second value and the jump of the value of the feature point markers at both ends, identify each arc segment;
[0022] For each identified arc segment, the initial and final points of the arc segment are determined based on the positions of the feature points at both ends. The next feature point after the initial point of the arc segment is taken as the intermediate point. The relevant information of the initial point, intermediate point, and final point is determined, including the order in the feature point sequence, the horizontal and vertical coordinates of the feature points, and the category of the feature points.
[0023] In one embodiment of the present invention, determining the corresponding center and radius of the arc segment by its initial point, midpoint, and end point includes:
[0024] Connect the initial point, midpoint, and end point of the arc with straight lines in each pair;
[0025] Draw the perpendicular bisector of each line;
[0026] The intersection of the three perpendicular bisectors is defined as the center of the arc segment, and any distance between the center of the arc segment and the corresponding initial point, intermediate point, and termination point is defined as the radius of the arc segment.
[0027] In one embodiment of the present invention, determining the fitting direction of the arc segment based on the vector cross product using the initial point, midpoint, and center of the arc segment includes:
[0028] Based on the initial point, midpoint, and center of the arc segment, determine the prior vector and subsequent vector of the arc segment; according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule, determine whether the fitting direction of the arc segment is clockwise or counterclockwise.
[0029] In one embodiment of the present invention, determining the prior vector and subsequent vector of the circular arc based on the initial point, midpoint, and center of the arc; and determining whether the fitting direction of the circular arc is clockwise or counterclockwise according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule, includes:
[0030] The vector from the center of the arc segment to the initial point is defined as the prior vector;
[0031] The vector from the center of the arc to the midpoint is determined as the subsequent vector;
[0032] According to the right-hand screw rule, the four fingers turn from the starting vector to the direction of the intermediate vector. If the direction of the thumb points inward into the paper, the fitting direction of the arc segment is considered to be clockwise; if the direction of the thumb points outward from the paper, the fitting direction of the arc segment is considered to be counterclockwise.
[0033] In one embodiment of the present invention, the parameterization represents the arc segment, and the calculation of the range of angles corresponding to the arc segment based on the fitting direction of the arc segment includes:
[0034] The parametric equation of the circle is determined as follows:
[0035]
[0036] Where r is the radius of the circle, x1 is the x-coordinate of the center of the circle, y1 is the y-coordinate of the center of the circle, x is the x-coordinate of any point on the circle, y is the y-coordinate of any point on the circle, and θ is the phase of any point on the circle, ranging from 0 to 2π.
[0037] The vector from the center of the arc segment to the initial point is defined as the starting vector, and the vector from the center of the arc segment to the midpoint is defined as the ending vector.
[0038] Based on the fitting direction of the arc segment and the phase values of the starting vector and the ending vector, the θ range of the arc segment fitting is determined.
[0039] In one embodiment of the present invention, determining the θ range of the circular arc fitting based on the fitting direction of the arc segment and the phase values of the starting vector and the ending vector includes:
[0040] When the phase value θ1 of the initial vector is equal to the phase value θ2 of the final vector, the fitted θ range is from 0 to 2π; when the phase value θ1 of the initial vector is not equal to the phase value θ2 of the final vector, a classification judgment is made based on the fitting direction of the arc segment, including:
[0041] The fitting direction for this arc segment is clockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitting range of θ is from θ2 to θ1; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitting range of θ is from θ2 to θ1+2π; when the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ2 to θ1; when the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ2 to θ1+2π.
[0042] The fitting direction for this arc segment is counterclockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitting range of θ is from θ1 to θ2+2π; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitting range of θ is from θ1 to θ2; when the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ1 to θ2+2π; when the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ1 to θ2.
[0043] Secondly, embodiments of the present invention provide an apparatus for fitting an arc based on feature points and restoring the outline of an image, the apparatus comprising:
[0044] The arc segment position information determination module is used to identify each arc segment and determine the position information of each arc segment based on the feature point information of the outer contour of the acquired target image, including the relevant information of the initial point, the middle point and the end point.
[0045] The module for determining the center and radius of an arc segment is used to determine the center and radius of the corresponding arc segment based on its initial point, midpoint, and end point.
[0046] The module for determining the fitting direction of an arc segment is used to determine the fitting direction of the arc segment based on the vector cross product using the initial point, midpoint, and center of the arc segment.
[0047] The arc segment angle range determination module is used to parametrically represent the arc segment and calculate the range of the corresponding angles of the arc segment based on the fitting direction of the arc segment.
[0048] The arc segment fitting module is used to fit the arc segment based on the center, radius, and corresponding angle range of the arc segment.
[0049] The image outline restoration module is used to connect the remaining straight line feature points after each arc segment has been fitted, thereby restoring the outline of the target image.
[0050] Thirdly, embodiments of the present invention provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0051] The memory is used to store computer programs;
[0052] When the processor executes the program stored in the memory, it implements the steps of the method for fitting arcs based on feature points and restoring the outline of an image provided in the embodiments of the present invention.
[0053] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for fitting arcs based on feature points and restoring the outline of an image provided in embodiments of the present invention.
[0054] The beneficial effects of this invention are:
[0055] This invention proposes a method for fitting arcs and restoring the outline of an image based on feature points. Each arc segment is determined using only three points: the initial point, the intermediate point, and the ending point, eliminating other redundant arc points. These three points are sufficient to reconstruct the corresponding arc segment, significantly reducing the amount of data representing the arc. After obtaining known feature point information, this invention selects either straight line fitting or arc fitting based on the feature point category. Compared to existing algorithms that can only determine the entire circle, this method can more accurately determine the arc range. This invention's method can be used for arc recognition and low-data-volume restoration of images, improving the accuracy of arc recognition. The low data volume also allows for faster transmission of shape information.
[0056] Furthermore, in this embodiment of the invention, the arc is represented by a parametric equation, and the angle range of the arc is accurately determined based on the fitting direction of the arc and the relative positions of the starting vector and the ending vector, which is more accurate than the method that can only restore the entire circle. Attached Figure Description
[0057] Figure 1 This is a flowchart illustrating a method for fitting an arc based on feature points and restoring the outline of an image, provided in an embodiment of the present invention.
[0058] Figures 2(a), 2(b), and 2(c) show the results of feature point extraction of the outlines of a car shape, a dolphin shape, and a circle shape according to an embodiment of the present invention.
[0059] Figures 3(a), 3(b), and 3(c) show the results of arc recognition of car shape, dolphin shape, and round shape based on the corresponding feature point information in the embodiments of the present invention.
[0060] Figures 4(a), 4(b), and 4(c) show the restored car outline, dolphin outline, and circular outline, respectively, according to the embodiments of the present invention.
[0061] Figure 5 This is a schematic diagram of the structure of a device for fitting an arc based on feature points and restoring the outline of an image, provided in an embodiment of the present invention.
[0062] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0063] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] To improve the accuracy of arc recognition, thereby enhancing arc fitting capabilities and enabling low-data-volume recovery of image shape, this invention provides a method, apparatus, electronic device, and storage medium for fitting arcs based on feature points and recovering image outlines.
[0065] It should be noted that the execution subject of the method for fitting an arc based on feature points and restoring the outline of an image provided in this embodiment of the invention can be a device for fitting an arc based on feature points and restoring the outline of an image, and the device can run in an electronic device. The electronic device can be a server or a terminal device, but is not limited to these.
[0066] In a first aspect, embodiments of the present invention provide a method for fitting circular arcs based on feature points and restoring the outline of an image, such as... Figure 1 As shown, the method may include the following steps:
[0067] S1. Based on the feature point information of the outer contour of the acquired target image, identify each arc segment and determine the position information of each arc segment, including the relevant information of the initial point, intermediate point and termination point.
[0068] In this embodiment of the invention, the executing entity acts as the data receiving end, receiving feature point information of the outer contour of the target image sent by the data sending end. The target image is the original image from which the outer contour needs to be recovered in this embodiment of the invention. For the data sending end, it can use existing methods to extract the edge contour of the target image, thereby outputting the feature point information of the target image's outer contour. For example, the data sending end can use the Canny operator to extract the edge contour of the target image, comparing the curvature values of each point with points in its adjacent region to determine whether the feature point is a circular arc feature point or a straight line feature point, i.e., determining the category of the feature point, and determining the horizontal and vertical coordinates of each feature point's pixels in the target image to represent the feature point's position, generating the feature point information of the target image's outer contour based on the positions and categories of all feature points. Currently, this embodiment of the invention does not impose specific limitations on the generation process of the feature point information of the target image's outer contour.
[0069] For easier understanding, please refer to Figures 2(a), 2(b), and 2(c), which show the results of feature point extraction from the outlines of a car, a dolphin, and a circle, respectively. These figures represent the images after feature point extraction using the Douglas-Peucker algorithm, where points on the outlines are the feature points. Here, DP refers to the Douglas-Peucker algorithm, a classic algorithm for extracting edge feature points.
[0070] Regarding S1, in one optional implementation, identifying each arc segment and determining the position information of each arc segment based on the feature point information of the acquired target image's outline may include the following steps:
[0071] S11, Obtain the position and category of each feature point contained in the feature point information;
[0072] The location of a feature point represents the horizontal and vertical coordinates of a pixel; the types of feature points include straight line feature points and circular arc feature points; all feature points are represented in the form of a feature point sequence.
[0073] S12, mark the straight line feature points as the first value and the circular arc feature points as the second value;
[0074] The first and second values can be any two different values. For example, in one optional implementation, the first value can be 1 and the second value can be 0. That is, if the straight line feature points are marked as 1 and the arc feature points are marked as 0, then it can be understood that the labels at the feature point categories are a sequence of 0 and 1 arranged according to the contour feature points.
[0075] S13, Identify each arc segment based on the continuous arrangement of the second value and the jump of the value of the feature point markers at both ends;
[0076] It is understandable that if there are multiple consecutive 0s representing the feature points of a circular arc, then it can be determined that a circular arc segment exists at that location. The sequence at the arc is a series of consecutive 0s arranged together, and the boundary between 0s and 1s may be the start or end point of the arc.
[0077] Therefore, we can iterate through each feature point and determine whether the feature points before and after each feature point are marked as 0 or 1. If it is the endpoint of an arc, then one of its preceding or following feature points must be marked as 1, and the other as 0.
[0078] S14. For each identified arc segment, determine the initial and final points of the arc segment based on the positions of the feature points at both ends, take the next feature point of the initial point of the arc segment as the intermediate point, and determine the relevant information of the initial point, intermediate point and final point, including the order in the feature point sequence, the horizontal and vertical coordinates of the feature points and the category of the feature points.
[0079] For each identified arc segment, step S13 determines the initial and ending points, and step S14 further determines the relevant information for these two points. Furthermore, in S14, the next feature point after the initial point of the arc segment can be used as an intermediate point, and the relevant information for this intermediate point is also determined. The relevant information for these three points includes at least the order of each point in the feature point sequence, the x and y coordinates of the feature point, and the category of the feature point.
[0080] For easier understanding, please refer to Figures 3(a), 3(b), and 3(c), which show the results of arc recognition for the shapes of a car, a dolphin, and a circle based on the corresponding feature point information. Only the information of the initial point, midpoint, and end point of each arc is retained. Subsequent reconstruction of the arc is based solely on these three feature points.
[0081] S2, the center and radius of the circle are determined by the initial point, midpoint and end point of the arc;
[0082] In one optional implementation, S2 may include the following steps:
[0083] S21, connect the initial point, the middle point and the end point of the arc segment with straight lines in pairs;
[0084] S22, draw the perpendicular bisector of each line;
[0085] S23, the intersection of the three perpendicular bisectors is determined as the center of the arc segment, and any distance between the center of the arc segment and the corresponding initial point, intermediate point and termination point is determined as the radius of the arc segment.
[0086] Using relevant knowledge of plane geometry, we can understand that three perpendicular bisectors converge at a single point, which can be considered the center of the circle defined by the three points. The distance from this center to the three points is the same, which is the radius.
[0087] S3. Using the initial point, midpoint, and center of the arc segment, determine the fitting direction of the arc segment based on the vector cross product.
[0088] In this embodiment of the invention, there are two directions for fitting the arc: clockwise fitting and counterclockwise fitting. The specific direction needs to be determined based on the characteristics of the arc segment.
[0089] In one optional implementation, S3 may include:
[0090] Based on the initial point, midpoint, and center of the arc segment, determine the prior vector and subsequent vector of the arc segment; according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule, determine whether the fitting direction of the arc segment is clockwise or counterclockwise.
[0091] In this embodiment of the invention, the vector from the center of the arc segment to the initial point can be determined as the prior vector, and the vector from the center of the arc segment to the midpoint can be determined as the subsequent vector. The four-finger screw rule can be either a right-hand screw rule or a left-hand screw rule, but the judgment methods corresponding to different rules are opposite.
[0092] For example, taking the right-hand screw rule as an example, the above process can include:
[0093] 1) Determine the vector from the center of the arc segment to the initial point as the prior vector;
[0094] 2) Determine the vector from the center of the arc segment to the midpoint as the subsequent vector;
[0095] 3) According to the right-hand screw rule, the four fingers turn from the starting vector to the direction of the intermediate vector. If the direction of the thumb points inward into the paper, the fitting direction of the arc segment is considered to be clockwise; if the direction of the thumb points outward from the paper, the fitting direction of the arc segment is considered to be counterclockwise.
[0096] To make it easier to understand, let's assume the starting point of the arc segment is A, the next point after the starting point is B, the ending point is C, and the center of the circle corresponding to the arc segment is O. According to the right-hand rule, the four fingers... Turn For the direction, if the thumb points inwards from the paper, the direction of the circular arc fitting is considered to be clockwise; if the thumb points outwards from the paper, the direction of the fitting is considered to be counterclockwise.
[0097] If the left-hand screw rule is adopted, it can be understood that the corresponding process in 3) above is as follows: According to the left-hand screw rule, the four fingers turn from the starting vector to the direction of the intermediate vector. If the direction of the thumb points inward into the paper, the fitting direction of the arc segment is considered to be counterclockwise; if the direction of the thumb points outward from the paper, the fitting direction of the arc segment is considered to be clockwise.
[0098] In practice, any four-finger spiral rule can be selected to determine the fitting direction of each arc segment.
[0099] S4, parameterizes the arc segment and calculates the range of angles corresponding to the arc segment based on the fitting direction of the arc segment;
[0100] In one optional implementation, S4 may include the following steps:
[0101] S41, the parametric equation of the circle is determined as follows:
[0102]
[0103] Where r is the radius of the circle, x1 is the x-coordinate of the center of the circle, y1 is the y-coordinate of the center of the circle, x is the x-coordinate of any point on the circle, y is the y-coordinate of any point on the circle, and θ is the phase of any point on the circle, ranging from 0 to 2π.
[0104] The key point of this invention is to calculate the range of an arc θ. The phase value of the vector can be obtained using the atan2 function in MATLAB, but the angle range obtained here is from -π to π. If the fitting direction and relative position are not considered, the arc angle range calculated by directly subtracting the phase value of the starting vector from the phase value of the ending vector is incorrect.
[0105] Therefore, this invention presents a method for calculating the range of angles θ corresponding to an arc based on the direction of arc fitting. After determining θ, it is only necessary to use the parametric equation of the circle to fit the arc.
[0106] S42, determine the vector from the center of the arc segment to the initial point as the starting vector, and the vector from the center of the arc segment to the midpoint as the ending vector;
[0107] To facilitate understanding, continuing with the example above, let the initial vector be set to... The endpoint vector is set as The phase values of the starting and ending vectors can be obtained using the atan2 function in MATLAB, which will not be elaborated here.
[0108] S43, Based on the fitting direction of the arc segment and the phase values of the starting vector and the ending vector, determine the θ range of the arc segment fitting.
[0109] Specifically, S43 may include the following:
[0110] When the phase value θ1 of the initial vector is equal to the phase value θ2 of the final vector, the fitted θ range is from 0 to 2π. When the phase value θ1 of the initial vector is not equal to the phase value θ2 of the final vector, a classification judgment is made based on the fitting direction of the arc segment, including: for the fitting direction of the arc segment being clockwise:
[0111] (1) If the phase values of the starting vector and the ending vector are both greater than 0 or both less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitted θ range is from θ2 to θ1; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitted θ range is from θ2 to θ1+2π.
[0112] (2) When the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ2 to θ1.
[0113] (3) When the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ2 to θ1+2π.
[0114] (ii) The fitting direction for this arc segment is counterclockwise:
[0115] (1) If the phase values of the starting vector and the ending vector are both greater than 0 or both less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitted θ range is from θ1 to θ2+2π; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitted θ range is from θ1 to θ2.
[0116] (2) When the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ1 to θ2+2π.
[0117] (3) When the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ1 to θ2.
[0118] In this embodiment of the invention, when the phase value of the starting vector and the phase value of the ending vector are not equal, the fitting direction of the arc segment, as well as the specific numerical values and comparison of the phase values of the starting vector and the ending vector, can be used to query the above-mentioned classification content to determine the θ range of the arc segment fitting.
[0119] S5, Fit the arc segment based on the center, radius, and corresponding angle range of the arc segment;
[0120] Given the center and radius of the circle, and based on the determined range of the θ angle, the arc can be accurately fitted using the parametric equation of the circle.
[0121] By following the steps above, each arc segment can be fitted.
[0122] S6. After all the arc segments have been fitted, the remaining straight line feature points are connected by straight lines to restore the outline of the target image.
[0123] After fitting each arc segment, the remaining straight line feature points can be directly connected by straight lines to finally restore the outline of the target image.
[0124] Please refer to Figures 4(a), 4(b), and 4(c) for understanding the recovered image outlines. These three figures represent the recovered outlines of a car, a dolphin, and a circle, respectively—that is, the restored vector graphics. It is evident that the method of this embodiment can recover the complete outline of a target image. Figures 4(a), 4(b), and 4(c) demonstrate that by using the method of this embodiment to recover images from filtered and classified edge feature points, it is possible to describe the shape information with a relatively small amount of data and achieve real-time transmission.
[0125] Images are typically recorded using raster graphics, but raster graphics require recording information for each pixel, resulting in a large amount of data. When acquiring the outline of a target in real time, it's desirable to minimize the data size while still reconstructing the original target's shape as completely as possible.
[0126] This invention proposes a method for fitting arcs and restoring the outline of an image based on feature points. Each arc segment is determined using only three points: the initial point, the intermediate point, and the ending point, eliminating other redundant arc points. These three points are sufficient to reconstruct the corresponding arc segment, significantly reducing the amount of data representing the arc. After obtaining known feature point information, this invention selects either straight line fitting or arc fitting based on the feature point category. Compared to existing algorithms that can only determine the entire circle, this method can more accurately determine the arc range. This invention's method can be used for arc recognition and low-data-volume restoration of images, improving the accuracy of arc recognition. The low data volume also allows for faster transmission of shape information.
[0127] Furthermore, in this embodiment of the invention, the arc is represented by a parametric equation, and the angle range of the arc is accurately determined based on the fitting direction of the arc and the relative positions of the starting vector and the ending vector, which is more accurate than the method that can only restore the entire circle.
[0128] Secondly, corresponding to the above method embodiments, this invention also provides an apparatus for fitting an arc based on feature points and restoring the outline of an image, such as... Figure 5 As shown, the device includes:
[0129] The arc segment position information determination module 501 is used to identify each arc segment and determine the position information of each arc segment, including the relevant information of the initial point, the middle point and the end point, based on the feature point information of the acquired target image's outline.
[0130] The arc segment center and radius determination module 502 is used to determine the corresponding center and radius from the initial point, middle point and end point of the arc segment;
[0131] The arc segment fitting direction determination module 503 is used to determine the fitting direction of the arc segment based on the vector cross product using the initial point, intermediate point and center of the arc segment.
[0132] The arc segment angle range determination module 504 is used to parametrically represent the arc segment and calculate the range of the corresponding angle of the arc segment based on the fitting direction of the arc segment.
[0133] The arc segment fitting module 505 is used to fit the arc segment based on the center, radius and corresponding angle range of the arc segment.
[0134] The image outline restoration module 506 is used to connect the remaining straight line feature points with straight lines after each arc segment has been fitted, so as to restore the outline of the target image.
[0135] Optionally, the arc segment position information determination module 501 is specifically used for:
[0136] Obtain the position and category of each feature point contained in the feature point information; wherein, the position of the feature point represents the horizontal and vertical coordinates of the pixel; the category of the feature point includes straight line feature points and circular arc feature points; all feature points are represented in the form of a feature point sequence;
[0137] Mark the straight line feature points as the first value and the circular arc feature points as the second value;
[0138] Based on the continuous arrangement of the second value and the jump of the value of the feature point markers at both ends, identify each arc segment;
[0139] For each identified arc segment, the initial and final points of the arc segment are determined based on the positions of the feature points at both ends. The next feature point after the initial point of the arc segment is taken as the intermediate point. The relevant information of the initial point, intermediate point, and final point is determined, including the order in the feature point sequence, the horizontal and vertical coordinates of the feature points, and the category of the feature points.
[0140] Optional, the arc segment center radius determination module 502 is specifically used for:
[0141] Connect the initial point, midpoint, and end point of the arc with straight lines in each pair;
[0142] Draw the perpendicular bisector of each line;
[0143] The intersection of the three perpendicular bisectors is defined as the center of the arc segment, and any distance between the center of the arc segment and the corresponding initial point, intermediate point, and termination point is defined as the radius of the arc segment.
[0144] Optionally, the arc segment fitting direction determination module 503 is specifically used for:
[0145] Based on the initial point, midpoint, and center of the arc segment, determine the prior vector and subsequent vector of the arc segment; according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule, determine whether the fitting direction of the arc segment is clockwise or counterclockwise.
[0146] Optionally, the arc segment fitting direction determination module 503 determines the prior vector and subsequent vector of the arc segment based on the initial point, midpoint, and center of the arc segment; and determines whether the fitting direction of the arc segment is clockwise or counterclockwise according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule. Specifically, it is used for:
[0147] The vector from the center of the arc segment to the initial point is defined as the prior vector;
[0148] The vector from the center of the arc to the midpoint is determined as the subsequent vector;
[0149] According to the right-hand screw rule, the four fingers turn from the starting vector to the direction of the intermediate vector. If the direction of the thumb points inward into the paper, the fitting direction of the arc segment is considered to be clockwise; if the direction of the thumb points outward from the paper, the fitting direction of the arc segment is considered to be counterclockwise.
[0150] Optionally, the arc segment angle range determination module 504 includes:
[0151] The submodule for determining the parametric equation of a circle is used to determine the parametric equation of the circle as follows:
[0152]
[0153] Where r is the radius of the circle, x1 is the x-coordinate of the center of the circle, y1 is the y-coordinate of the center of the circle, x is the x-coordinate of any point on the circle, y is the y-coordinate of any point on the circle, and θ is the phase of any point on the circle, ranging from 0 to 2π.
[0154] The vector determination submodule is used to determine the vector from the center of the arc segment to the initial point as the starting vector, and the vector from the center of the arc segment to the midpoint as the ending vector.
[0155] The circular arc fitting angle range determination submodule is used to determine the θ range of the circular arc fitting based on the fitting direction of the circular arc segment and the phase values of the starting vector and the ending vector.
[0156] Optional, the circular arc fitting angle range determination submodule is specifically used for:
[0157] When the phase value θ1 of the initial vector is equal to the phase value θ2 of the final vector, the fitted θ range is from 0 to 2π; when the phase value θ1 of the initial vector is not equal to the phase value θ2 of the final vector, a classification judgment is made based on the fitting direction of the arc segment, including:
[0158] The fitting direction for this arc segment is clockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitting range of θ is from θ2 to θ1; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitting range of θ is from θ2 to θ1+2π; when the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ2 to θ1; when the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ2 to θ1+2π.
[0159] The fitting direction for this arc segment is counterclockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or less than 0: when the phase value θ1 of the starting vector is greater than the phase value θ2 of the ending vector, the fitting range of θ is from θ1 to θ2+2π; when the phase value θ1 of the starting vector is less than the phase value θ2 of the ending vector, the fitting range of θ is from θ1 to θ2; when the phase value θ1 of the starting vector is greater than or equal to 0 and the phase value θ2 of the ending vector is less than or equal to 0, the fitting range of θ is from θ1 to θ2+2π; when the phase value θ1 of the starting vector is less than or equal to 0 and the phase value θ2 of the ending vector is greater than or equal to 0, the fitting range of θ is from θ1 to θ2.
[0160] For details on the specific processing procedures of each module of the device, please refer to the relevant content in the first section, which will not be repeated here.
[0161] Thirdly, embodiments of the present invention also provide an electronic device, such as... Figure 6As shown, it includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0162] The memory is used to store computer programs;
[0163] When the processor executes the program stored in the memory, it implements the steps of any of the methods provided in the first aspect of the present invention for fitting an arc based on feature points and restoring the outline of an image.
[0164] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0165] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0166] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0167] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0168] The method provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, etc. No limitation is made herein; any electronic device that can implement this invention falls within the protection scope of this invention.
[0169] Fourthly, corresponding to the method for fitting an arc based on feature points and restoring the outline of an image provided in the first aspect, this embodiment of the invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements any of the steps of the method for fitting an arc based on feature points and restoring the outline of an image provided in the first aspect of this invention.
[0170] For the embodiments of the device / electronic device / storage medium, since they are basically similar to the method embodiments, the description is relatively simple, and relevant parts can be referred to in the description of the method embodiments.
[0171] It should be noted that the device, electronic device, and storage medium in the embodiments of the present invention are respectively the device, electronic device, and storage medium for applying the above-described method of fitting arcs based on feature points and restoring the outline of an image. Therefore, all embodiments of the above-described method of fitting arcs based on feature points and restoring the outline of an image are applicable to the device, electronic device, and storage medium, and can achieve the same or similar beneficial effects.
[0172] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for fitting circular arcs based on feature points and restoring the outline of an image, characterized in that, include: Based on the feature point information of the acquired target image's outline, each arc segment is identified, and the position information of each arc segment is determined, including information related to the initial point, intermediate point, and termination point. This includes: acquiring the position and category of each feature point contained in the feature point information; the position of the feature point represents the horizontal and vertical coordinates of the pixel; the category of the feature point includes straight line feature points and arc feature points; all feature points are represented in the form of a feature point sequence; straight line feature points are marked as a first value, and arc feature points are marked as a second value; based on the continuous arrangement of the second values and the jump of the marked values of the feature points at both ends, each arc segment is identified; for each identified arc segment, based on the positions of the feature points at both ends, the initial point and termination point of the arc segment are determined, the next feature point of the initial point of the arc segment is taken as the intermediate point, and the relevant information of the initial point, intermediate point, and termination point is determined, including the order in the feature point sequence, the horizontal and vertical coordinates of the feature points, and the category of the feature points. The center and radius of the circle are determined by the initial point, midpoint, and end point of the arc. Using the initial point, midpoint, and center of the arc segment, the fitting direction of the arc segment is determined by the vector cross product; The arc segment is represented parametrically, and the range of the corresponding angle of the arc segment is calculated based on the fitted direction of the arc segment. The arc is fitted based on the center, radius, and corresponding angle range of the arc segment; After each arc segment is fitted, the remaining straight line feature points are connected by straight lines to restore the outline of the target image.
2. The method for fitting circular arcs and restoring image contours based on feature points according to claim 1, characterized in that, The center and radius of the circle are determined by the initial point, midpoint, and end point of the arc, including: Connect the initial point, midpoint, and end point of the arc with straight lines in each pair; Draw the perpendicular bisector of each line; The intersection of the three perpendicular bisectors is defined as the center of the arc segment, and any distance between the center of the arc segment and the corresponding initial point, intermediate point, and termination point is defined as the radius of the arc segment.
3. The method for fitting circular arcs and restoring image contours based on feature points according to claim 1, characterized in that, The step of determining the fitting direction of the arc segment using its initial point, midpoint, and center, based on the vector cross product, includes: Based on the initial point, midpoint, and center of the arc segment, determine the prior vector and subsequent vector of the arc segment; according to the direction from the prior vector to the subsequent vector and the four-finger spiral rule, determine whether the fitting direction of the arc segment is clockwise or counterclockwise.
4. The method for fitting circular arcs and restoring image contours based on feature points according to claim 3, characterized in that, The process involves determining the prior and subsequent vectors of the arc segment based on its initial point, midpoint, and center; and determining the fitting direction of the arc segment as clockwise or counterclockwise based on the direction from the prior vector to the subsequent vector and the four-finger spiral rule, including: The vector from the center of the arc segment to the initial point is defined as the prior vector; The vector from the center of the arc to the midpoint is determined as the subsequent vector; According to the right-hand screw rule, the four fingers turn from the direction of the preceding vector to the direction of the following vector. If the direction of the thumb points inward into the paper, the fitting direction of the arc segment is considered to be clockwise; if the direction of the thumb points outward from the paper, the fitting direction of the arc segment is considered to be counterclockwise.
5. The method for fitting circular arcs and restoring the outline of an image based on feature points according to claim 3 or 4, characterized in that, The parameterization represents the arc segment, and the range of angles corresponding to the arc segment is calculated based on the fitted direction of the arc segment, including: The parametric equation of the circle is determined as follows: in, r Let be the radius of the circle. Let x be the x-coordinate of the center of the circle. Let be the ordinate of the center of the circle. x Let x be the x-coordinate of any point on the circle. y Let be the ordinate of any point on the circle. Let be the phase corresponding to any point on the circle, with a range of . 0 to 2 ; The vector from the center of the arc segment to the initial point is defined as the starting vector, and the vector from the center of the arc segment to the midpoint is defined as the ending vector. Based on the fitting direction of the arc segment, and the phase values of the starting vector and the ending vector, the fitting direction of the arc segment is determined. scope.
6. The method for fitting circular arcs and restoring image contours based on feature points according to claim 5, characterized in that, The fitting direction of the circular arc segment, and the phase values of the starting vector and the ending vector, are used to determine the fitting direction of the circular arc segment. Scope, including: When the phase value of the initial vector Phase value with the endpoint vector When they are equal, the fitted The range is from 0 to When the phase value of the initial vector Phase value with the endpoint vector When they are not equal, classification is performed based on the fitting direction of the arc segment, including: The fitting direction for this arc segment is clockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or both are less than 0: when the phase value of the starting vector... Phase value greater than the endpoint vector , fitted The range is from arrive When the phase value of the initial vector Phase value less than the endpoint vector , fitted The range is from arrive When the phase value of the initial vector The phase value of the endpoint vector is greater than or equal to 0. Less than or equal to 0, the fitted The range is from arrive When the phase value of the initial vector The phase value of the endpoint vector is less than or equal to 0. Greater than or equal to 0, the fitted The range is from arrive ; The fitting direction for this arc segment is counterclockwise: if the phase values of both the starting vector and the ending vector are greater than 0 or both are less than 0: when the phase value of the starting vector... Phase value greater than the endpoint vector , fitted The range is from arrive When the phase value of the initial vector Phase value less than the endpoint vector , fitted The range is from arrive When the phase value of the initial vector The phase value of the endpoint vector is greater than or equal to 0. Less than or equal to 0, the fitted The range is from arrive When the phase value of the initial vector The phase value of the endpoint vector is less than or equal to 0. Greater than or equal to 0, the fitted The range is from arrive .
7. A device for fitting circular arcs based on feature points and restoring the outline of an image, characterized in that, include: The arc segment position information determination module is used to identify each arc segment and determine the position information of each arc segment based on the feature point information of the outer contour of the acquired target image, including the relevant information of the initial point, the middle point and the end point. The module for determining the center and radius of an arc segment is used to determine the center and radius of the corresponding arc segment based on its initial point, midpoint, and end point. The module for determining the fitting direction of an arc segment is used to determine the fitting direction of the arc segment based on the vector cross product using the initial point, midpoint, and center of the arc segment. The arc segment angle range determination module is used to parametrically represent the arc segment and calculate the range of the corresponding angles of the arc segment based on the fitting direction of the arc segment. The arc segment fitting module is used to fit the arc segment based on the center, radius, and corresponding angle range of the arc segment. The image outline restoration module is used to connect the remaining straight line feature points with straight lines after each arc segment has been fitted, so as to restore the outline of the target image. Specifically, the arc segment position information determination module is used for: Obtain the position and category of each feature point contained in the feature point information; wherein, the position of the feature point represents the horizontal and vertical coordinates of the pixel; the category of the feature point includes straight line feature points and circular arc feature points; all feature points are represented in the form of a feature point sequence; Mark the straight line feature points as the first value and the circular arc feature points as the second value; Based on the continuous arrangement of the second value and the jump of the value of the feature point markers at both ends, identify each arc segment; For each identified arc segment, the initial and final points of the arc segment are determined based on the positions of the feature points at both ends. The next feature point after the initial point of the arc segment is taken as the intermediate point. The relevant information of the initial point, intermediate point, and final point is determined, including the order in the feature point sequence, the horizontal and vertical coordinates of the feature points, and the category of the feature points.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes the program stored in the memory, it implements the steps of the method described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-6.