CN114170261A - Image contour generation method and device and electronic equipment - Google Patents

Image contour generation method and device and electronic equipment Download PDF

Info

Publication number
CN114170261A
CN114170261A CN202111257336.2A CN202111257336A CN114170261A CN 114170261 A CN114170261 A CN 114170261A CN 202111257336 A CN202111257336 A CN 202111257336A CN 114170261 A CN114170261 A CN 114170261A
Authority
CN
China
Prior art keywords
contour
target
line segment
image
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111257336.2A
Other languages
Chinese (zh)
Inventor
苗猛
丁威
苏凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Iecho Technology Co ltd
Original Assignee
Hangzhou Iecho Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Iecho Technology Co ltd filed Critical Hangzhou Iecho Technology Co ltd
Priority to CN202111257336.2A priority Critical patent/CN114170261A/en
Publication of CN114170261A publication Critical patent/CN114170261A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/181Segmentation; Edge detection involving edge growing; involving edge linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30124Fabrics; Textile; Paper

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The application discloses an image contour generation method and device and electronic equipment. The method comprises the steps of extracting an initial contour of an image to be cut, and determining the trend of the contour according to the numerical relation among the coordinates of all pixel points of the initial contour. And 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 for the target local contour meeting the apical angle smoothness condition in the initial contour. Determining the circle center and the radius of a circle where the inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circular equation and a starting point of the inserted circular arc; generating an insertion arc of the target local contour according to the insertion point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour; the inserting circular arc of each target local contour is used for replacing the corresponding target local contour to generate a final leather contour image for cutting by the cutting bed, so that the cutting quality and the cutting efficiency of the cutting bed can be effectively improved.

Description

Image contour generation method and device and electronic equipment
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image contour generation method and apparatus, and an electronic device.
Background
With the rapid development of automation technology and intelligent technology, intelligent equipment is applied to various industries, cutting beds are used as intelligent equipment for batch production and processing of flexible materials in industries such as textile clothing, automobile decorations and the like, and the automatic cutting technology for fabrics is rapidly developed in order to meet the practical requirements of users on high utilization rate, high-quality processing and high-efficiency processing of the fabrics.
When a fabric is cut by using a cutting bed such as a multilayer cutting bed, a cutting track is generated in an image of the fabric based on the shape and size of each cut piece, or an area outline of the fabric is directly used as the cutting track, and then the fabric is cut according to the cutting track. Some flexible materials with certain thickness such as leather often adopt a round wheel to cut, and the leather is sometimes taken up due to the fact that a cutter needs to be lifted up and down at a sharp corner of the profile, so that the cutting quality is affected, and the cutting efficiency is reduced.
In view of this, how to improve the cutting quality and efficiency of such materials is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
The application provides an image contour generation method, an image contour generation device and electronic equipment, which effectively improve the cutting quality and the cutting efficiency of a cutting bed.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
an embodiment of the present invention provides an image contour generation method, including:
extracting an initial contour of an image to be cut, and determining the contour trend according to the numerical relationship among pixel coordinates of all pixel points of the initial contour;
for each section of local contour in the initial contour, if a target local contour meeting a sharp corner smoothing condition exists, 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;
determining the circle center and the radius of a circle where an inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circle equation of the circle and a starting point of the inserted circular arc;
generating an insertion arc of the target local contour according to insertion point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour;
and replacing the corresponding target local contour by using the inserted circular arc of each target local contour to generate a contour image of the image to be cut.
Optionally, before the extracting the initial contour of the image to be cropped, the method further includes:
carrying out image preprocessing on the multi-channel original image to obtain a plurality of single-channel images;
performing threshold segmentation on each single-channel image, and determining a target image meeting image quality conditions based on a threshold segmentation result;
carrying out binarization threshold segmentation on the target image to obtain a binary image;
and filtering the area smaller than the preset area threshold value in the binary image to obtain the image to be cut.
Optionally, before the target local contour satisfying the condition of sharp corner smoothing exists, the method further includes:
dividing the initial contour into a plurality of sections of connected local contours;
for each local contour, acquiring pixel coordinates of three adjacent pixel points of the current local contour, and calculating an included angle between a first line segment formed by the first pixel point and the second pixel point and a second line segment formed by the second pixel point and the third pixel point; if the included angle is larger than or equal to a preset angle threshold value, judging that the current local contour does not meet the sharp corner smoothing condition; if the included angle is smaller than a preset angle threshold value, judging that the current local contour meets the sharp corner smoothing condition;
optionally, the determining the profile trend according to the numerical relationship between the pixel coordinates of each pixel point of the initial profile includes:
traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points;
and 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, the profile direction of the initial profile is clockwise.
Optionally, the determining the profile trend according to the numerical relationship between the pixel coordinates of each pixel point of the initial profile includes:
traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points;
acquiring pixel coordinates of a previous pixel point and a 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 outline trend of the initial outline is clockwise; if the cross product of the first vector and the second vector is greater than 0, the profile trend of the initial profile is in a counterclockwise trend; 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.
Optionally, the determining, according to the profile trend and the pixel coordinates of each pixel point of the target local profile, the concavity and convexity of the target local profile includes:
for each local contour, acquiring coordinates of three adjacent pixel points of the current local contour, forming a first directional vector by the coordinates of the initial pixel point and the coordinates of the middle pixel point, and forming a second directional vector by the coordinates of the middle pixel point and the coordinates of the tail pixel point;
when the profile trend is clockwise, if the cross product of the first directional vector and the second directional vector is less than 0, the current local profile is convex; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is concave;
when the profile runs counter-clockwise: if the cross product of the first directional vector and the second directional vector is less than 0, the current local contour is concave; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is convex.
Optionally, the determining, according to the pixel coordinates of each pixel point of the target local contour, the circle center and the radius of the circle where the inserted arc is located to determine the circle equation of the circle and the starting point of the inserted arc includes:
acquiring adjacent first target pixel points, second target pixel points and third target pixel points on the target local contour and 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, calculating the radius of the circle where the insertion circular 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 smaller than that of the second target line segment, calculating the radius of a circle where the insertion circular 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; simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc;
calculating the circle center coordinate of the circle where the inserted circular arc is located according to a triangle similarity principle, and determining the circle equation according to the circle center coordinate and the radius of the circle where the inserted circular arc is located;
and taking a point at which a minor arc corresponding to the central angle of the circle where the inserting arc is located is firstly tangent to the first target line segment or the second target line segment as the starting point of the inserting arc along the trend of the profile.
Optionally, if the length of the first target line segment is greater than or equal to the length of the second target line segment, 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 smaller than that of the second target line segment, calculating the radius of a circle where the insertion circular 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 simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc comprises the following steps:
and calling a radius calculation relational expression to calculate the radius of the circle where the inserted circular arc is located, wherein the radius calculation relational expression is as follows:
Figure RE-GDA0003498434410000041
in the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circlerradius is the radius of the circle where the insertion arc is located, theta is the included angle between the first target line segment and the second target line segment, and n is a constant.
Optionally, the process of generating an insertion arc of the target local contour according to insertion point information, the starting point, the circle center, and the circular equation based on the contour trend and the concavity and convexity of the target local contour includes:
determining the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle;
rotating the initial line segment determined by the circle center and the starting point of the inserted circular arc along the outline trend by taking the circle center of the circle where the inserted circular arc is located as the center according to the rotating angle to obtain a plurality of rotating line segments;
for each rotating line segment, determining an insertion point from an intersection point of the rotating line segment and a circle where the insertion arc is located based on a pixel point located at the middle position on the target contour;
and generating an insertion arc of the target local contour according to each insertion point and the concavity and convexity of the target local contour.
Another aspect of an embodiment of the present invention provides an image contour generating apparatus, including:
the initial contour extraction module is used for extracting an initial contour of the image to be cut;
the contour direction determining module is used for determining the contour direction according to the numerical relationship among the pixel coordinates of all the pixel points of the initial contour;
the concave-convex determining module is used for determining the concave-convex of each section of local contour in the initial contour according to the contour trend and the pixel coordinates of each pixel point of the target local contour if the target local contour meeting the sharp-corner smooth condition exists;
the inserted circular arc parameter calculation module is used for determining the circle center and the radius of a circle where an inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circular equation of the circle and a starting point of the inserted circular arc;
the inserting circular arc generating module is used for generating an inserting circular arc of the target local contour according to inserting point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour;
and the contour generation module is used for replacing the corresponding target local contour with the inserted circular arc of each target local contour to generate a contour image of the leather to be processed.
An embodiment of the present invention further provides an electronic device, which includes a processor, and the processor is configured to implement the steps of the image contour generation method according to any one of the preceding items when executing the computer program stored in the memory.
Finally, an embodiment of the present invention provides a readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the image contour generation method according to any one of the preceding claims.
The utility model provides a technical scheme's advantage lies in, to the material that needs utilize the cutting bed to cut the processing, whether discernment material profile image exists the closed angle earlier, if there is the closed angle, then adopt one section circular arc to replace this closed angle, make whole material profile smoother, thereby avoid profile closed angle department to lift up and the phenomenon emergence of falling the cutter, can effectively reduce the number of times that the cutter lifts up and falls, improve cutting bed cutting quality and cutting efficiency, thereby improve product quality and whole production efficiency.
In addition, the embodiment of the invention also provides a corresponding implementation device, electronic equipment and a readable storage medium for the image contour generation method, so that the method has higher practicability, and the device, the electronic equipment and the readable storage medium have corresponding advantages.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the related art, the drawings required to be used in the description of the embodiments or the related art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flowchart of an image contour generation method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an original image of a leather material to be cut according to an illustrative example provided by the embodiment of the invention;
FIG. 3 is a schematic diagram of a first illustrative single-channel image obtained after processing FIG. 2 according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a second illustrative single-channel image obtained after processing FIG. 2 according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a third illustrative single-channel image obtained after processing FIG. 2 according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a fourth illustrative single-channel image obtained after processing FIG. 2 according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a fifth illustrative single-channel image obtained after processing FIG. 2 according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a target image obtained after processing FIG. 2 according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a binary image obtained after processing fig. 8 according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of an image obtained after the region filtering process is performed on the image shown in FIG. 9 according to an embodiment of the present invention;
FIG. 11 is a schematic diagram of an initial contour image obtained after the contour extraction process is performed on the image shown in FIG. 10 according to an embodiment of the present invention;
FIG. 12 is a schematic diagram of an initial contour image obtained after the contour extraction process is performed on the image shown in FIG. 10 according to an embodiment of the present invention;
FIG. 13 is a schematic diagram of a partial enlargement at the A-sharp corner of FIG. 11 according to an embodiment of the present invention;
FIG. 14 is a partial enlarged view of the intersection B of FIG. 12 according to an embodiment of the present invention;
FIG. 15 is a schematic view of an embodiment of the present invention providing an initial profile orientation in a clockwise direction;
FIG. 16 is a schematic view of an embodiment of the present invention providing an initial profile that runs counter-clockwise;
FIG. 17 is a schematic diagram of insertion arc parameter determination in an exemplary clockwise approach provided by an embodiment of the present invention;
FIG. 18 is a schematic view of an insertion arc parameter determination in another exemplary clockwise embodiment provided by an embodiment of the present invention;
FIG. 19 is a schematic diagram of an insertion arc parameter determination in an exemplary counterclockwise approach provided by an embodiment of the present invention;
FIG. 20 is a schematic diagram illustrating insertion arc parameter determination in another exemplary embodiment of a counterclockwise approach according to an embodiment of the present invention;
FIG. 21 is a schematic diagram illustrating the determination of an insertion point into an arc according to an embodiment of the present invention;
FIG. 22 is a schematic diagram of an image obtained after smoothing of sharp corners at A in FIG. 11 according to an embodiment of the present invention;
FIG. 23 is a schematic diagram illustrating an image obtained after smoothing of sharp corners at B in FIG. 12 according to an embodiment of the present invention;
FIG. 24 is an enlarged partial view taken at A in FIG. 22 according to an embodiment of the present invention;
FIG. 25 is an enlarged partial view of FIG. 23 at B according to an embodiment of the present invention;
FIG. 26 is a block diagram of an embodiment of an apparatus for generating an image contour according to an embodiment of the present invention;
fig. 27 is a block diagram of a specific implementation of an electronic device according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may include other steps or elements not expressly listed.
Having described the technical solutions of the embodiments of the present invention, various non-limiting embodiments of the present application are described in detail below.
Referring to fig. 1, fig. 1 is a schematic flow chart of an image contour generation method according to an embodiment of the present invention, where the embodiment of the present invention may include the following:
s101: extracting an initial contour of the image to be cut, and determining the contour trend according to the numerical relationship among the pixel coordinates of each pixel point of the initial contour.
The image to be cut in this step is an image of a material to be cut by using a circular wheel knife of a cutting bed, and the material is a flexible material which needs to have a certain thickness, such as leather. The initial contour is contour information of a material to be cut, which is extracted from an image to be cut, and any contour extraction method can be adopted to extract the contour image, which does not influence the implementation of the application. The pixel points in the step refer to the pixel points on the initial contour, and the numerical relationship between the pixel point coordinates refers to the magnitude relationship between coordinate values of all the pixel points on the same coordinate axis. The profile run refers to whether the entire initial profile runs clockwise or counterclockwise.
S102: and for each section of local contour in the initial contour, 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 for the target local contour meeting the sharp-angle smooth condition.
Since the sharp corners of the initial contour need to be smoothed, it is necessary to determine whether there is a sharp corner in the initial contour, i.e. whether there is a sharp corner in a certain part of the initial contour, in order to find out each sharp corner in the initial contour, the step can divide the initial contour into a plurality of local contours, in order 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 determined whether the local contour satisfies a sharp corner smoothing condition, the so-called sharp corner smoothing condition is also a condition for determining whether there is a sharp corner in each local contour that needs to be smoothed, the sharp corner smoothing condition can be, for example, whether the angles of two line segments formed by three pixel points are smaller than a preset angle threshold, e.g. 10 °, if the angles of two line segments formed by three pixel points are smaller than the preset angle threshold, e.g. 10 °, the sharp corner is considered to need to be smoothed, namely, the condition of smoothing the sharp corner is met. If the angle of two line segments formed by the three pixel points is larger than the preset angle threshold value, for example, 10 degrees, the sharp corner does not need to be subjected to smoothing treatment, namely, the condition of smoothing the sharp corner is not met. The person skilled in the art can flexibly determine the condition of the sharp corner smoothing according to the actual situation, and the present application does not limit this. The target local contour is those of the local contours that satisfy the apical angle smoothing condition, and is referred to as a target local contour for distinction. The concavity and convexity of the target local contour means whether the target local contour is a concave curve or a convex curve.
S103: and determining the circle center and the radius of the circle where the inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circular equation and a starting point of the inserted circular arc.
The insertion of the arc in the step is a curve which is put into the initial contour in place of the target local contour, and the replacement curve is in an arc shape in order to ensure the smoothness of the initial contour. The method comprises the following steps that two line segments with sharp corners are formed by connecting pixel points of a target local contour, the circle center and the radius of a circle where an inserted circular arc is located can be determined according to pixel coordinates of each pixel point of the target local contour, after the circle center and the radius of the circle are determined, a circle equation of the circle where the inserted circular arc is located is uniquely determined, after the circle equation is determined, the circle center of the inserted maximum circular arc can be determined according to a mathematical theory, and then the starting point of the inserted circular arc can be determined.
S104: and generating an insertion arc of the target local contour according to the insertion point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour.
And after the circle where the inserted circular arc is positioned is uniquely determined in the last step, determining the concavity and convexity of the inserted circular arc and the direction of accessing the initial contour according to the trend of the contour and the concavity and convexity of the target local contour. The insertion point information may be the total number of insertion points or the distance between adjacent insertion points, and determines the smoothness of the entire insertion arc, and to some extent, the more insertion points, the smoother the insertion arc, and the smoother the entire contour. The embodiment can adjust the degree of the sharp angle to be removed and the smooth degree of the sharp angle to be removed by setting the preset angle threshold and the insertion point information, reduces the lifting and falling of the cutter in the movement process, and improves the cutting quality and efficiency.
S105: and replacing the corresponding target local contour by using the inserted circular arc of each target local contour to generate a contour image of the image to be cut.
After the corresponding inserting circular arc is generated for each target local contour by using the steps S102-S104, each inserting circular arc is used for replacing the corresponding target local contour in the initial contour, and the replaced initial contour is the contour image which is conveyed to the cutting bed to perform cutting processing on the material to be cut, namely the final material contour for cutting by the cutting bed is generated.
In the technical scheme provided by the embodiment of the invention, for the material to be cut by using the cutting bed, whether a sharp corner exists in a material outline image is firstly identified, if the sharp corner exists, a section of circular arc is adopted to replace the sharp corner, so that the outline of the whole material is smoother, the phenomenon that a cutter needs to be lifted and dropped at the sharp corner of the outline is avoided, the times of lifting and dropping the cutter can be effectively reduced, the cutting quality and the cutting efficiency of the cutting bed are improved, and the product quality and the whole production efficiency are improved.
It should be noted that, there is no strict sequential execution order among the steps in this application, and as long as a logical order is met, the steps may be executed simultaneously or according to a certain preset order, and fig. 1 is only an exemplary manner, and does not represent that only such an execution order is available.
In order to further improve the cutting quality of the cutting bed, before extracting the initial contour of the material, some preprocessing may be further performed on the material image to improve the accuracy of extracting the initial contour, that is, before S101, the method may further include:
carrying out image preprocessing on the multi-channel original image to obtain a plurality of single-channel images; performing threshold segmentation on each single-channel image, and determining a target image meeting image quality conditions based on a threshold segmentation result; performing binarization threshold segmentation on the target image to obtain a binary image; and filtering the area smaller than the preset area threshold value in the binary image to obtain the image to be cut.
In this embodiment, the corresponding material of the image to be cut may be a leather material, and correspondingly, the original image is an original leather material image, and the image may be a multi-channel image, as shown in fig. 2. The multi-channel image can be subjected to filtering operation, channel separation operation and image graying operation, so that a plurality of single-channel images are obtained, and the filtering operation can be performed by Gaussian filtering. The number of the single-channel images can be flexibly selected according to actual conditions, for example, the number of the single-channel images can be 7, and fig. 3-7 show 4 single-channel images of the multi-channel original leather images. Threshold segmentation can be performed on each single-channel image by using the maximum inter-class variance OTSU algorithm, the number of small regions included in each single-channel binary image is counted, and the smaller the number of small regions included, the better the image quality of the image is proved, that is, the image quality condition is met, and the single-channel binary image is used as a target image, as shown in fig. 8. And (3) carrying out binarization threshold segmentation on the selected target image to obtain a binary image, as shown in fig. 9, because the binary image has a plurality of small interfering regions, filtering out the small interfering regions through region area screening, and only reserving a leather region as shown in fig. 10. The preset area threshold of the embodiment can be flexibly determined according to the actual application scenario, which is not limited in this application. Taking the finally obtained image in this embodiment as the image to be cropped in S101, and extracting the initial contour of the image to be cropped, which is shown in fig. 11 and 12.
According to the embodiment, the accuracy of initial contour extraction can be improved by carrying out a series of image processing on the original image, and the improvement of the cutting quality is further facilitated.
The foregoing embodiment does not limit the condition for smoothing sharp corners and how to determine whether there are sharp corners in the initial contour for smoothing, and this embodiment also provides a corresponding embodiment, which may include:
dividing the initial contour into a plurality of sections of connected local contours; for each local contour, acquiring pixel coordinates of three adjacent pixel points of the current local contour, and calculating an included angle between a first line segment formed by the first pixel point and the second pixel point and a second line segment formed by the second pixel point and the third pixel point; if the included angle is larger than or equal to the preset angle threshold, judging that the current local contour does not meet the sharp corner smoothing condition, and directly judging the next local contour without performing smoothing processing on the local contour, namely without executing S102-S105. If the included angle is smaller than the preset angle threshold, it is determined that the current local contour meets the sharp corner smoothing condition, and the local contour of the segment needs to be smoothed, that is, S102-S105 are executed. For the pixel point at the a-sharp corner in fig. 11 and the pixel point at the B-sharp corner in fig. 12, A, B (partially enlarged as shown in fig. 13 and fig. 14) are located at the corner of the contour and have a smaller angle, i.e. a sharp corner, so that the cutting tool is lifted up first when cutting to this position, rotated by a certain angle and then dropped down for continuous cutting, and the lifting and dropping of the cutting tool will reduce the cutting efficiency and also affect the cutting quality, so that S102-S105 need to be performed to perform the sharp corner removing smoothing process.
The preset angle threshold of the embodiment can be selected according to an actual application scene, and the included angle value can be calculated according to the cosine theorem. The method for judging the local contour of the target provided by the embodiment is simple and effective.
In the above embodiment, how to execute step S102 is not limited, and this embodiment provides an optional implementation manner for determining the profile trend and the profile unevenness, in this embodiment, the initial profile trend may be referred to as a clockwise trend equal to 0, as shown in fig. 15; the initial contour run in the counterclockwise direction may be referred to as recipcity 1, as shown in fig. 16. The method specifically comprises the following steps:
as an optional implementation manner, traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points; if the coordinate value of the target pixel point on the Y coordinate axis is larger 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 smaller than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, the profile direction of the initial profile is clockwise.
In this embodiment, all points on the initial contour are traversed to find the pixel point with the maximum or minimum X coordinate value (or the maximum or minimum Y coordinate value). Taking the maximum pixel point of the X axis as an example, selecting the maximum point of the X coordinate as maxMercrentPt, and taking the coordinate as (maxMercrentPtX, maxMercrentPtY); the previous point of the maximum point is denoted as maxPreviousPt with coordinates (maxPreviousPtX, maxPreviousPtY); the latter point of the maximum point is denoted as maxNextPt with coordinates (maxnexttx, maxnextty), and the profile trend of the initial profile can be determined according to the following relation:
Figure RE-GDA0003498434410000131
taking the minimum pixel point of the X axis as an example, selecting the minimum value point of the X coordinate as minCurrentPt, and the coordinates are (minCurrentPtX, minCurrentPtY); the point preceding the minimum point is denoted as minproviouspt with coordinates (minproviousptx, minproviouspty); the next point after the minimum point is designated as minNextPt, and the coordinates are (minNextPtX, minNextPtY), the contour of the initial contour can be determined according to the following relation:
Figure RE-GDA0003498434410000132
as another implementation parallel to the above embodiment, traversing all the pixel points of the initial contour, and determining a target pixel point with the smallest coordinate value on the X coordinate axis among all the pixel points; acquiring pixel coordinates of a previous pixel point and a next pixel point of a target pixel point; if the cross product of the first vector and the second vector is less than 0, the outline trend of the initial outline is clockwise; if the cross product of the first vector and the second vector is greater than 0, the profile trend of the initial profile is in a counterclockwise trend; the first vector is formed by a target pixel point and a previous pixel point, and the second vector is formed by the target pixel point and a next pixel point.
In this embodiment, all points on the initial contour are traversed to find the point with the maximum or minimum X coordinate value (or the maximum pixel point or the minimum pixel point on the Y coordinate). Taking the minimum pixel point of the X axis as an example, selecting the minimum value point as G, and the coordinate as (minCurrentPtX, minCurrentPtY); the point preceding the minimum point is denoted as F, with coordinates (minpreviouspstx, minpreviouspy); the latter point of the minimum 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 profile trend of the initial profile can be judged according to the following relation:
Figure RE-GDA0003498434410000141
after the above embodiments are explained, the conditions 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 manner as above, and further description is omitted here.
After determining the profile trend of the initial profile, the judging method of the concave-convex property of the local profile may be: for each local contour, acquiring coordinates of three adjacent pixel points of the current local contour, forming a first directional vector by the coordinates of the initial pixel point and the coordinates of the middle pixel point, and forming a second directional vector by the coordinates of the middle pixel point and the coordinates of the tail pixel point; when the profile trend is clockwise, if the cross product of the first directional vector and the second directional vector is less than 0, the current local profile is convex; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is concave; when the profile runs counter-clockwise: if the cross product of the first directional vector and the second directional vector is less than 0, the current local contour is concave; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is convex. For example, the local contour includes three pixels A, B and C, the pixel a and the pixel B in this embodiment are not the same as the pixel a and the pixel B in fig. 11 and fig. 12, the pixels A, B and C in this embodiment are any three pixels on any local contour, and the judgment method of the concavity and convexity of the local contour may be: the cross product of the vector AB and the vector BC is cross ProductABC, and the local concavity and convexity are judged according to the trend of the profile and the positive and negative of the cross product, and the judgment relation can be as follows:
Figure RE-GDA0003498434410000151
the embodiment provides a determining mode of various profile trends and a judging mode of profile concavity and convexity, and improves the flexibility and the practicability of the whole technical scheme.
The above embodiment does not limit how to execute S103, and this embodiment also provides a selectable determination manner for the circle parameter where the arc is inserted and the parameter of the inserted arc, which may include:
acquiring adjacent first target pixel points, second target pixel points and third target pixel points on a target local contour and 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 that of the second target line segment, calculating the radius of the circle where the inserted circular 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 smaller than that of the second target line segment, calculating the radius of a circle where the inserted circular 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; simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc; calculating the center coordinates of the circle where the inserted circular arc is located according to a triangle similarity principle, and determining a circle equation according to the center coordinates and the radius of the circle where the inserted circular arc is located; and taking the point at which the minor arc corresponding to the central angle of the circle where the inserted arc is located is firstly tangent with the first target line segment or the second target line segment as the starting point of the inserted arc along the profile trend. In this embodiment, for convenience of description, the first target pixel is referred to as pixel a, the second target pixel is referred to as pixel B, and the third target pixel is referred to as pixel C, and the pixels a and B are not the same as A, B shown in fig. 11 and 12. According to the Euclidean distance formula of the two-dimensional space, the lengths distanceAB and distanceBC of the line segments AB and BC can be calculated, the sizes of the line segments AB and BC are compared, as an optional implementation mode, the radius of a circle where the insertion circular arc is located can be calculated by calling a radius calculation relational expression, and the radius calculation relational expression can be expressed as:
Figure RE-GDA0003498434410000161
wherein distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circlerradius is the radius of the circle where the circular arc is inserted, and theta is the first target lineThe angle between the segment and the second target line segment, n being a constant. The circle of the insertion arcs with different profile directions can be in the form of a circle with the center of the insertion arc being O as shown in fig. 17-20. Determining the circle O of the insertion arc1The equation: firstly, calculating the center O of the largest insertable arc, as shown in fig. 21, respectively solving the linear equations of the straight lines AB, BC, OB and OC, and the equations of the simultaneous straight lines OB and OC or OB and OA, and solving the intersection point, i.e. the center O coordinate (maxcentx, maxcenty) of the inserted arc; since the coordinates of point B, O, C are known, line segment O1C1And OC length is known, according to Δ BO1C1Similar to the delta BOC, the center O of the circle where the inserted arc is located can be calculated1Having coordinates (centerX, centerY) and determining a circle O based on the center and radius1Equation of (x-centerX)2+(y-centerY)2=circleRadius2. The method for determining the starting point of the insertion arc comprises the following steps: along the profile run, the central angle PO1C1The point where the corresponding minor arc is first tangent to the straight line AB or BC is the starting point of the insertion arc.
The above embodiment does not limit how to execute S104, and this embodiment also provides an optional generation manner of inserting an arc, which may include:
determining the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle; rotating an initial line segment determined by the circle center of the inserted arc and the starting point by taking the circle center as the center, along the trend of the outline and according to the rotating angle to obtain a plurality of rotating line segments; for each rotating line segment, determining an insertion point from the intersection point of the rotating line segment and the circle where the insertion circular arc is located based on the pixel point located at the middle position on the target contour; and generating an insertion arc of the target local contour according to the insertion points and the concave-convex property of the target local contour.
In the embodiment, the insertion point information set by the user is obtained, and if the insertion point information is the insertion point number insertionPtsNum, as shown in fig. 21, the central angle PO is bisected according to the insertion point number1C1Calculating the rotation angle of the insertion point each time, which can be expressed as bisecMangle PO1C1=angle PO1C1/insertionPtsNum. When the insertion point information is conditioned on the distance between insertion points, for example, arcLength (angle PO), the method can be implemented1C1Circlerradius calculates the arc length of the inserted arc, calculates the number of insertion points according to insertionPtsNum ═ arcLength/insertingPtsDistance, and finally calculates the rotation angle bisecAangile PO of the insertion point each time1C1=angle PO1C1/insertionPtsNum. Connected with the center of a circle O1A straight line O is obtained from the starting point P of the circular arc1P, straight line O1P is O1Centered, along the contour, each rotation of bisectAangle PO1C1Straight line of rotation O1Q and the circle O1Q, and when the number of rotations reaches the insertion point number insertionptnum, as shown in fig. 21, the insertion point acquisition is completed. Simultaneous straight line O1Equation Q and circle O1The equation yields a quadratic equation of one unity, so that there are two sets of solutions, i.e. the straight line O1Q and the circle O1With two points of intersection Q1And Q2As in FIG. 21; calculating points B and Q by using Euclidean distance formula of two-dimensional space1、Q2Distance BQ of1、BQ2Comparison of BQ1、BQ2The size, the short one of distance is the required intersection point Q coordinate, the contour after inserting the arc is as shown in fig. 22 and fig. 23, the local map at the sharp corner A, B is as shown in fig. 24 and fig. 25, and by comparing the contours before and after smoothing, it can be obviously seen that after the sharp corner is removed through the embodiment, compared with the initial contour, the finally obtained whole contour can be smoothly transited, thereby effectively improving the cutting quality and the cutting efficiency.
In order to make the technical solutions of the present application more clearly apparent to those skilled in the art, the present application also illustrates the whole technical solutions by taking the cutting of the fur material image as an example, which may include:
a1: acquiring a three-channel original image of the leather material shown in fig. 2, and performing gaussian filtering, channel separation and graying processing on the original image to generate 7 single-channel images, as shown in fig. 3-7.
A2: and (3) performing threshold segmentation on the 7 single-channel images generated in the step A1 by using an OTSU algorithm, calculating the number of areas in the segmented binary image, and performing subsequent processing by using the image with the minimum number as an image with the optimal quality, as shown in FIG. 8.
A3: the image selected in step a2 is subjected to binarization threshold segmentation to obtain a binary image, as shown in fig. 9.
A4: and D, performing region area screening on the binary image in the step A3, filtering out small regions, and only reserving a leather region to obtain a graph 10.
A5: the leather contour was extracted from the image obtained in step a4, and fig. 11 and 12 were obtained. A, B in fig. 11 and 12, which are located at the corners of the profile and have small angles (i.e., sharp corners), require a de-pointing smoothing process as follows.
A6: traversing all points on the contour, and finding out a minimum pixel point G of an X coordinate value, wherein the coordinate is (minCurrentPtX, minCurrentPtY); the point preceding the minimum point is denoted as F, with coordinates (minpreviouspstx, minpreviouspy); the latter point of the minimum point is denoted as H, with coordinates (minNextPtX, minNextPtY); the cross product of the vector FG and the vector GH is referred to as crossProductFGH, and the profile direction can be determined according to the following relational expression, where the profile direction is 0 in the clockwise direction and 1 in the counterclockwise direction.
Figure RE-GDA0003498434410000181
A7: setting a target angle targetAngle, sequentially taking 3 adjacent points A, B, C on the contour, wherein the coordinates are (pointAx, pointaay), (pointabx, pointaby), (pointacx, and pointacy), calculating an included angle theta between a straight line AB and a straight line BC by using a cosine law, and judging whether the local contour formed by the 3 points needs to be smooth or not, wherein the judgment formula is as follows:
Figure RE-GDA0003498434410000182
a8: judging A, B, C the concave-convex property of the local contour composed of three points: the cross product of the vector AB and the vector BC is recorded as cross product ABC, and the concavity and convexity of the local contour can be judged according to the following relational expression according to the trend of the contour and the positive and negative of the cross product:
Figure RE-GDA0003498434410000191
a9: determining the radius circlerradius of the circle where the insertion circular arc is located: calculating the lengths distanceAB and distanceBC of the line segments AB and BC according to a Euclidean distance formula of a two-dimensional space, comparing the sizes of the line segments AB and BC, and determining the radius of a circle where the inserted arc is located according to the following formula:
Figure RE-GDA0003498434410000192
a10: determining the circle O of the insertion arc1The equation: firstly, the center O of the largest insertable arc is found, as shown in fig. 10, the linear equations of the straight lines AB, BC, OB, OC are found respectively, the equations of the straight lines OB and OC or OB and OA are combined, and the intersection point is found to be the center O coordinate (maxcentx, maxcenty); since the coordinates of point B, O, C are known, line segment O1C1And OC length is known, according to Δ BO1C1Similar to Delta BOC, the center of circle O can be obtained1Coordinates (centerX, centerY), circle O1Is (x-centerX)2+(y-centerY)2=circleRadius2. Inserting the starting point of the circular arc: along the profile run, the central angle PO1C1The point at which the corresponding minor arc is first tangent to the straight line AB or BC is the starting point of the insertion arc.
A11: setting the number of insertion points insertionPtsNum, bisecting the central angle PO according to the number of insertion points1C1Calculating each rotation angle of the insertion point as bisectAangle PO1C1=angle PO1C1/insertionPtsNum. Connected with the center of a circle O1And the starting point P of the circular arc to obtain a straight line O1P, straight line O1P is O1Centered, along the contour, each rotation of bisectAangle PO1C1Straight line of rotation O1Q and the circle O1The intersection of (a) is Q. When the number of rotations reaches the insertion point number insertionPtsNum, the insertion point is acquiredAnd (4) finishing.
A12: simultaneous straight line O1Equation Q and circle O1The equation yields a quadratic equation of one unit having two solutions, i.e. the line O1Q and the circle O1There are two intersections. The distance between point B and the two intersection points is calculated by using the Euclidean distance formula of the two-dimensional space, the short distance is the required intersection point, and the contour after inserting the arc is shown in figures 22 and 23.
From the above, by comparing the smooth front and rear contours, it can be seen that, after the sharp corner of the original contour is removed by adopting the technical scheme provided by the embodiment, the whole contour can be smoothly transited, and the cutting is more convenient.
The embodiment of the invention also provides a corresponding device for the image contour generation method, so that the method has higher practicability. Wherein the means can be described separately from the functional module point of view and the hardware point of view. In the following, the image contour generation apparatus provided by the embodiment of the present invention is introduced, and the image contour generation apparatus described below and the image contour generation method described above may be referred to correspondingly.
Based on the angle of the functional module, referring to fig. 26, fig. 26 is a structural diagram of an image contour generation apparatus according to an embodiment of the present invention, in a specific implementation manner, the apparatus may include:
an initial contour extraction module 261, configured to extract an initial contour of the image to be cropped.
The contour direction determining module 262 is configured to determine a contour direction according to a numerical relationship between pixel coordinates of each pixel point of the initial contour.
The concavity and convexity determining module 263 is configured to determine, for each segment of the local contour in the initial contour, 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 if the target local contour satisfying the sharp-corner smoothing condition exists.
And the inserted arc parameter calculation module 264 is used for determining the circle center and the 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 a circular equation and a starting point of the inserted arc.
And the inserting arc generating module 265 is used for generating an inserting arc of the target local contour according to the inserting point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour.
And the contour generation module 266 is configured to replace the corresponding target local contour with the inserted arc of each target local contour, and generate a contour image of the image to be cropped.
Optionally, in some embodiments of this embodiment, the apparatus may further include an image preprocessing module, configured to perform image preprocessing on the multi-channel original image before extracting the initial contour of the image to be cropped, to obtain a plurality of single-channel images; performing threshold segmentation on each single-channel image, and determining a target image meeting image quality conditions based on a threshold segmentation result; performing binarization threshold segmentation on the target image to obtain a binary image; and filtering the area smaller than the preset area threshold value in the binary image to obtain the image to be cut.
As an optional implementation manner of this embodiment, the apparatus may further include a smoothing determining module, configured to divide the initial contour into multiple segments of connected local contours; for each local contour, acquiring pixel coordinates of three adjacent pixel points of the current local contour, and calculating an included angle between a first line segment formed by the first pixel point and the second pixel point and a second line segment formed by the second pixel point and the third pixel point; if the included angle is larger than or equal to a preset angle threshold value, judging that the current local contour does not meet the sharp corner smoothing condition; and if the included angle is smaller than the preset angle threshold value, judging that the current local contour meets the sharp corner smoothing condition. Optionally, in other embodiments of this embodiment, the contour direction determining module 262 may be further configured to: traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points; if the coordinate value of the target pixel point on the Y coordinate axis is larger 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 smaller than or equal to the coordinate value of the next pixel point of the target pixel point on the Y coordinate axis, the profile direction of the initial profile is clockwise.
As an optional implementation manner of this embodiment, the contour direction determining module 262 may be further configured to: traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points; acquiring pixel coordinates of a previous pixel point and a next pixel point of a target pixel point; if the cross product of the first vector and the second vector is less than 0, the outline trend of the initial outline is clockwise; if the cross product of the first vector and the second vector is greater than 0, the profile trend of the initial profile is in a counterclockwise trend; the first vector is formed by a target pixel point and a previous pixel point, and the second vector is formed by the target pixel point and a next pixel point.
As another optional implementation manner of this embodiment, the concavity and convexity determining module 263 may be configured to obtain, for each local contour, coordinates of three adjacent pixels of the current local contour, where a first directional vector is formed by the initial pixel coordinate and the middle pixel coordinate, and a second directional vector is formed by the middle pixel coordinate and the tail pixel coordinate; when the profile trend is clockwise, if the cross product of the first directional vector and the second directional vector is less than 0, the current local profile is convex; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is concave; when the profile runs counter-clockwise: if the cross product of the first directional vector and the second directional vector is less than 0, the current local contour is concave; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is convex.
As some other optional implementations of this embodiment, the insertion arc parameter calculating module 264 may be configured to: acquiring adjacent first target pixel points, second target pixel points and third target pixel points on a target local contour and 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 that of the second target line segment, calculating the radius of the circle where the inserted circular 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 smaller than that of the second target line segment, calculating the radius of a circle where the inserted circular 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; simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc; calculating the center coordinates of the circle where the inserted circular arc is located according to a triangle similarity principle, and determining a circle equation according to the center coordinates and the radius of the circle where the inserted circular arc is located; and taking the point at which the minor arc corresponding to the central angle of the circle where the inserted arc is located is firstly tangent with the first target line segment or the second target line segment as the starting point of the inserted arc along the profile trend.
As some other embodiments of this embodiment, the insertion arc parameter calculating module 264 may further be configured to: and calling a radius calculation relational expression to calculate the radius of the circle where the inserted arc is located, wherein the radius calculation relational expression is as follows:
Figure RE-GDA0003498434410000221
in the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circlerradius is the radius of the circle where the circular arc is inserted, theta 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 insertion arc generating module 265 may be further configured to: determining the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle; rotating an initial line segment determined by the circle center of the inserted arc and the starting point by taking the circle center as the center, along the trend of the outline and according to the rotating angle to obtain a plurality of rotating line segments; for each rotating line segment, determining an insertion point from the intersection point of the rotating line segment and the circle where the insertion circular arc is located based on the pixel point located at the middle position on the target contour; and generating an insertion arc of the target local contour according to the insertion points and the concave-convex property of the target local contour.
The functions of the functional modules of the image contour generation apparatus according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
Therefore, the cutting quality and the cutting efficiency of the cutting bed can be effectively improved.
The image contour generation apparatus mentioned above is described from the perspective of a functional module, and further, the present application also provides an electronic device described from the perspective of hardware. Fig. 27 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 27, the electronic apparatus includes a memory 270 for storing a computer program; a processor 271, adapted to implement the steps of the image contour generation method as mentioned in any of the above embodiments when executing the computer program.
The processor 271 may include one or more processing cores, such as a 4-core processor, an 8-core processor, the processor 271 may also be a controller, a microcontroller, a microprocessor or other data processing chip, and the like. The processor 271 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 271 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 271 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content that the display screen needs to display. In some embodiments, the processor 271 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 270 may include one or more computer-readable storage media, which may be non-transitory. Memory 270 may also include high-speed random access memory as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. The memory 270 may in some embodiments be an internal storage unit of the electronic device, such as a hard disk of a server. The memory 270 may also be an external storage device of the electronic device in other embodiments, such as a plug-in hard disk provided on a server, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 270 may also include both internal storage units and external storage devices of the electronic device. The memory 270 may be used for storing various data and application software installed in the electronic device, such as: the code of the program that executes the vulnerability handling method, etc. may also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 270 is at least used for storing a computer program 2701, wherein after being loaded and executed by the processor 271, the computer program can implement the relevant steps of the image contour generation method disclosed in any of the foregoing embodiments. In addition, the resources stored by the memory 270 may also include an operating system 2702 and data 2703, which may be stored in a transient or persistent manner. The operating system 2702 may include Windows, Unix, Linux, and the like. The data 2703 may include, but is not limited to, data corresponding to an image contour generation result, and the like.
In some embodiments, the electronic device may further include a display screen 272, an input/output interface 273, a communication interface 274, alternatively referred to as a network interface, a power supply 275, and a communication bus 276. The display 272 and the input/output interface 273 such as a Keyboard (Keyboard) belong to the user interface, and the optional user interface may also include a standard wired interface, a wireless interface, and the like. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, as appropriate, is used for displaying information processed in the electronic device and for displaying a visualized 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., typically used to establish a communication connection between an electronic device and other electronic devices. The communication bus 276 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 27, but this is not intended to represent only one bus or type of bus.
Those skilled in the art will appreciate that the configuration shown in FIG. 27 is not intended to be limiting of the electronic device and may include more or fewer components than those shown, such as a sensor 277 for performing various functions.
The functions of the functional modules of the electronic device according to the embodiments of the present invention may be specifically implemented according to the method in the above method embodiments, and the specific implementation process may refer to the description related to the above method embodiments, which is not described herein again.
Therefore, the cutting quality and the cutting efficiency of the cutting bed can be effectively improved.
It is to be understood that, if the image contour generation method in the above-described embodiment is implemented in the form of a software functional unit and sold or used as a stand-alone product, it may be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application may be substantially or partially implemented in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the methods of the embodiments of the present application, or all or part of the technical solutions. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), an electrically erasable programmable ROM, a register, a hard disk, a multimedia card, a card type Memory (e.g., SD or DX Memory, etc.), a magnetic Memory, a removable magnetic disk, a CD-ROM, a magnetic or optical disk, and other various media capable of storing program codes.
Based on this, the embodiment of the present invention further provides a readable storage medium, which stores a computer program, and the computer program is executed by a processor, and the steps of the image contour generation method according to any one of the above embodiments are provided.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. For hardware including devices and electronic equipment disclosed by the embodiment, the description is relatively simple because the hardware includes the devices and the electronic equipment correspond to the method disclosed by the embodiment, and the relevant points can be obtained by referring to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The image contour generation method, the image contour generation device and the electronic device provided by the present application are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present application.

Claims (11)

1. An image contour generation method, comprising:
extracting an initial contour of an image to be cut, and determining the contour trend according to the numerical relationship among pixel coordinates of all pixel points of the initial contour;
for each section of local contour in the initial contour, if a target local contour meeting a sharp corner smoothing condition exists, 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;
determining the circle center and the radius of a circle where an inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circle equation of the circle and a starting point of the inserted circular arc;
generating an insertion arc of the target local contour according to insertion point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour;
and replacing the corresponding target local contour with the inserted circular arc of each target local contour to generate a contour image of the image to be cropped.
2. The image contour generation method according to claim 1, wherein before extracting the initial contour of the image to be cropped, the method further comprises:
carrying out image preprocessing on the multi-channel original image to obtain a plurality of single-channel images;
performing threshold segmentation on each single-channel image, and determining a target image meeting image quality conditions based on a threshold segmentation result;
carrying out binarization threshold segmentation on the target image to obtain a binary image;
and filtering the area smaller than the preset area threshold value in the binary image to obtain the image to be cut.
3. The image contour generation method according to claim 1, wherein determining a contour trend according to a numerical relationship between pixel coordinates of each pixel point of the initial contour includes:
traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points;
and 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, the profile direction of the initial profile is clockwise.
4. The image contour generation method according to claim 1, wherein determining a contour trend according to a numerical relationship between pixel coordinates of each pixel point of the initial contour includes:
traversing all pixel points of the initial contour, and determining a target pixel point with the minimum coordinate value on an X coordinate axis in all the pixel points;
acquiring pixel coordinates of a previous pixel point and a 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 outline trend of the initial outline is clockwise; if the cross product of the first vector and the second vector is greater than 0, the profile trend of the initial profile is in a counterclockwise trend; 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, further comprising, before the target local contour satisfying the sharp corner smoothing condition exists:
dividing the initial contour into a plurality of sections of connected local contours;
for each local contour, acquiring pixel coordinates of three adjacent pixel points of the current local contour, and calculating an included angle between a first line segment formed by the first pixel point and the second pixel point and a second line segment formed by the second pixel point and the third pixel point; if the included angle is larger than or equal to a preset angle threshold value, judging that the current local contour does not meet the sharp corner smoothing condition; and if the included angle is smaller than a preset angle threshold value, judging that the current local contour meets the sharp corner smoothing condition.
6. The image contour generation method according to claim 1, wherein the determining of 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 includes:
for each local contour, acquiring coordinates of three adjacent pixel points of the current local contour, forming a first directional vector by the coordinates of the initial pixel point and the coordinates of the middle pixel point, and forming a second directional vector by the coordinates of the middle pixel point and the coordinates of the tail pixel point;
when the profile trend is clockwise, if the cross product of the first directional vector and the second directional vector is less than 0, the current local profile is convex; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is concave;
when the profile runs counter-clockwise: if the cross product of the first directional vector and the second directional vector is less than 0, the current local contour is concave; if the cross product of the first directional vector and the second directional vector is greater than 0, the current local contour is convex.
7. The image contour generation method according to claim 1, wherein the determining a center and a radius of a circle where an inserted arc is located according to pixel coordinates of each pixel point of the target local contour to determine a circle equation of the circle and a starting point of the inserted arc comprises:
acquiring adjacent first target pixel points, second target pixel points and third target pixel points on the target local contour and 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, calculating the radius of the circle where the insertion circular 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 smaller than that of the second target line segment, calculating the radius of a circle where the insertion circular 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; simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc;
calculating the circle center coordinate of the circle where the inserted circular arc is located according to a triangle similarity principle, and determining the circle equation according to the circle center coordinate and the radius of the circle where the inserted circular arc is located;
and taking a point at which a minor arc corresponding to the central angle of the circle where the inserting arc is located is firstly tangent to the first target line segment or the second target line segment as the starting point of the inserting arc along the trend of the profile.
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, the radius of the circle where the insertion arc is located is calculated 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 smaller than that of the second target line segment, calculating the radius of a circle where the insertion circular 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 simultaneously calculating the circle center coordinate and the radius of the inserted maximum circular arc comprises the following steps:
and calling a radius calculation relational expression to calculate the radius of the circle where the inserted circular arc is located, wherein the radius calculation relational expression is as follows:
Figure FDA0003324304570000041
in the formula, distanceAB is the length of the first target line segment, distanceBC is the length of the second target line segment, circlerradius is the radius of the circle where the insertion arc is located, theta is the included angle between the first target line segment and the second target line segment, and n is a constant.
9. The image contour generation method according to any one of claims 1 to 8, wherein the process of generating the insertion arc of the target local contour from the insertion point information, the start point, the circle center, and the circle equation based on the contour trend and the concavity and convexity of the target local contour includes:
determining the rotation angle of the insertion point according to the insertion point information and the angle value of the central angle;
rotating the initial line segment determined by the circle center and the starting point of the inserted circular arc along the outline trend by taking the circle center of the circle where the inserted circular arc is located as the center according to the rotating angle to obtain a plurality of rotating line segments;
for each rotating line segment, determining an insertion point from an intersection point of the rotating line segment and a circle where the insertion arc is located based on a pixel point located at the middle position on the target contour;
and generating an insertion arc of the target local contour according to each insertion point and the concavity and convexity of the target local contour.
10. An image contour generation apparatus, comprising:
the initial contour extraction module is used for extracting an initial contour of the image to be cut;
the contour direction determining module is used for determining the contour direction according to the numerical relationship among the pixel coordinates of all the pixel points of the initial contour;
the concave-convex determining module is used for determining the concave-convex of each section of local contour in the initial contour according to the contour trend and the pixel coordinates of each pixel point of the target local contour if the target local contour meeting the sharp-corner smooth condition exists;
the inserted circular arc parameter calculation module is used for determining the circle center and the radius of a circle where an inserted circular arc is located according to the pixel coordinates of each pixel point of the target local contour so as to determine a circular equation of the circle and a starting point of the inserted circular arc;
the inserting circular arc generating module is used for generating an inserting circular arc of the target local contour according to inserting point information, the starting point, the circle center and the circular equation based on the contour trend and the concavity and convexity of the target local contour;
and the contour generation module is used for replacing the corresponding target local contour with the inserted circular arc of each target local contour to generate a contour image of the leather to be processed.
11. An electronic device, comprising a processor and a memory, the processor being configured to implement the steps of the image contour generation method according to any one of claims 1 to 9 when executing a computer program stored in the memory.
CN202111257336.2A 2021-10-27 2021-10-27 Image contour generation method and device and electronic equipment Pending CN114170261A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111257336.2A CN114170261A (en) 2021-10-27 2021-10-27 Image contour generation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111257336.2A CN114170261A (en) 2021-10-27 2021-10-27 Image contour generation method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114170261A true CN114170261A (en) 2022-03-11

Family

ID=80477414

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111257336.2A Pending CN114170261A (en) 2021-10-27 2021-10-27 Image contour generation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114170261A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114693664A (en) * 2022-04-13 2022-07-01 深圳北芯生命科技股份有限公司 Method, device and medium for labeling blood vessel ultrasonic image
CN115601385A (en) * 2022-04-12 2023-01-13 北京航空航天大学(Cn) Bubble form processing method, bubble form processing apparatus, bubble form processing medium, and program product
CN115647575A (en) * 2022-12-28 2023-01-31 歌尔股份有限公司 Laser processing control method, device, equipment and storage medium
WO2023197563A1 (en) * 2022-04-13 2023-10-19 深圳北芯生命科技股份有限公司 Drawing method for adjusting delineated contour, and device and medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115601385A (en) * 2022-04-12 2023-01-13 北京航空航天大学(Cn) Bubble form processing method, bubble form processing apparatus, bubble form processing medium, and program product
CN114693664A (en) * 2022-04-13 2022-07-01 深圳北芯生命科技股份有限公司 Method, device and medium for labeling blood vessel ultrasonic image
WO2023197563A1 (en) * 2022-04-13 2023-10-19 深圳北芯生命科技股份有限公司 Drawing method for adjusting delineated contour, and device and medium
CN115647575A (en) * 2022-12-28 2023-01-31 歌尔股份有限公司 Laser processing control method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN114170261A (en) Image contour generation method and device and electronic equipment
CN110427932B (en) Method and device for identifying multiple bill areas in image
CN109670500B (en) Text region acquisition method and device, storage medium and terminal equipment
CN111275730A (en) Method, device and equipment for determining map area and storage medium
CN113989167B (en) Contour extraction method, device, equipment and medium based on seed point self-growth
CN107886516B (en) Method and computing equipment for computing hair trend in portrait
WO2023065792A1 (en) Image processing method and apparatus, electronic device, and computer-readable storage medium
US11738516B2 (en) Three dimensional model categories
CN110689492B (en) Image edge smoothing method and device
CN112017232A (en) Method, device and equipment for positioning circular pattern in image
US9317944B2 (en) Alignment of start and end of dashed curves
CN112396050B (en) Image processing method, device and storage medium
CN115170580A (en) Plate processing control method and device, computer equipment and storage medium
CN110909596A (en) Side face recognition method, device, equipment and storage medium
CN115589786A (en) Method, device and system for recognizing hand-drawn figure and computer readable storage medium
CN110598196A (en) Method and device for extracting table data missing outer frame and storage medium
CN113888546A (en) Method for arranging hand-drawn graph, electronic equipment and storage medium
US11503870B2 (en) Pattern filling in garment pieces
Park et al. Feature-aware filtering for point-set surface denoising
Mara Made in the humanities: Dual integral invariants for efficient edge detection
US10713792B1 (en) System and apparatus for image processing
US20230023611A1 (en) Method of identifying characters in images, electronic device, and storage medium
Yi et al. Geometric feature identification from topology optimization results
CN116205849A (en) Method and device for detecting number of round solid objects, electronic equipment and storage medium
KR20170047500A (en) Computing apparatus and computer program stored on computer-readable medium for detecting area of document from image

Legal Events

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