A device, computer equipment and storage medium for fitting curved target contour
By extracting the image feature and predicting the bending target area, combining the smoothing processing of boundary points and curvature screening, the upper and lower contour lines of the bending target are fitted, which solves the problem of inaccurate fitting of the bending target profile in the prior art, and achieves accurate fitting of the bending target profile.
Patent Information
- Application Number
- CN202111482789.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-12-07
AI Technical Summary
The connectivity domain diagram of the target obtained by the existing segmented network cannot accurately express the outline of the curved target.
By inputting the picture into the segmentation network for feature extraction and bending target area prediction, a connecting domain diagram is obtained; the boundary points in the connecting domain diagram are found and the boundary polygons are obtained; the boundary polygons are smoothed, the curvature of the contour points is filtered, the upper and lower boundary points are classified, and the upper and lower contour lines of the bend target are fitted.
The accurate fit of the curved target profile in the picture is achieved, laying the foundation for subsequent correction.
Smart Images

Figure CN114170257B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a device, a computer equipment and a storage medium for fitting a curved target contour. Background Art
[0002] Image segmentation is an important technology in computer vision tasks. In the process of segmentation, the segmentation network obtains the largest connected domain of the target. For relatively regular targets, their contours can be fitted through some related algorithms; however, for curved targets in the image (such as curved documents, curved lane lines, etc.), the connected domain cannot accurately express the contour of the curved target. Summary of the invention
[0003] The purpose of the present invention is to provide a method, device, computer equipment and storage medium for fitting the contour of a curved target, aiming to solve the problem that the connected domain graph of the target obtained by the existing segmentation network cannot accurately express the contour of the curved target.
[0004] In order to solve the above technical problems, the object of the present invention is achieved through the following technical solutions: a method for fitting a curved target contour is provided, comprising:
[0005] The image is input into the segmentation network for feature extraction, and then the curved target area is predicted to obtain a connected domain map;
[0006] Finding boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points;
[0007] Smoothing the boundary polygon to obtain a contour point-line diagram of the curved target;
[0008] According to the curvature of the contour points in the contour point line graph, a left endpoint set and a right endpoint set of the contour point line graph are screened out, and the contour points in the contour point line graph are classified into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set;
[0009] A plurality of control points are selected from the upper boundary points, and a plurality of control points are selected from the lower boundary points, and an upper contour line and a lower contour line of the curved object are respectively fitted according to the corresponding plurality of control points.
[0010] In addition, the technical problem to be solved by the present invention is to provide a device for fitting a curved target contour, which is characterized by comprising:
[0011] A preprocessing unit is used to input the image into the segmentation network for feature extraction, and then predict the curved target area to obtain a connected domain map;
[0012] A search unit, used for searching the boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points;
[0013] A smoothing processing unit, used for performing smoothing processing on the boundary polygon to obtain a contour point-line diagram of the curved target;
[0014] a classification unit, configured to screen out a left endpoint set and a right endpoint set of the contour point line graph according to the curvature of the contour points in the contour point line graph, and classify the contour points in the contour point line graph into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set;
[0015] The fitting unit is used to select multiple control points from the upper boundary points and select multiple control points from the lower boundary points, and respectively fit the upper contour line and the lower contour line of the curved object according to the corresponding multiple control points.
[0016] In addition, an embodiment of the present invention provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for fitting the curved target contour described in the first aspect above is implemented.
[0017] In addition, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method for fitting a curved target contour as described in the first aspect above.
[0018] The embodiment of the present invention discloses a method, device, computer equipment and storage medium for fitting the contour of a curved target. The method inputs a picture into a segmentation network for feature extraction, and then predicts the curved target area to obtain a connected domain map; finds boundary points in the connected domain map and obtains boundary polygons based on the boundary points; smoothes the boundary polygons to obtain a contour point-line map of the curved target; selects a left endpoint set and a right endpoint set of the contour point-line map according to the curvature of the contour points in the contour point-line map, and uses the left endpoint set and the right endpoint set to classify the contour points in the contour point-line map into upper boundary points and lower boundary points; selects multiple control points from the upper boundary points, and selects multiple control points from the lower boundary points, and respectively fits the upper contour line and the lower contour line of the curved target according to the corresponding multiple control points. The method provided by the embodiment of the present invention can accurately fit the contour of the curved target in the picture, laying a foundation for subsequent correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0020] Figure 1 A schematic flow chart of a method for fitting a curved target contour provided by an embodiment of the present invention;
[0021] Figure 2 A schematic diagram of a sub-process of a method for fitting a curved target contour provided by an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of another sub-process of the method for fitting a curved target contour provided by an embodiment of the present invention;
[0023] Figure 4 A schematic diagram of another sub-process of the method for fitting a curved target contour provided by an embodiment of the present invention;
[0024] Figure 5 A schematic diagram of dividing a contour point-line graph into upper and lower boundaries provided by an embodiment of the present invention;
[0025] Figure 6 A schematic diagram of fitting a curved target contour provided by an embodiment of the present invention;
[0026] Figure 7 A schematic block diagram of a device for fitting a curved target contour provided by an embodiment of the present invention;
[0027] Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0030] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0031] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0032] See also Figure 1 , Figure 1 A schematic flow chart of a method for fitting a curved target contour provided by an embodiment of the present invention;
[0033] like Figure 1 As shown, the method includes steps S101 to S105.
[0034] S101, input the image into the segmentation network for feature extraction, and then predict the curved target area to obtain a connected domain map;
[0035] In this step, the input image refers to an image in which the target is bent due to shooting angle or page distortion. The bent target here can be a bent document or a bent lane line, etc. The image is input into the segmentation network, and features of the image are first extracted through a convolutional neural network. Then, the mask branch prediction model in the segmentation network is used to predict the bent target area to obtain a connected domain map of the bent target area.
[0036] S102, searching for boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points;
[0037] This step solves a boundary polygon similar to the connected domain contour based on the connected domain graph, so as to perform subsequent polyline fitting processing.
[0038] S103, smoothing the boundary polygon to obtain a contour point-line diagram of the curved target;
[0039] This step performs polyline fitting, during which the boundary polygon is smoothed to reduce the number of discrete points on the contour, and the resulting contour point-line diagram is closer to the shape of the actual curved target.
[0040] S104, screening out a left endpoint set and a right endpoint set of the contour point line graph according to the curvature of the contour points in the contour point line graph, and classifying the contour points in the contour point line graph into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set;
[0041] S105 , selecting multiple control points from the upper boundary points and selecting multiple control points from the lower boundary points, and fitting the upper contour line and the lower contour line of the curved object according to the corresponding multiple control points.
[0042] In steps S104-S105, an algorithm for fitting broken lines is first proposed, which can not only reduce the number of discrete points on the contour, but also realize smoothing of boundary polygons in the process, and classify the contour points in the contour point-line diagram into upper boundary points and lower boundary points; then the control points are screened by the least squares method, and finally the contour of the curved target is accurately fitted by the control points through the Bezier curve, which lays the foundation for subsequent correction.
[0043] In one embodiment, if Figure 2 As shown, step S102 includes:
[0044] S201, selecting a pixel point with a color pixel value greater than 1 in the connected domain graph as a boundary starting point;
[0045] In the connected domain map, the size of the color pixel value of a pixel point can represent the probability that the pixel point is in the target area. The larger the color pixel value, the more likely it is that the pixel point is a boundary point on the boundary line of the target area. Therefore, this embodiment takes the color pixel value 1 as the benchmark and takes the pixel points with color pixel values greater than 1 as boundary points. In the connected domain map, any pixel point with a color pixel value greater than 1 can be selected as the boundary starting point. Here, relatively scattered pixel points with color pixel values greater than 1 can also be screened as the boundary starting points, so that it is easier to expand to the surroundings when starting to search.
[0046] S202, finding a pixel point with a color pixel value greater than 1 around the boundary starting point as the next boundary point;
[0047] S203, determine the parent-child relationship between the boundary starting point and the next boundary point, if the next boundary point is the parent boundary point of the boundary starting point, proceed to step S204, if the next boundary point is the child boundary point of the boundary starting point, jump to step S205;
[0048] In this step, taking the boundary starting point as a reference, if the next boundary point is located inside relative to the boundary starting point, the next boundary point is determined to be the parent boundary point of the boundary starting point; if the next boundary point is located outside relative to the boundary starting point, the next boundary point is determined to be the child boundary point of the boundary starting point.
[0049] S204, using the next boundary point as a new boundary starting point to search for the next pixel point whose color pixel value is greater than 1 in a counterclockwise direction;
[0050] S205, using the next boundary point as a new boundary starting point and searching in a clockwise direction for the next pixel point whose color pixel value is greater than 1;
[0051] S205: When all pixel points are found and the initial boundary starting point is returned, the search is completed, and the found boundary points are connected to obtain a boundary polygon.
[0052] In steps S203-S205, the iterative search is continuously performed based on the parent-child relationship between the boundary starting point and the next boundary point. The search process is basically to gradually complete the search in a closed loop path around the boundary of the connected domain graph. When the search finally returns to the initial boundary starting point, the search is completed. Finally, the found boundary points are connected to obtain a boundary polygon similar to the connected domain graph.
[0053] In one embodiment, if Figure 3 As shown, step S103 includes:
[0054] S301, dividing the boundary polygon into a plurality of boundary polylines;
[0055] In this step, the segmentation method may be segmentation according to the number of boundary points or segmentation according to the boundary path length, thereby obtaining a plurality of boundary polylines.
[0056] S302, the process of performing smoothing processing on each boundary polyline:
[0057] Connect the first and last points on the boundary polyline to get a straight line;
[0058] Calculate the maximum distance from other boundary points on the boundary polyline to the straight line;
[0059] Determine whether the farthest distance is less than a preset distance value, if so, smooth the boundary polyline, if not, split the boundary polygon into multiple sub-polylines, and then perform smoothing on each sub-polyline;
[0060] In this step, the first endpoint and the end point on the boundary polyline are first connected to obtain the straight line L, and then the boundary point C on the boundary polyline that is farthest from the straight line L is calculated, and the farthest distance is set to d; the farthest distance d is compared with the preset distance value. When the farthest distance d is less than the preset distance value, the boundary polyline is directly smoothed and the smoothed boundary point is returned. In this process, the number of boundary points on the boundary polyline is compressed; when the farthest distance d is greater than or equal to the preset distance value, the boundary polyline is split with the middle boundary point as the breakpoint to obtain two sub-polylines; then the first endpoint and the end point of each sub-polyline are connected to obtain the corresponding straight line L; and then the smoothing process is performed for each sub-polyline until all boundary polylines are finally smoothed.
[0061] S303: Connect all smoothed boundary polylines to obtain a contour point-line diagram of the curved object.
[0062] This embodiment proposes a polyline fitting algorithm, which can not only reduce the number of discrete points on the contour, but also achieve smoothing of the boundary polygons in the process, thereby obtaining a contour point-line diagram that is more similar to the curved target shape.
[0063] In one embodiment, if Figure 4 As shown, step S104 includes:
[0064] S401, sorting the contour points in the contour point line graph clockwise;
[0065] S402, finding two point sets whose curvatures are greater than the predicted curvature value from all contour points, and taking the point set at the left end of the contour point line graph as the left endpoint set, and taking the point set at the right end of the contour point line graph as the right endpoint set;
[0066] S403, taking the maximum ordinate and the minimum ordinate in the left endpoint set as the starting points of the upper boundary point and the lower boundary point respectively;
[0067] S404: Use the maximum ordinate and the minimum ordinate in the right endpoint set as the lower boundary point and the end point of the lower boundary point respectively.
[0068] In this embodiment, the reference Figure 5 As shown in the figure, it can be seen that the positions with the largest curvature are the left and right ends, and the curvatures at the left and right ends are much larger than the curvatures at other positions. Therefore, it is very convenient to set the predicted curvature value to filter out the points at these two positions, and use them as the left endpoint set of the left end position of the contour point graph and the right endpoint set of the right end position. The contour point sets selected by the two ends of the reference figure are the left endpoint set and the right endpoint set.
[0069] By taking the maximum ordinate in the left endpoint set as the starting point of the upper boundary point, and taking the maximum ordinate in the right endpoint set as the end point of the upper boundary point, a curved contour point line can be obtained in sequence (i.e., from left to right in the figure), and all contour points in this contour point line are upper boundary points. It can be understood that by taking the minimum ordinate in the left endpoint set as the starting point of the lower boundary point, and taking the minimum ordinate in the right endpoint set as the end point of the lower boundary point, another curved contour point line can be obtained in sequence (i.e., from left to right in the figure), and all contour points in this contour point line are lower boundary points.
[0070] The following describes the process of selecting multiple control points from the upper boundary points and selecting multiple control points from the lower boundary points in step S105, including:
[0071] Input all upper boundary points or lower boundary points into the following formula and output the corresponding multiple control points:
[0072]
[0073] Among them, the Bernstein basis polynomial is used i=0,1,2,3,4 Expand and get the above matrix n represents the order, p represents the upper boundary point or the lower boundary point, m represents the number of upper boundary points or the lower boundary points, and b represents the control point.
[0074] In this embodiment, taking the input of the upper boundary point as an example, the coordinates of all the upper boundary points are substituted into the above formula for calculation, and 5 control points can be output.
[0075] The following describes step S105, in which the upper contour line and the lower contour line of the curved object are fitted according to the corresponding multiple control points, including:
[0076] Input multiple control points into the following formula to calculate and obtain the curve polar coordinates of the upper contour line and the lower contour line:
[0077] T(t)=(1-t) 4 b0+4(1-t) 3 tb1+6(1-t) 2 t 2 b2+4(1-t)t 3 b3+t 4 b4;
[0078] Where T(t) represents the point on the curve at time t, n represents the order, and b i represents the i-th control point;
[0079] In this embodiment, the five control points outputted above are substituted into the above formula for calculation, and the fourth-order Bezier curve algorithm is used to finally obtain the upper contour line represented by the polar coordinates of the curve. It can be understood that the lower contour line represented by the polar coordinates of the curve can be calculated and obtained by the same method. The specific fitting effect is as follows: Figure 6 shown.
[0080] The embodiment of the present invention further provides a device for fitting a curved target contour, and the device for fitting a curved target contour is used to execute any embodiment of the method for fitting a curved target contour. Figure 7 , Figure 7 It is a schematic block diagram of a device for fitting a curved target contour provided by an embodiment of the present invention.
[0081] like Figure 7 As shown, the device 700 for fitting a curved target contour includes: a preprocessing unit 701 , a searching unit 702 , a smoothing processing unit 703 , a classification unit 704 and a fitting unit 705 .
[0082] A preprocessing unit 701 is used to input the image into a segmentation network for feature extraction, and then predict the curved target area to obtain a connected domain graph;
[0083] A search unit 702, used to search for boundary points in the connected domain graph and obtain boundary polygons according to the boundary points;
[0084] A smoothing processing unit 703 is used to perform smoothing processing on the boundary polygon to obtain a contour point-line diagram of the curved target;
[0085] A classification unit 704 is used to screen out a left endpoint set and a right endpoint set of the contour point line graph according to the curvature of the contour points in the contour point line graph, and classify the contour points in the contour point line graph into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set;
[0086] The fitting unit 705 is used to select multiple control points from the upper boundary points and select multiple control points from the lower boundary points, and respectively fit the upper contour line and the lower contour line of the curved object according to the corresponding multiple control points.
[0087] The device first solves a boundary polygon similar to the connected domain contour based on the connected domain graph obtained by segmentation, and then proposes an algorithm for fitting broken lines. This algorithm can not only reduce the number of discrete points on the contour, but also smooth the boundary polygon in the process. Finally, the contour of the curved target is accurately fitted by using the standard least squares method and the fourth-order Bezier curve, laying the foundation for subsequent correction.
[0088] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0089] The above-mentioned device for fitting the curved target contour can be implemented in the form of a computer program, which can be used in Figure 8 Runs on the computer device shown.
[0090] See also Figure 8 , Figure 8 800 is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 800 is a server, which can be an independent server or a server cluster composed of multiple servers.
[0091] See also Figure 8 The computer device 800 includes a processor 802 , a memory and a network interface 805 connected via a system bus 801 , wherein the memory may include a non-volatile storage medium 803 and an internal memory 804 .
[0092] The non-volatile storage medium 803 may store an operating system 8031 and a computer program 8032. When the computer program 8032 is executed, the processor 802 may execute a method for fitting a curved target contour.
[0093] The processor 802 is used to provide computing and control capabilities and support the operation of the entire computer device 800.
[0094] The internal memory 804 provides an environment for the operation of the computer program 8032 in the non-volatile storage medium 803. When the computer program 8032 is executed by the processor 802, the processor 802 can execute a method for fitting a curved target contour.
[0095] The network interface 805 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 800 to which the solution of the present invention is applied. The specific computer device 800 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0096] Those skilled in the art will understand that Figure 8 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Figure 8 The embodiments shown are consistent and will not be described again here.
[0097] It should be understood that in the embodiment of the present invention, the processor 802 may be a central processing unit (CPU), and the processor 802 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0098] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the method for fitting a curved target profile according to an embodiment of the present invention is implemented.
[0099] The storage medium is a physical, non-transient storage medium, for example, it can be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, etc., which can store program codes.
[0100] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0101] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for fitting a curved target contour, characterized in that: include: The image is input into the segmentation network for feature extraction, and then the curved target area is predicted to obtain a connected domain map; Finding boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points; Smoothing the boundary polygon to obtain a contour point-line diagram of the curved target; According to the curvature of the contour points in the contour point line graph, a left endpoint set and a right endpoint set of the contour point line graph are screened out, and the contour points in the contour point line graph are classified into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set; Filtering a plurality of control points from the upper boundary points, and filtering a plurality of control points from the lower boundary points, and fitting an upper contour line and a lower contour line of the curved target respectively according to the corresponding plurality of control points; The step of selecting a plurality of control points from the upper boundary points and selecting a plurality of control points from the lower boundary points comprises: Input all upper boundary points or lower boundary points into the following formula and output the corresponding multiple control points: ; Among them, the Bernstein basis polynomial is used Expand to get the above matrix ; n represents the order, p represents the upper boundary point or the lower boundary point, m represents the number of upper boundary points or the lower boundary points, and b represents the control point.
2. The method for fitting a curved target contour according to claim 1, characterized in that: The step of searching for boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points includes: Selecting a pixel point whose color pixel value is greater than 1 in the connected domain graph as a boundary starting point; Finding a pixel point with a next color pixel value greater than 1 around the boundary starting point as the next boundary point, and determining the parent-child relationship between the boundary starting point and the next boundary point; If the next boundary point is the parent boundary point of the boundary starting point, then the next boundary point is used as the new boundary starting point to search for the next pixel point whose color pixel value is greater than 1 in the counterclockwise direction; wherein, taking the boundary starting point as the reference, if the next boundary point is located inside relative to the boundary starting point, then the next boundary point is determined to be the parent boundary point of the boundary starting point; If the next boundary point is a sub-boundary point of the boundary starting point, then the next boundary point is used as a new boundary starting point to search for the next pixel point whose color pixel value is greater than 1 in a clockwise direction; wherein, taking the boundary starting point as a reference, if the next boundary point is outside relative to the boundary starting point, then the next boundary point is determined to be a sub-boundary point of the boundary starting point; When all pixels are found and the initial boundary starting point is returned, the search is completed, and the found boundary points are connected to obtain the boundary polygon.
3. The method for fitting a curved target contour according to claim 2, characterized in that: The determining the parent-child relationship between the boundary starting point and the next boundary point includes: Taking the boundary starting point as a reference, if the next boundary point is located inside relative to the boundary starting point, the next boundary point is determined to be the parent boundary point of the boundary starting point; if the next boundary point is located outside relative to the boundary starting point, the next boundary point is determined to be the child boundary point of the boundary starting point.
4. The method for fitting a curved target contour according to claim 1, characterized in that: The step of smoothing the boundary polygon to obtain a contour point-line diagram of the curved target includes: Splitting the boundary polygon into a plurality of boundary polylines; The process of smoothing each boundary polyline is as follows: Connecting the first and last points on the boundary polyline to obtain a straight line; Calculate the maximum distance from other boundary points on the boundary polyline to the straight line; Determine whether the farthest distance is less than a preset distance value, if so, smooth the boundary polyline, if not, split the boundary polygon into multiple sub-polylines, and then perform smoothing on each sub-polyline; Connect all smoothed boundary polylines to obtain the contour point-line diagram of the curved target.
5. The method for fitting a curved target contour according to claim 1, characterized in that: The step of screening out a left endpoint set and a right endpoint set of the contour point line graph according to the curvature of the contour points in the contour point line graph, and classifying the contour points in the contour point line graph into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set comprises: Sort the contour points in the contour point line graph clockwise; Find two point sets whose curvature is greater than the predicted curvature value from all contour points, and use the point set at the left end of the contour point line graph as the left endpoint set, and use the point set at the right end of the contour point line graph as the right endpoint set; The maximum ordinate and the minimum ordinate in the left endpoint set are used as the starting points of the upper boundary point and the lower boundary point respectively; The maximum ordinate and the minimum ordinate in the right endpoint set are respectively used as the termination points of the upper boundary point and the lower boundary point.
6. The method for fitting a curved target contour according to claim 1, characterized in that: The step of fitting the upper contour line and the lower contour line of the curved object according to the corresponding multiple control points comprises: Input multiple control points into the following formula to calculate and obtain the curve polar coordinates of the upper contour line and the lower contour line: ; in, represents the point on the curve at time t, n represents the order, b i represents the i-th control point.
7. A device for fitting a curved target contour, characterized in that: include: A preprocessing unit is used to input the image into the segmentation network for feature extraction, and then predict the curved target area to obtain a connected domain map; A search unit, used for searching the boundary points in the connected domain graph and obtaining boundary polygons according to the boundary points; A smoothing processing unit, used for performing smoothing processing on the boundary polygon to obtain a contour point-line diagram of the curved target; a classification unit, configured to screen out a left endpoint set and a right endpoint set of the contour point line graph according to the curvature of the contour points in the contour point line graph, and classify the contour points in the contour point line graph into upper boundary points and lower boundary points by using the left endpoint set and the right endpoint set; A fitting unit, used to select multiple control points from the upper boundary points, and select multiple control points from the lower boundary points, and respectively fit the upper contour line and the lower contour line of the curved target according to the corresponding multiple control points The step of selecting a plurality of control points from the upper boundary points and selecting a plurality of control points from the lower boundary points comprises: Input all upper boundary points or lower boundary points into the following formula and output the corresponding multiple control points: ; Among them, the Bernstein basis polynomial is used Expand to get the above matrix ; n represents the order, p represents the upper boundary point or the lower boundary point, m represents the number of upper boundary points or the lower boundary points, and b represents the control point.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for fitting a curved target contour according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the method for fitting a curved target contour according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image vectorization method based on sub-pixels
CN110049340A
Contour extraction method and device, electronic equipment and storage medium
CN112183541A