Image contour generation method, device and electronic device

By identifying and smoothing the sharp corners in the image profile of the cutter cutting flexible material and using insertion arcs instead of sharp corners, the cutting bed cutting quality and efficiency problems are solved, achieving a more efficient cutting process.

CN114170261BActive Publication Date: 2025-07-22HANGZHOU IECHO SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111257336.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-27
Publication Date
2025-07-22
Estimated Expiration
2041-10-27

AI Technical Summary

Technical Problem

In the prior art, when cutting flexible materials on the cutting bed, especially leather, there are problems of low cutting quality and low efficiency, especially due to the sharp corners of the contour, the tool is frequently lifted and dropped, which affects the cutting efficiency.

Method used

By extracting the initial contour of the image to be cropped, identifying and smoothing the sharp corners, using an insertion arc instead of the sharp corners, a smooth material contour is generated to prevent the tool from lifting and falling at the sharp corners.

Benefits of technology

It improves the cutting quality and cutting efficiency of the cutting bed, reduces the number of times the tool is lifted and dropped, and improves product quality and production efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114170261B_ABST
    Figure CN114170261B_ABST
Patent Text Reader

Abstract

The present application discloses an image contour generation method, apparatus and electronic device. Among them, the method includes extracting an initial contour of the image to be cut, and determining the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour. For the target local contour in the initial contour that meets the sharp corner smoothing condition, the concavity and convexity of the target local contour are determined according to the contour direction and the pixel coordinates of each pixel point of the target local contour. The center and radius of the circle where the inserted arc is located are determined according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation and the starting point of the inserted arc; based on the contour direction and the concavity and convexity of the target local contour, the inserted arc of the target local contour is generated according to the insertion point information, the starting point, the center and the circle equation; the inserted arc of each target local contour is used to replace the corresponding target local contour to generate the final leather material contour image for the cutting machine to cut, which can effectively improve the cutting quality and cutting efficiency of the cutting machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image processing, and particularly to an image contour generation method, apparatus, and electronic device. Background Art

[0002] With the rapid development of automation technology and intelligent technology, intelligent devices are applied in various industries. As an intelligent device for batch production and processing of flexible materials in industries such as textile and clothing, automotive interior decoration, etc., in order to meet the actual needs of users for high utilization rate, high-quality processing, and efficient processing of fabrics, the automatic cutting technology for fabrics has also developed rapidly.

[0003] When using a cutting machine such as a multi-layer cutting machine to cut and process fabrics, a cutting trajectory will be generated in the fabric image based on the shape and size of each cutting piece first, or directly use the contour of a certain area of the fabric as the cutting trajectory, and then cut the fabric according to the cutting trajectory. For some flexible materials with a certain thickness such as leather, a circular cutter is often used for cutting. Since the tool needs to be lifted and lowered at the sharp corners of the contour, sometimes the leather will be lifted up, which will not only affect the cutting quality but also reduce the cutting efficiency.

[0004] In view of this, how to improve the cutting quality and cutting efficiency of this kind of material is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The present application provides an image contour generation method, apparatus, and electronic device, which can effectively improve the cutting quality and cutting efficiency of a cutting machine.

[0006] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:

[0007] On the one hand, an embodiment of the present invention provides an image contour generation method, including:

[0008] Extracting an initial contour of an image to be cut, and determining the contour trend according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour;

[0009] For each local contour in the initial contour, if there is a target local contour that satisfies the sharp corner smoothing condition, determining the concavity and convexity of the target local contour according to the contour trend and the pixel coordinates of each pixel point of the target local contour;

[0010] Determining the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation of the circle and the starting point of the inserted arc;

[0011] Generate an insertion arc for the target local contour based on the contour trend and the concavity and convexity of the target local contour, according to the insertion point information, the starting point, the center of the circle, and the circle equation.

[0012] Generate a contour image of the image to be cropped by replacing each target local contour with the insertion arc of the corresponding target local contour.

[0013] Optionally, before extracting the initial contour of the image to be cropped, it further includes:

[0014] Perform image preprocessing on the multi-channel original image to obtain multiple single-channel images.

[0015] Perform threshold segmentation on each single-channel image, and determine a target image that meets the image quality conditions based on the threshold segmentation result.

[0016] Perform binary threshold segmentation on the target image to obtain a binary image.

[0017] Filter out regions in the binary image that are smaller than a preset area threshold to obtain the image to be cropped.

[0018] Optionally, before determining if there is a target local contour that meets the sharp corner smoothing condition, it further includes:

[0019] Divide the initial contour into multiple connected local contours.

[0020] For each local contour, obtain the pixel coordinates of three adjacent pixel points of the current local contour, and calculate the angle between the first line segment formed by the first pixel point and the second pixel point and the second line segment formed by the second pixel point and the third pixel point; if the angle is greater than or equal to a preset angle threshold, determine that the current local contour does not meet the sharp corner smoothing condition; if the angle is less than the preset angle threshold, determine that the current local contour meets the sharp corner smoothing condition.

[0021] Optionally, the determining the contour trend according to the numerical relationship between the pixel coordinates of the pixel points of the initial contour includes:

[0022] Traverse all pixel points of the initial contour to determine a target pixel point with the smallest coordinate value on the X coordinate axis among all pixel points.

[0023] If the coordinate value of the target pixel point on the Y coordinate axis is greater than or equal to the coordinate value of the previous pixel point of the target pixel point on the Y coordinate axis, and the coordinate value of the target pixel point on the Y coordinate axis is less than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, then the contour trend of the initial contour is clockwise.

[0024] Optionally, determining the contour direction based on the numerical relationship between the pixel coordinates of each pixel point of the initial contour includes:

[0025] Traverse all pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X axis among all pixel points;

[0026] Obtain the pixel coordinates of the previous pixel point and the next pixel point of the target pixel point;

[0027] If the cross product of the first vector and the second vector is less than 0, the contour direction of the initial contour is clockwise; if the cross product of the first vector and the second vector is greater than 0, the contour direction of the initial contour is counterclockwise; the first vector is formed by the target pixel point and the previous pixel point, and the second vector is formed by the target pixel point and the next pixel point.

[0028] Optionally, determining the concavity and convexity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour includes:

[0029] For each local contour, obtain the coordinates of three adjacent pixel points of the current local contour. The starting pixel point coordinates and the middle pixel point coordinates form a first pointing vector, and the middle pixel point coordinates and the end pixel point coordinates form a second pointing vector;

[0030] When the contour direction is clockwise, if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is convex; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is concave;

[0031] When the contour direction is counterclockwise: if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is concave; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is convex.

[0032] Optionally, determining the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour to determine the circle equation of the circle and the starting point of the inserted arc includes:

[0033] Obtain adjacent first target pixel point, second target pixel point and third target pixel point on the target local contour and their respective pixel coordinates; the first target pixel point and the second target pixel point form a first target line segment, and the second target pixel point and the third target pixel point form a second target line segment;

[0034] If the length of the first target line segment is greater than or equal to the length of the second target line segment, calculate the radius of the circle where the insertion arc is located according to the included angle between the first target line segment and the second target line segment and the length of the second target line segment; if the length of the first target line segment is less than the length of the second target line segment, calculate the radius of the circle where the insertion arc is located according to the included angle between the first target line segment and the second target line segment and the length of the first target line segment; at the same time, calculate the center coordinates and radius of the inserted maximum arc.

[0035] Calculate the center coordinates of the circle where the insertion arc is located according to the principle of similar triangles, and determine the circle equation according to the center coordinates and the radius of the circle where the insertion arc is located.

[0036] Along the contour direction, take the point where the inferior arc corresponding to the central angle of the circle where the insertion arc is located is first tangent to the first target line segment or the second target line segment as the starting point of the insertion arc.

[0037] Optionally, the process of calculating the radius of the circle where the insertion arc is located according to the included angle between the first target line segment and the second target line segment and the length of the second target line segment if the length of the first target line segment is greater than or equal to the length of the second target line segment, or calculating the radius of the circle where the insertion arc is located according to the included angle between the first target line segment and the second target line segment and the length of the first target line segment if the length of the first target line segment is less than the length of the second target line segment, and at the same time calculating the center coordinates and radius of the inserted maximum arc includes:

[0038] Call the radius calculation relational expression to calculate the radius of the circle where the insertion arc is located, and the radius calculation relational expression is:

[0039]

[0040] In the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circleRadius is the radius of the circle where the insertion arc is located, θ is the included angle between the first target line segment and the second target line segment, and n is a constant.

[0041] Optionally, the process of generating the insertion arc of the target local contour according to the insertion point information, the starting point, the center and the circle equation based on the contour direction and the concavity and convexity of the target local contour includes:

[0042] Determine the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle.

[0043] Rotate the starting line segment determined by the center and starting point of the inserted arc around the center of the circle where the inserted arc is located, along the contour direction, by the rotation angle, to obtain a plurality of rotated line segments;

[0044] For each rotated line segment, based on the pixel point at the middle position on the target contour, determine the insertion point from the intersection points of the rotated line segment and the circle where the inserted arc is located;

[0045] Generate the inserted arc of the target local contour according to each insertion point and the concavity and convexity of the target local contour.

[0046] Another aspect of the embodiments of the present invention provides an image contour generation device, including:

[0047] An initial contour extraction module, configured to extract the initial contour of the image to be cropped;

[0048] A contour direction determination module, configured to determine the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour;

[0049] A concavity and convexity determination module, for each local contour in the initial contour, if there is a target local contour that satisfies the sharp corner smoothing condition, determine the concavity and convexity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour;

[0050] An inserted arc parameter calculation module, configured to determine the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation of the circle and the starting point of the inserted arc;

[0051] An inserted arc generation module, configured to generate the inserted arc of the target local contour based on the contour direction and the concavity and convexity of the target local contour, according to the insertion point information, the starting point, the center of the circle, and the circle equation;

[0052] A contour generation module, configured to use the inserted arc of each target local contour to replace the corresponding target local contour, and generate the contour image of the leather material to be processed.

[0053] The embodiments of the present invention further provide an electronic device, including a processor, and the processor is configured to implement the steps of the image contour generation method as described in any one of the previous items when executing the computer program stored in the memory.

[0054] Finally, the embodiments of the present invention also provide a readable storage medium, on which a computer program is stored, and the computer program is configured to implement the steps of the image contour generation method as described in any one of the previous items when executed by a processor.

[0055] The advantages of the technical solution provided by this application are as follows: For materials that need to be cut using a cutting bed, first identify whether there are sharp corners in the material contour image. If there are sharp corners, use an arc to replace the sharp corner, making the entire material contour smoother. This can avoid the phenomenon of the tool being lifted and lowered at the contour sharp corners, effectively reducing the number of times the tool is lifted and lowered, improving the cutting quality and efficiency of the cutting bed, and thus improving the product quality and the overall production efficiency.

[0056] In addition, the embodiments of the present invention also provide corresponding implementation devices, electronic devices, and readable storage media for the image contour generation method, further making the method more practical, and the devices, electronic devices, and readable storage media have corresponding advantages.

[0057] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] To more clearly illustrate the technical solutions of the embodiments of the present invention or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0059] Figure 1 Schematic flowchart of an image contour generation method provided by an embodiment of the present invention;

[0060] Figure 2 Schematic diagram of the original image of the leather material to be cut in the exemplary example provided by an embodiment of the present invention;

[0061] Figure 3 For the present invention, the first schematic single-channel image obtained after processing Figure 2 is shown in the schematic diagram;

[0062] Figure 4 For the present invention, the second schematic single-channel image obtained after processing Figure 2 is shown in the schematic diagram;

[0063] Figure 5 For the present invention, the third schematic single-channel image obtained after processing Figure 2 is shown in the schematic diagram;

[0064] Figure 6 For the present invention, the fourth schematic single-channel image obtained after processing Figure 2 is shown in the schematic diagram;

[0065] Figure 7 The fifth schematic single-channel image obtained after processing Figure 2 in the embodiments of the present invention;

[0066] Figure 8 The schematic diagram of the target image obtained after processing Figure 2 in the embodiments of the present invention;

[0067] Figure 9 The schematic diagram of the binary image obtained after processing Figure 8 in the embodiments of the present invention;

[0068] Figure 10 The schematic diagram of the image obtained after region filtering processing Figure 9 in the embodiments of the present invention;

[0069] Figure 11 The schematic diagram of the initial contour image obtained after contour extraction processing Figure 10 in the embodiments of the present invention;

[0070] Figure 12 The schematic diagram of the initial contour image obtained after contour extraction processing Figure 10 in the embodiments of the present invention;

[0071] Figure 13 The partial enlarged schematic diagram of the A sharp corner of Figure 11 in the embodiments of the present invention;

[0072] Figure 14 The partial enlarged schematic diagram of the B intersection angle of Figure 12 in the embodiments of the present invention;

[0073] Figure 15 The schematic diagram of the initial contour with a clockwise direction in the embodiments of the present invention;

[0074] Figure 16 The schematic diagram of the initial contour with a counterclockwise direction in the embodiments of the present invention;

[0075] Figure 17 The schematic diagram for determining the inserted arc parameters in a schematic example with a clockwise direction in the embodiments of the present invention;

[0076] Figure 18 The schematic diagram for determining the inserted arc parameters in another schematic example with a clockwise direction in the embodiments of the present invention;

[0077] Figure 19 The schematic diagram for determining the inserted arc parameters in a schematic example with a counterclockwise direction in the embodiments of the present invention;

[0078] Figure 20 Schematic diagram for determining the parameters of the insertion arc in another illustrative example with a counterclockwise downward direction provided by an embodiment of the present invention;

[0079] Figure 21 Schematic diagram for determining the insertion point of the insertion arc provided by an embodiment of the present invention;

[0080] Figure 22 Provided by an embodiment of the present invention Figure 11 Schematic diagram of the image obtained after smoothing the sharp corner at point A of

[0081] Figure 23 Provided by an embodiment of the present invention Figure 12 Schematic diagram of the image obtained after smoothing the sharp corner at point B of

[0082] Figure 24 Provided by an embodiment of the present invention for Figure 22 Partial enlarged schematic diagram of point A of

[0083] Figure 25 Provided by an embodiment of the present invention for Figure 23 Partial enlarged schematic diagram of point B of

[0084] Figure 26 Structural diagram of a specific implementation manner of an image contour generation device provided by an embodiment of the present invention;

[0085] Figure 27 Structural diagram of a specific implementation manner of an electronic device provided by an embodiment of the present invention. Specific implementation manner

[0086] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0087] The terms "first", "second", "third", "fourth", etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.

[0088] After introducing the technical solutions of the embodiments of the present invention, various non-limiting implementation manners of the present application will be described in detail below.

[0089] First, refer to Figure 1 , Figure 1 which is a schematic flowchart of an image contour generation method provided by an embodiment of the present invention. The embodiments of the present invention may include the following content:

[0090] S101: Extract the initial contour of the image to be cut, and determine the contour direction according to the numerical relationship between the pixel coordinates of each pixel point on the initial contour.

[0091] The image to be cut in this step refers to the image of the material that needs to be cut by the circular cutter of the cutting machine. The material is flexible and needs to have a certain thickness, such as leather. The initial contour is the contour information of the material that needs to be cut extracted from the image to be cut. Any contour extraction method can be used to extract the contour image, which does not affect the implementation of the present application. The pixel points in this step refer to the pixel points on the initial contour, and the numerical relationship between the pixel point coordinates refers to the comparison of the coordinate values of each pixel point on the same coordinate axis. The contour direction refers to whether the entire initial contour is in a clockwise or counterclockwise direction.

[0092] S102: For each local contour in the initial contour, for the target local contour that meets the sharp corner smoothing condition, determine the concavity and convexity of the target local contour according to the contour direction and the pixel coordinates of each pixel point on the target local contour.

[0093] Since it is necessary to smooth the sharp corners of the initial contour, it is necessary to determine whether there are sharp corners in the initial contour, that is, whether there are sharp corners in a certain part of the initial contour. In order to find each sharp corner in the initial contour, this step can divide the initial contour into multiple local contours. To improve the accuracy, a starting point can be determined in the initial contour. Starting from the starting point, every three pixel points form a local contour, and then it is judged whether the local contour meets the sharp corner smoothing condition. The so-called sharp corner smoothing condition is also the condition for judging whether there are sharp corners that need to be smoothed in each local contour. The sharp corner smoothing condition can be, for example, whether the angle between the two line segments formed by three pixel points is less than a preset angle threshold such as 10°. If the angle between the two line segments formed by three pixel points is less than the preset angle threshold such as 10°, it is considered that this sharp corner needs to be smoothed, that is, it meets the sharp corner smoothing condition. If the angle between the two line segments formed by three pixel points is greater than the preset angle threshold such as 10°, it is considered that this sharp corner does not need to be smoothed, that is, it does not meet the sharp corner smoothing condition. Those skilled in the art can flexibly determine the sharp corner smoothing condition according to the actual situation, and this application does not make any restrictions on this. The target local contour is those local contours in the local contours that meet the sharp corner smoothing condition, and for the sake of distinction, it is called the target local contour. The concavity and convexity of the target local contour refers to whether the target local contour is a concave curve or a convex curve.

[0094] S103: Determine the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation and the starting point of the inserted arc.

[0095] The inserted arc in this step refers to the curve that replaces the target local contour and is placed in the initial contour. In order to ensure the smoothness of the initial contour, the replacement curve adopts an arc shape. The pixel points of the target local contour are necessarily connected to form two line segments with sharp corners. According to the pixel coordinates of each pixel point of the target local contour, the center and radius of the circle where the inserted arc is located can be determined. After determining the center and radius of the circle, the circle equation of the circle where the inserted arc is located is uniquely determined. After determining the circle equation, according to mathematical theory, the center of the inserted maximum arc can be determined, and then the starting point of the inserted arc can be determined.

[0096] S104: Based on the contour trend and the concavity and convexity of the target local contour, generate the inserted arc of the target local contour according to the insertion point information, starting point, center and circle equation.

[0097] After uniquely determining the circle where the inserted arc is located in the previous step, determine the concavity and convexity of the inserted arc and the direction of accessing the initial contour according to the contour trend and the concavity and convexity of the target local contour. The insertion point information can be the total number of insertion points or the spacing between adjacent insertion points. The insertion point information determines the smoothness of the entire inserted arc. To a certain extent, the more insertion points there are, the smoother the inserted arc is, and the smoother the entire contour is. In this embodiment, the preset angle threshold and the insertion point information can be set to adjust the degree of sharp angle to be removed and the smoothness at the sharp angle removal, reduce the lifting and lowering during the tool movement, and improve the cutting quality and efficiency.

[0098] S105: Replace each target local contour with the inserted arc of the target local contour to generate a contour image of the to-be-cut image.

[0099] After generating the corresponding inserted arc for each target local contour by using S102 - S104, in the initial contour, each inserted arc is used to replace the corresponding target local contour. The initial contour after replacement is the contour image fed to the cutting bed for cutting the to-be-cut material, that is, the final material contour for cutting by the cutting bed is generated.

[0100] In the technical solution provided by the embodiment of the present invention, for the material that needs to be cut by the cutting bed, first identify whether there is a sharp angle in the material contour image. If there is a sharp angle, a section of arc is used to replace the sharp angle, so that the entire material contour is smoother, thereby avoiding the phenomenon that the tool needs to be lifted and lowered at the contour sharp angle, effectively reducing the number of times the tool is lifted and lowered, improving the cutting quality and cutting efficiency of the cutting bed, and thus improving the product quality and the entire production efficiency.

[0101] It should be noted that there is no strict order of execution among the steps of this application. As long as it conforms to the logical order, these steps can be executed simultaneously or in a certain preset order. Figure 1 It is just a schematic way and does not mean that it can only be such an execution order.

[0102] In order to further improve the cutting quality of the cutting bed, before extracting the initial contour of the material, some preprocessing can also be performed on the material image to improve the extraction accuracy of the initial contour, that is, before S101, it can also include:

[0103] Perform image preprocessing on the multi-channel original image to obtain multiple single-channel images; perform threshold segmentation on each single-channel image, and determine the target image that meets the image quality conditions based on the threshold segmentation result; perform binary threshold segmentation on the target image to obtain a binary image; filter out the regions smaller than the preset area threshold in the binary image to obtain the to-be-cut image.

[0104] In this embodiment, the material corresponding to the image to be cut can be leather. Correspondingly, the original image is the original leather image, and this image can be a multi-channel image, such as Figure 2 shown. Filtering operations, channel separation operations, and image grayscaling operations can be performed on the multi-channel image to obtain multiple single-channel images. For example, Gaussian filtering can be used for the filtering operation. The number of single-channel images can be flexibly selected according to the actual situation. For example, it can be 7, Figures 3 - 7 showing single-channel images of 4 multi-channel original leather images. The OTSU algorithm of the maximum inter-class variance method can be used to perform threshold segmentation on each single-channel image, and count the number of small regions contained in each single-channel binary image. The fewer the number of small regions, the better the image quality of the image, that is, it meets the image quality condition, and this single-channel binary image is used as the target image, as shown in Figure 8. Perform binary threshold segmentation on the selected target image to obtain a binary image, such as Figure 9 shown. Since there are many interfering small regions in the binary image, filter out the small regions through area screening and only retain the leather region, such as Figure 10 shown. The preset area threshold in this embodiment can be flexibly determined according to the actual application scenario, and the present application does not make any limitation on this. Use the finally obtained image in this embodiment as the image to be cut in S101, and extract the initial contour of this image to be cut, which is Figure 11 and Figure 12 shown.

[0105] In this embodiment, through a series of image processing on the original image, the accuracy of initial contour extraction can be improved, which is beneficial to improving the cutting quality.

[0106] The above embodiments do not limit the sharp corner smoothing conditions and how to judge whether there are sharp corners to be smoothed in the initial contour. This embodiment also gives a corresponding embodiment, which may include:

[0107] Divide the initial contour into multiple connected local contours; for each local contour, obtain the pixel coordinates of three adjacent pixel points of the current local contour, and calculate the angle between the first line segment formed by the first pixel point and the second pixel point and the second line segment formed by the second pixel point and the third pixel point; if the angle is greater than or equal to the preset angle threshold, it is determined that the current local contour does not meet the sharp corner smoothing condition, and this local contour does not need to be smoothed, that is, S102 - S105 do not need to be executed, and directly judge the next local contour. If the angle is less than the preset angle threshold, it is determined that the current local contour meets the sharp corner smoothing condition, and this local contour needs to be smoothed, that is, execute S102 - S105. Such as Figure 11 the pixel points at the A sharp corner of Figure 12 and the pixel points at the B sharp corner ofFigure 14 ) It is located at the corner of the contour and the angle is small, that is, a sharp corner. Therefore, when the tool cuts here, it first lifts, rotates a certain angle and then drops to continue cutting. The lifting and dropping of the tool will reduce the cutting efficiency and affect the cutting quality. Therefore, it is necessary to execute S102 - S105 for sharp corner smoothing processing.

[0108] The preset angle threshold of this embodiment can be selected according to the actual application scenario, and the included angle value can be calculated according to the cosine theorem. The judgment method of the target local contour provided by this embodiment is simple and effective.

[0109] In the above embodiment, there is no limitation on how to execute step S102. In this embodiment, an optional implementation manner for determining the contour direction and the contour concavity and convexity is given. In this embodiment, the initial contour direction being clockwise can be called reciprocity = 0, such as Figure 15 ; the initial contour direction being counterclockwise can be called reciprocity = 1, such as Figure 16 . Specifically, it may include the following steps:

[0110] As an optional implementation manner, traverse all the pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X coordinate axis among all the pixel points; if the coordinate value of the target pixel point on the Y coordinate axis is greater than or equal to the coordinate value of the previous pixel point of the target pixel point on the Y coordinate axis, and the coordinate value of the target pixel point on the Y coordinate axis is less than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, then the contour direction of the initial contour is clockwise.

[0111] In this embodiment, all the points on the initial contour are traversed to find the pixel point with the largest or smallest X coordinate value (or the largest or smallest Y coordinate value). Taking the pixel point with the largest X coordinate value as an example, the pixel point with the largest X coordinate value is denoted as maxCurrentPt, and the coordinate is (maxCurrentPtX, maxCurrentPtY); the previous point of the maximum value point is denoted as maxPreviousPt, and the coordinate is (maxPreviousPtX, maxPreviousPtY); the next point of the maximum value point is denoted as maxNextPt, and the coordinate is (maxNextPtX, maxNextPtY). The contour direction of the initial contour can be judged according to the following relational expression:

[0112]

[0113] Taking the minimum pixel point of the X-axis as an example, select the point with the minimum X coordinate and denote it as minCurrentPt, with coordinates (minCurrentPtX, minCurrentPtY); denote the previous point of the minimum value point as minPreviousPt, with coordinates (minPreviousPtX, minPreviousPtY); denote the next point of the minimum value point as minNextPt, with coordinates (minNextPtX, minNextPtY). The contour direction of the initial contour can be judged according to the following relational expression:

[0114]

[0115] As another implementation mode parallel to the above embodiments, traverse all pixel points of the initial contour to determine the target pixel point with the minimum coordinate value on the X coordinate axis among all pixel points; obtain the pixel coordinates of the previous pixel point and the next pixel point of the target pixel point; if the cross product of the first vector and the second vector is less than 0, the contour direction of the initial contour is clockwise; if the cross product of the first vector and the second vector is greater than 0, the contour direction of the initial contour is counterclockwise; the first vector is formed by the target pixel point and the previous pixel point, and the second vector is formed by the target pixel point and the next pixel point.

[0116] In this embodiment, traverse all points on the initial contour to find the point with the largest or smallest X coordinate value (or the largest or smallest pixel point on the Y coordinate). Taking the minimum pixel point of the X-axis as an example, select the minimum value point and denote it as G, with coordinates (minCurrentPtX, minCurrentPtY); denote the previous point of the minimum value point as F, with coordinates (minPreviousPtX, minPreviousPtY); denote the next point of the minimum value point as H, with coordinates (minNextPtX, minNextPtY); denote the cross product of vector FG and vector GH as crossProductFGH. The contour direction of the initial contour can be judged according to the following relational expression:

[0117]

[0118] After elaborating on the above various implementation modes, the cases of the maximum pixel point of the X-axis, the minimum pixel point and the maximum pixel point of the Y-axis can be obtained in the same way as above. Here, it will not be elaborated any further.

[0119] After determining the contour direction of the initial contour, the method for judging the concavity and convexity of the local contour can be as follows: for each local contour, obtain the coordinates of three adjacent pixel points of the current local contour. The starting pixel point coordinates and the middle pixel point coordinates form a first pointing vector, and the middle pixel point coordinates and the end pixel point coordinates form a second pointing vector. When the contour direction is clockwise, if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is convex; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is concave. When the contour direction is counterclockwise: if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is concave; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is convex. For example, the local contour includes three pixel points A, B, and C. Pixel point A and pixel point B in this embodiment are not the same pixel points as pixel point A and pixel point B of Figure 11 and Figure 12 . Pixel points A, B, and C in this embodiment are any three pixel points on any local contour. The method for judging the concavity and convexity of this local contour can be as follows: the cross product of vector AB and vector BC is crossProductABC. According to the contour direction and the positive or negative of the cross product, judge the local concavity and convexity. The judgment relationship can be as follows:

[0120]

[0121] This embodiment provides various methods for determining the contour direction and judging the concavity and convexity of the contour, improving the flexibility and practicability of the entire technical solution.

[0122] The above embodiment does not make any limitation on how to execute S103. This embodiment also gives an optional method for determining the parameters of the circle where the inserted arc is located and the parameters of the inserted arc, which may include:

[0123] Obtain the first target pixel point, the second target pixel point, and the third target pixel point adjacent to each other on the target local contour and their respective pixel coordinates; the first target pixel point and the second target pixel point form a first target line segment, and the second target pixel point and the third target pixel point form a second target line segment; if the length of the first target line segment is greater than or equal to the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the second target line segment; if the length of the first target line segment is less than the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the first target line segment; at the same time, calculate the center coordinates and radius of the inserted maximum arc; calculate the center coordinates of the circle where the inserted arc is located according to the principle of similar triangles, and determine the circle equation according to the center coordinates and the radius of the circle where the inserted arc is located; along the contour direction, take the point where the inferior arc corresponding to the central angle of the circle where the inserted arc is located is first tangent to the first target line segment or the second target line segment as the starting point of the inserted arc. In this embodiment, for the convenience of description, the first target pixel point can be called pixel point A, the second target pixel point can be called pixel point B, and the third target pixel point can be called pixel point C. Similarly, pixel points A and B are different from the attached Figure 11 and Figure 12 A, B. According to the Euclidean distance formula in two-dimensional space, the lengths distanceAB and distanceBC of line segments AB and BC can be calculated, and the sizes of line segments AB and BC are compared. As an alternative implementation, the radius of the circle where the inserted arc is located can be calculated by calling the radius calculation relationship formula, and the radius calculation relationship formula can be expressed as:

[0124]

[0125] In the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circleRadius is the radius of the circle where the inserted arc is located, θ is the included angle between the first target line segment and the second target line segment, and n is a constant. The forms of the circles where the inserted arcs are located with different contour directions can be as Figures 17 - 20 , and the center of the inserted arc is O. Determine the equation of the circle O1 where the inserted arc is located: First, calculate the center O of the maximum arc that can be inserted. As shown in Figure 21 , find the linear equations of lines AB, BC, OB, and OC respectively. Combine the equations of line OB and OC or OB and OA to obtain the intersection point, which is the coordinate (maxCenterX, maxCenterY) of the center O of the inserted arc; since the coordinates of points B, O, and C are known and the lengths of line segments O1C1 and OC are known, according to the similarity of △BO1C1 and △BOC, the coordinate (centerX, centerY) of the center O1 of the circle where the inserted arc is located can be calculated. Based on the above center and radius, the circle equation of circle O1 is (x - centerX)2 +(y-centerY) 2 =circleRadius 2 The method for determining the starting point of the inserted arc is: along the contour direction, the point where the minor arc corresponding to the central angle PO1C1 first touches the straight line AB or BC is the starting point of the inserted arc.

[0126] The above embodiment does not limit how to execute S104. This embodiment also provides an optional method for generating an inserted arc, which may include:

[0127] The rotation angle of the insertion point is determined according to the insertion point information and the angle value of the center angle of the circle; the starting line segment determined by the center of the insertion arc and the starting point is rotated according to the rotation angle along the contour with the center of the circle as the center to obtain multiple rotated line segments; for each rotated line segment, based on the pixel point located in the middle position of the target contour, the insertion point is determined from the intersection of the rotated line segment and the circle where the insertion arc is located; the insertion arc of the target local contour is generated according to the concavity of each insertion point and the target local contour.

[0128] In this embodiment, the insertion point information set by the user is obtained. If the insertion point information is the number of insertion points insertionPtsNum, such as Figure 21 As shown, the center angle PO1C1 is bisected according to the number of insertion points, and the rotation angle of each insertion point is calculated. The rotation angle of each insertion point can be expressed as bisectAangle PO1C1=angle PO1C1 / insertionPtsNum. When the insertion point information is based on the distance between the insertion points insertPtsDistance, the arc length of the insertion arc can be calculated according to arcLength=anglePO1C1*circleRadius, and then the number of insertion points is calculated according to insertionPtsNum=arcLength / insertPtsDistance. Finally, the rotation angle of each insertion point bisectAangle PO1C1=angle PO1C1 / insertionPtsNum is calculated. Connect the center O1 and the starting point P of the arc to obtain a straight line O1P. The straight line O1P takes O1 as the center and runs along the contour. Each time it rotates bisectAangle PO1C1, the intersection of the rotated straight line O1Q and the circle O1 is Q, as shown Figure 21 When the number of rotations reaches the number of insertion points insertionPtsNum, the insertion point acquisition is completed. The equation of the line O1Q and the equation of the circle O1 will result in a quadratic equation, so there will be two sets of solutions, that is, the line O1Q and the circle O1 have two intersection points Q1 and Q2, such as Figure 21; Calculate the distances BQ1 and BQ2 between point B and Q1, Q2 using the Euclidean distance formula in two-dimensional space, compare the magnitudes of BQ1 and BQ2, and the one with the shorter distance is the coordinate of the required intersection point Q. The contour after inserting the arc is as Figure 22 and Figure 23 , and the partial views at sharp corners A and B are as Figure 24 and 25 . By comparing the contours before and after smoothing, it can be clearly seen that after removing the sharp corners through this embodiment, compared with the initial contour, the entire finally obtained contour can have a smooth transition, thereby effectively improving the cutting quality and cutting efficiency.

[0129] To make the technical solution of this application clearer and more understandable to those skilled in the art, this application also takes the cutting of leather images as an example to elaborate on the entire technical solution, which may include:

[0130] A1: Obtain the three-channel original image of the leather as shown in Figure 2 , perform Gaussian filtering, channel separation, and grayscale processing on this original image to generate 7 single-channel images, as shown in Figures 3 - 7 .

[0131] A2: Use the OTSU algorithm to perform threshold segmentation on the 7 single-channel images generated in step A1, calculate the number of regions in the segmented binary image, and use the image with the smallest number as the image with the optimal quality for subsequent processing, as shown in Figure 8 .

[0132] A3: Perform binary threshold segmentation on the image selected in step A2 to obtain a binary image, as shown in Figure 9 .

[0133] A4: Perform region area screening on the binary image in step A3, filter out small regions, and only retain the leather region to obtain Figure 10 .

[0134] A5: Extract the leather contour from the image obtained in step A4 to obtain Figure 11 and Figure 12 . Figure 11 and Figure 12 A and B in are located at the contour turning corners and have a relatively small angle (i.e., sharp corners), and the following steps need to be carried out for sharp corner removal and smoothing processing.

[0135] A6: Traverse all points on the contour to find the pixel point G with the minimum X - coordinate value, whose coordinates are (minCurrentPtX, minCurrentPtY); the previous point of the minimum - value point is denoted as F, with coordinates (minPreviousPtX, minPreviousPtY); the next point of the minimum - value point is denoted as H, with coordinates (minNextPtX, minNextPtY); the cross - product of the vector FG and the vector GH is denoted as crossProductFGH, and the contour direction can be judged according to the following relational formula. For a clockwise contour, reciprocity = 0; for a counter - clockwise contour, reciprocity = 1.

[0136]

[0137] A7: Set the target angle targetAngle. Successively take three adjacent points A, B, and C on the contour, with coordinates (pointAx, pointAy), (pointBx, pointBy), and (pointCx, pointCy) respectively. Use the cosine theorem to calculate the included angle θ between the straight line AB and the straight line BC, and judge whether the local contour formed by these three points needs to be smoothed. The judgment formula is as follows:

[0138]

[0139] A8: Judge the concavity and convexity of the local contour formed by points A, B, and C: The cross - product of the vector AB and the vector BC is denoted as crossProductABC. According to the contour direction and the positive or negative of the cross - product, the concavity and convexity of the local contour can be judged according to the following relational formula:

[0140]

[0141] A9: Determine the radius circleRadius of the circle where the inserted arc is located: Calculate the lengths distanceAB and distanceBC of the line segments AB and BC according to the Euclidean distance formula in two - dimensional space, compare the sizes of the line segments AB and BC, and the formula for determining the radius of the circle where the inserted arc is located is as follows:

[0142]

[0143] A10: Determine the equation of the circle O1 where the inserted arc is located: First, find the center O of the largest arc that can be inserted, as Figure 10As shown in the figure, the linear equations of lines AB, BC, OB, and OC are obtained respectively. By simultaneously solving the equations of line OB and OC or OB and OA, the intersection point is the coordinates of the center O (maxCenterX, maxCenterY). Since the coordinates of points B, O, and C are known and the lengths of line segments O1C1 and OC are known, according to the similarity of △BO1C1 and △BOC, the coordinates of the center O1 (centerX, centerY) can be obtained. The equation of circle O1 is (x - centerX) 2 +(y - centerY) 2 =circleRadius 2 . Insertion starting point of the arc: Along the contour direction, the point where the minor arc corresponding to the central angle PO1C1 is first tangent to line AB or BC is the insertion starting point of the arc.

[0144] A11: Set the number of insertion points insertionPtsNum. Bisect the central angle PO1C1 according to the number of insertion points, and calculate the angle of each rotation of the insertion point as bisectAangle PO1C1 = angle PO1C1 / insertionPtsNum. Connect the center O1 to the starting point P of the arc to obtain line O1P. With O1 as the center, along the contour direction, rotate line O1P by bisectAangle PO1C1 each time, and the intersection point of the rotated line O1Q and circle O1 is Q. When the number of rotations reaches the number of insertion points insertionPtsNum, the acquisition of the insertion points is completed.

[0145] A12: Simultaneously solve the equation of line O1Q and the equation of circle O1 to obtain a quadratic equation of one variable. This quadratic equation of one variable has two sets of solutions, that is, line O1Q and circle O1 have two intersection points. Use the Euclidean distance formula in two-dimensional space to calculate the distances between point B and these two intersection points, and the one with the shorter distance is the required intersection point. The contour after inserting the arc is as Figure 22 and 23 .

[0146] As can be seen from the above, by comparing the contours before and after smoothing, it can be clearly seen that after removing the sharp corners of the original contour by using the technical solution provided in this embodiment, the entire contour can be smoothly transitioned, which is more convenient for cutting.

[0147] The embodiment of the present invention also provides a corresponding device for the image contour generation method, further making the method more practical. Among them, the device can be described from the perspective of functional modules and the perspective of hardware respectively. The image contour generation device provided in the embodiment of the present invention is introduced below. The image contour generation device described below can be mutually referred to with the image contour generation method described above.

[0148] From the perspective of functional modules, see Figure 26 , Figure 26The following is a structural diagram of the image contour generation device provided by an embodiment of the present invention under a specific embodiment. The device may include:

[0149] An initial contour extraction module 261, configured to extract an initial contour of an image to be cropped.

[0150] A contour direction determination module 262, configured to determine the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour.

[0151] A concavity and convexity determination module 263, for each local contour in the initial contour, if there is a target local contour that satisfies the sharp corner smoothing condition, determine the concavity and convexity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour.

[0152] An inserted arc parameter calculation module 264, configured to determine the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation and the starting point of the inserted arc.

[0153] An inserted arc generation module 265, configured to generate an inserted arc of the target local contour based on the contour direction and the concavity and convexity of the target local contour, according to the insertion point information, the starting point, the center of the circle, and the circle equation.

[0154] A contour generation module 266, configured to use the inserted arc of each target local contour to replace the corresponding target local contour, and generate a contour image of the image to be cropped.

[0155] Optionally, in some embodiments of this embodiment, the above device may further include an image preprocessing module, configured to perform image preprocessing on a multi-channel original image before extracting the initial contour of the image to be cropped, to obtain multiple single-channel images; perform threshold segmentation on each single-channel image, and determine a target image that meets the image quality condition based on the threshold segmentation result; perform binary threshold segmentation on the target image to obtain a binary image; filter out regions smaller than a preset area threshold in the binary image to obtain the image to be cropped.

[0156] As an alternative implementation of this embodiment, the above device may further include a smoothing judgment module, which is configured to divide the initial contour into multiple connected local contours; for each local contour, obtain the pixel coordinates of three adjacent pixel points of the current local contour, and calculate the included angle between the first line segment formed by the first pixel point and the second pixel point and the second line segment formed by the second pixel point and the third pixel point; if the included angle is greater than or equal to a preset angle threshold, it is determined that the current local contour does not meet the sharp corner smoothing condition; if the included angle is less than the preset angle threshold, it is determined that the current local contour meets the sharp corner smoothing condition. Optionally, in some other implementations of this embodiment, the above contour direction determination module 262 may further be configured to: traverse all pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X coordinate axis among all pixel points; if the coordinate value of the target pixel point on the Y coordinate axis is greater than or equal to the coordinate value of the previous pixel point of the target pixel point on the Y coordinate axis and the coordinate value of the target pixel point on the Y coordinate axis is less than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, then the contour direction of the initial contour is clockwise.

[0157] As an alternative implementation of this embodiment, the above contour direction determination module 262 may further be configured to: traverse all pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X coordinate axis among all pixel points; obtain the pixel coordinates of the previous pixel point and the next pixel point of the target pixel point; if the cross product of the first vector and the second vector is less than 0, then the contour direction of the initial contour is clockwise; if the cross product of the first vector and the second vector is greater than 0, then the contour direction of the initial contour is counterclockwise; the first vector is formed by the target pixel point and the previous pixel point, and the second vector is formed by the target pixel point and the next pixel point.

[0158] As another alternative implementation of this embodiment, the above concavity and convexity determination module 263 may be configured to, for each local contour, obtain the coordinates of three adjacent pixel points of the current local contour, the starting pixel point coordinate and the middle pixel point coordinate form a first pointing vector, and the middle pixel point coordinate and the end pixel point coordinate form a second pointing vector; when the contour direction is clockwise, if the cross product of the first pointing vector and the second pointing vector is less than 0, then the current local contour is convex; if the cross product of the first pointing vector and the second pointing vector is greater than 0, then the current local contour is concave; when the contour direction is counterclockwise: if the cross product of the first pointing vector and the second pointing vector is less than 0, then the current local contour is concave; if the cross product of the first pointing vector and the second pointing vector is greater than 0, then the current local contour is convex.

[0159] As some other alternative embodiments of this embodiment, the above-mentioned inserted arc parameter calculation module 264 can be used to: obtain adjacent first target pixel point, second target pixel point and third target pixel point on the target local contour and their respective pixel coordinates; the first target pixel point and the second target pixel point form a first target line segment, and the second target pixel point and the third target pixel point form a second target line segment; if the length of the first target line segment is greater than or equal to the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the second target line segment; if the length of the first target line segment is less than the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the first target line segment; at the same time, calculate the center coordinates and radius of the inserted maximum arc; calculate the center coordinates of the circle where the inserted arc is located according to the principle of similar triangles, and determine the circle equation according to the center coordinates and the radius of the circle where the inserted arc is located; along the contour direction, use the point where the inferior arc corresponding to the central angle of the circle where the inserted arc is located is first tangent to the first target line segment or the second target line segment as the starting point of the inserted arc.

[0160] As some other embodiments of this embodiment, the above-mentioned inserted arc parameter calculation module 264 can further be used to: call the radius calculation relational expression to calculate the radius of the circle where the inserted arc is located, and the radius calculation relational expression is:

[0161]

[0162] In the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circleRadius is the radius of the circle where the inserted arc is located, θ is the included angle between the first target line segment and the second target line segment, and n is a constant. Optionally, in some other embodiments of this embodiment, the above-mentioned inserted arc generation module 265 can further be used to: determine the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle; rotate the starting line segment determined by the center and the starting point of the inserted arc around the center, along the contour direction, according to the rotation angle, to obtain a plurality of rotated line segments; for each rotated line segment, based on the pixel point located in the middle position on the target contour, determine the insertion point from the intersection points of the rotated line segment and the circle where the inserted arc is located; generate the inserted arc of the target local contour according to each insertion point and the concavity and convexity of the target local contour.

[0163] The functions of the functional modules of the image contour generation device described in the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the relevant descriptions of the above method embodiments, which will not be elaborated here.

[0164] As can be seen from the above, this embodiment can effectively improve the cutting quality and cutting efficiency of the cutting machine.

[0165] The image contour generation device mentioned above is described from the perspective of functional modules. Further, the present application also provides an electronic device, which is described from the hardware perspective. Figure 27 It is a schematic structural diagram of the electronic device provided by the embodiment of the present application in an implementation manner. As Figure 27 shown, the electronic device includes a memory 270 for storing computer programs; a processor 271 for implementing the steps of the image contour generation method mentioned in any of the above embodiments when executing the computer programs.

[0166] Among them, the processor 271 may include one or more processing cores, such as a 4-core processor or an 8-core processor. The processor 271 may also be a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 271 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 271 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 271 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 271 may also include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.

[0167] The memory 270 may include one or more computer-readable storage media, which may be non-transitory. The memory 270 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In some embodiments, the memory 270 may be an internal storage unit of an electronic device, such as the hard disk of a server. In other embodiments, the memory 270 may also be an external storage device of an electronic device, such as a plug-in hard disk equipped on a server, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory 270 may also include both an internal storage unit and an external storage device of the electronic device. The memory 270 can be used not only to store application software installed in the electronic device and various types of data, such as the code of a program for executing a vulnerability handling method, etc., but also to temporarily store data that has been output or will be output. In this embodiment, the memory 270 is at least used to store the following computer program 2701, wherein, after the computer program is loaded and executed by the processor 271, it can implement the relevant steps of the image contour generation method disclosed in any of the foregoing embodiments. Additionally, the resources stored in the memory 270 may also include an operating system 2702 and data 2703, etc., and the storage method can be temporary storage or permanent storage. Among them, the operating system 2702 may include Windows, Unix, Linux, etc. The data 2703 may include, but is not limited to, data corresponding to the image contour generation result, etc.

[0168] In some embodiments, the above-mentioned electronic device may further include a display screen 272, an input / output interface 273, a communication interface 274 or a network interface, a power supply 275, and a communication bus 276. Among them, the display screen 272 and the input / output interface 273, such as a keyboard, belong to user interfaces. Optional user interfaces may also include standard wired interfaces, wireless interfaces, etc. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) toucher, etc. The display may also be appropriately referred to as a display screen or a display unit, and is used to display information processed in the electronic device and to display a visual user interface. The communication interface 274 may optionally include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, etc., and is generally used to establish a communication connection between the electronic device and other electronic devices. The communication bus 276 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. This bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 27 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0169] Those skilled in the art can understand that Figure 27 the structure shown in the figure does not constitute a limitation on the electronic device, and it may include more or fewer components than those shown in the figure. For example, it may further include a sensor 277 for implementing various functions.

[0170] The functions of the functional modules of the electronic device described in the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant descriptions in the above method embodiments and will not be elaborated here.

[0171] As can be seen from the above, this embodiment can effectively improve the cutting quality and cutting efficiency of the cutting machine.

[0172] It can be understood that if the image contour generation method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), electrically erasable programmable ROMs, registers, hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, removable disks, CD-ROMs, magnetic disks, or optical disks, etc., which can store program codes of various types.

[0173] Based on this, the embodiments of the present invention further provide a readable storage medium storing a computer program, and when the computer program is executed by a processor, it performs the steps of the image contour generation method as described in any of the above embodiments.

[0174] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the hardware, including devices and electronic devices, disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.

[0175] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0176] The above has introduced in detail a method, apparatus, and electronic device for generating an image contour provided in this application. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principles of the present invention, several improvements and modifications can still be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. An image contour generation method, characterized in that, Including: Extract the initial contour of the image to be cropped, and determine the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour; For each local contour in the initial contour, if there is a target local contour that meets the sharp corner smoothing condition, determine the convexity and concavity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour; Determine the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation of the circle and the starting point of the inserted arc; Based on the contour direction and the convexity and concavity of the target local contour, generate the inserted arc of the target local contour according to the insertion point information, the starting point, the center of the circle and the circle equation; Use the inserted arc of each target local contour to replace the corresponding target local contour to generate the contour image of the image to be cropped; Among them, the process of generating the inserted arc of the target local contour based on the contour direction and the convexity and concavity of the target local contour, according to the insertion point information, the starting point, the center of the circle and the circle equation, includes: Determine the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle; Rotate the starting line segment determined by the center of the inserted arc and the starting point around the center of the circle where the inserted arc is located, along the contour direction, according to the rotation angle, to obtain a plurality of rotated line segments; For each rotated line segment, based on the pixel point located in the middle position on the target contour, determine the insertion point from the intersection points of the rotated line segment and the circle where the inserted arc is located; Generate the inserted arc of the target local contour according to each insertion point and the convexity and concavity of the target local contour.

2. The image contour generation method according to claim 1, wherein Before extracting the initial contour of the image to be cropped, it further includes: Perform image preprocessing on the multi-channel original image to obtain multiple single-channel images; Perform threshold segmentation on each single-channel image, and determine the target image that meets the image quality condition based on the threshold segmentation result; Perform binary threshold segmentation on the target image to obtain a binary image; Filter the regions smaller than the preset area threshold in the binary image to obtain the image to be cropped.

3. The image contour generation method according to claim 1, wherein The determining the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour includes: Traverse all pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X coordinate axis among all pixel points; If the coordinate value of the target pixel point on the Y coordinate axis is greater than or equal to the coordinate value of the previous pixel point of the target pixel point on the Y coordinate axis, and the coordinate value of the target pixel point on the Y coordinate axis is less than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, then the contour direction of the initial contour is clockwise.

4. The image contour generation method according to claim 1, wherein The determining the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour includes: Traverse all pixel points of the initial contour to determine the target pixel point with the smallest coordinate value on the X coordinate axis among all pixel points; Obtain the pixel coordinates of the previous pixel point and the next pixel point of the target pixel point; If the cross product of the first vector and the second vector is less than 0, the contour direction of the initial contour is clockwise; if the cross product of the first vector and the second vector is greater than 0, the contour direction of the initial contour is counterclockwise; the first vector is formed by the target pixel point and the previous pixel point, and the second vector is formed by the target pixel point and the next pixel point.

5. The image contour generation method according to claim 4, wherein Before there is a target local contour that meets the sharp corner smoothing condition, it further includes: Dividing the initial contour into multiple connected local contours; For each local contour, obtain the pixel coordinates of three adjacent pixel points of the current local contour, and calculate the angle between the first line segment formed by the first pixel point and the second pixel point and the second line segment formed by the second pixel point and the third pixel point; if the angle is greater than or equal to the preset angle threshold, determine that the current local contour does not meet the sharp corner smoothing condition; if the angle is less than the preset angle threshold, determine that the current local contour meets the sharp corner smoothing condition.

6. The image contour generation method according to claim 1, wherein Determining the convexity and concavity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour includes: For each local contour, obtain the coordinates of three adjacent pixel points of the current local contour. The starting pixel point coordinates and the intermediate pixel point coordinates form a first pointing vector, and the intermediate pixel point coordinates and the end pixel point coordinates form a second pointing vector; When the contour direction is clockwise, if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is convex; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is concave; When the contour direction is counterclockwise: if the cross product of the first pointing vector and the second pointing vector is less than 0, the current local contour is concave; if the cross product of the first pointing vector and the second pointing vector is greater than 0, the current local contour is convex.

7. The image contour generation method according to claim 1, wherein Determining the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour to determine the circle equation of the circle and the starting point of the inserted arc includes: Obtain adjacent first target pixel point, second target pixel point and third target pixel point on the target local contour and their respective pixel coordinates; the first target pixel point and the second target pixel point form a first target line segment, and the second target pixel point and the third target pixel point form a second target line segment; If the length of the first target line segment is greater than or equal to the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the angle between the first target line segment and the second target line segment and the length of the second target line segment; if the length of the first target line segment is less than the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the angle between the first target line segment and the second target line segment and the length of the first target line segment; at the same time, calculate the center coordinates and radius of the inserted maximum arc; Calculate the center coordinates of the circle where the inserted arc is located according to the principle of similar triangles, and determine the circle equation based on the center coordinates and the radius of the circle where the inserted arc is located; Along the contour direction, take the point where the minor arc corresponding to the central angle of the circle where the inserted arc is located is first tangent to the first target line segment or the second target line segment as the starting point of the inserted arc.

8. The image contour generation method according to claim 7, wherein If the length of the first target line segment is greater than or equal to the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the second target line segment; if the length of the first target line segment is less than the length of the second target line segment, calculate the radius of the circle where the inserted arc is located according to the included angle between the first target line segment and the second target line segment and the length of the first target line segment; The process of calculating the center coordinates and radius of the maximum inserted arc at the same time includes: Call the radius calculation relational expression to calculate the radius of the circle where the inserted arc is located, and the radius calculation relational expression is: In the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circleRadius is the radius of the circle where the inserted arc is located, θ is the included angle between the first target line segment and the second target line segment, and n is a constant.

9. An image contour generation device, characterized in that, Include: An initial contour extraction module for extracting the initial contour of the image to be cut; A contour direction determination module for determining the contour direction according to the numerical relationship between the pixel coordinates of each pixel point of the initial contour; A concavity and convexity determination module for each local contour in the initial contour, if there is a target local contour that satisfies the sharp corner smoothing condition, determine the concavity and convexity of the target local contour according to the contour direction and the pixel coordinates of each pixel point of the target local contour; An inserted arc parameter calculation module for determining the center and radius of the circle where the inserted arc is located according to the pixel coordinates of each pixel point of the target local contour, so as to determine the circle equation of the circle and the starting point of the inserted arc; An inserted arc generation module for generating the inserted arc of the target local contour based on the contour direction and the concavity and convexity of the target local contour, according to the insertion point information, the starting point, the center and the circle equation; A contour generation module for generating the contour image of the image to be cut by using the inserted arc of each target local contour to replace the corresponding target local contour; Among them, the inserted arc generation module is used to: determine the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle; rotate the starting line segment determined by the center and the starting point of the inserted arc around the center of the circle where the inserted arc is located, along the contour direction, according to the rotation angle, to obtain a plurality of rotated line segments; for each rotated line segment, based on the pixel point located in the middle position on the target contour, determine the insertion point from the intersection points of the rotated line segment and the circle where the inserted arc is located; generate the inserted arc of the target local contour according to each insertion point and the concavity and convexity of the target local contour.

10. An electronic device, characterized in that, It includes a processor and a memory. When the processor executes the computer program stored in the memory, it implements the steps of the image contour generation method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Fruit recognition method and system

    CN110309730A

  • Procedure to determine contour of tool inputting ideal position for only one point on contour

    DE19914862A1