CN113096147A - MATLAB-based automatic laser marking shadow generation method - Google Patents

MATLAB-based automatic laser marking shadow generation method Download PDF

Info

Publication number
CN113096147A
CN113096147A CN202110376152.1A CN202110376152A CN113096147A CN 113096147 A CN113096147 A CN 113096147A CN 202110376152 A CN202110376152 A CN 202110376152A CN 113096147 A CN113096147 A CN 113096147A
Authority
CN
China
Prior art keywords
contour
boundary
shadow
points
line
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.)
Granted
Application number
CN202110376152.1A
Other languages
Chinese (zh)
Other versions
CN113096147B (en
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.)
National University of Defense Technology
Original Assignee
National University of Defense Technology
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 National University of Defense Technology filed Critical National University of Defense Technology
Priority to CN202110376152.1A priority Critical patent/CN113096147B/en
Publication of CN113096147A publication Critical patent/CN113096147A/en
Application granted granted Critical
Publication of CN113096147B publication Critical patent/CN113096147B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4007Scaling of whole images or parts thereof, e.g. expanding or contracting based on interpolation, e.g. bilinear interpolation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • 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/30204Marker

Landscapes

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

Abstract

The invention provides an automatic generation method of laser marking shadow based on MATLAB, which comprises the following steps: extracting and interpolating graph edge data, equidistantly shifting polygons, establishing an equidistant contour line shadow filling model of a multi-connected pattern, establishing a zigzag shadow filling model of the multi-connected pattern, and finally obtaining clear, uniform and multi-connected graph laser marking shadow filling without intermittent breakpoints based on the equidistant contour lines and the zigzag shadow filling method. The invention constructs the MATLAB-based equidistant contour line and zigzag shadow filling method of the multi-connected graph, can realize the high-efficiency and quick filling of the multi-connected graph, and solves the problems of poor plasticity, low calculation speed, breakpoint, misconnection, excessive deviation frequency and the like of a laser marking drawing program.

Description

MATLAB-based automatic laser marking shadow generation method
Technical Field
The invention belongs to the technical field of laser marking, and relates to an automatic generation method of laser marking shadows based on MATLAB, which is specifically characterized in that contour lines and zigzag shadows of any multi-connected domain graph are filled on the MATLAB based on polygon equidistant offset and equidistant parallel line cutting algorithm according to a boundary coordinate set of the multi-connected domain graph after linear interpolation, and the function is developed.
Background
The laser marking is used as a modern precision machining method, is commonly used for marking information such as characters, symbols, images and the like on a model or a product, has the advantages of no contact of a workpiece, high and fine track, strong and durable marking and the like compared with the traditional corrosion machining method and the pneumatic machining method, and does not pollute the environment in the marking process. At present, the laser marking technology is widely used in various industries, and opens up a wide prospect for modern processing production with high quality, high efficiency, no pollution and low cost.
The basic principle of laser marking is that under the irradiation of high-energy laser beams, certain physical and chemical traces such as melting, vaporization, heating discoloration and the like are left on the surface of a workpiece along a specific track, so that the information marking of the surface of the workpiece is realized. The core system of the laser marking machine is a laser control system, and the drawing system is a key branch system of the control system. The problem to be solved by laser marking is to identify the two-dimensional outline of the pattern, and then generate a series of equidistant irradiation tracks in the outline, and the laser irradiates along the tracks to form clear and striking shadow marks. Currently, outline filling schemes commonly used for laser marking include closed curve filling, diagonal filling, cross-hatch filling, contour filling, zigzag filling, and the like. Among them, contour line and zigzag filling are the most common two filling methods: the basic principle of zigzag filling is to cut contour lines with equidistant parallel lines to form a series of parallel line segments, and then connect the line segments end to end according to the zigzag sequence to obtain discrete laser tracks. The basic principle of parallel contour filling is to utilize equidistant inward shift of polygons and continuously derive new sub-boundaries inward from the outer contour until the equidistant contours cover the whole graph. In practice, the choice of which filling scheme to choose depends to a large extent on the physicochemical properties of the marking material and the effect of the marking process on the processing task.
The drawing modules commonly used for laser marking are mainly of two types: one is drawing software, a program, an App and the like which are carried by a machine, automatically identifies characteristic information such as the outline, the color and the like of an object through a certain algorithm, and generates different types of filling shadows in batches by comparing a drawing library carried by the software. The method has the advantages that the track file can be manufactured and uploaded to the control center in a short time, the efficiency is high, and automation is realized. However, the most important defects are that the printing object cannot be processed in real time, the plasticity is weak, for example, when complex patterns such as laser etching LOGO are marked, the operation of the whole laser marking machine is stopped once the drawing software fails, and the cost problem and the safety problem caused by disassembling and assembling the marking machine must be considered in the aspect of equipment maintenance. The other is to make a shadow file with the aid of external drawing software, which is commonly known as CorelDraw, CAD, etc., and can generate a shadow and plan a laser track outside the marking machine, and then send the output shadow file (usually in a picture format such as pdf or jpg) back to the control system and perform subsequent operations. Most of the software is non-open source software developed abroad, the use right needs to be purchased, the internal code of the software cannot be changed or is difficult to change, and the program plasticity is not high. In addition, most software also has certain requirements on file formats of input and output data, and incompatibility often exists. Currently, China still leaves a gap in the development of laser marking drawing software and programs, and with the continuous popularization of laser marking technology, automatic shadow generation programs oriented to various programming languages have become potential requirements.
At present, the automatic generation module of laser marking shadow still takes the image processing program carried by the marking machine as the main part, and has no shared open source program temporarily, and the processing speed is not ideal. The Polygon equidistant migration can be completed by a Polygon program package carried by MATLAB, the shadow generation of equidistant contour lines can be realized theoretically, but the polygonal shadow curve after migration still has the problems of end point position opening, disordered end point connection, excessive migration and the like, and particularly for the multi-connected domain graph, further optimization processing is still needed. The zigzag shadow tentative MATLAB command can be generated in one key and needs to be implemented manually programmed. In general, laser marking shadow programming based on various programming languages such as MATLAB has a great development space.
In order to solve the problem of shortage of open source drawing programs and realize efficient and rapid generation of laser marking shadows, the invention introduces two algorithms of polygon equidistant migration and equidistant parallel line cutting, and establishes an automatic generation model and a program of multi-connected domain graphic parallel lines and contour line laser marking shadows according to graphic processing commands and programming characteristics of MATLAB. Firstly, reading graphic data of a multi-connected domain, interpolating the two-dimensional resolution to 1/5 intervals, removing overlapped edges through maximum equidistant migration, identifying reconnection of break points and deleting staggered connection to realize automatic generation of contour line shadows, and realizing automatic generation of zigzag shadows through five steps of single equidistant migration, equidistant line cutting, intersection point sequencing, odd-even edge processing and non-monotonic edge removal.
Disclosure of Invention
The invention aims to provide a method for automatically generating laser marking shadows of parallel lines and contour lines of a multi-connected domain graph, and the method is realized by packaging an algorithm by using an MATLAB open source programming language.
An automatic generation method of laser marking shadow based on MATLAB comprises the following steps:
step 1: extracting and interpolating graphic edge data;
step 2: equally shifting the polygon;
and step 3: establishing a contour shadow filling model;
and 4, step 4: establishing an equidistant parallel line shadow filling model;
and 5: and packaging implementation is carried out based on MATLAB open source programming language.
The step 1 specifically comprises:
and acquiring a contour boundary coordinate set of a given graph by using an Incontour or Edge function of MATLAB or by using other graphical methods, and linearly interpolating the boundary coordinates through an interp function to control the horizontal and vertical distances among all points within 1/4 of an offset distance.
MATLAB is a commercial mathematical software produced by MathWorks company in America, and is used in the fields of data analysis, wireless communication, deep learning, image processing and computer vision, signal processing, quantitative finance and risk management, robots, control systems and the like.
The step 2 specifically comprises:
firstly, solving a curve equation of a target contour according to a contour boundary coordinate data set; the target contour curve is not a smooth curve in nature, but a polygon formed by connecting a plurality of straight lines end to end; in a cartesian coordinate system, taking a simple polygon as an example, assuming two coordinates (XA, YA) and (XB, YB) on the outer contour, as shown in fig. 1, the slope k of the straight line AB can be expressed as:
Figure BDA0003011236780000031
let the equation for line AB be: and y is kx + B, and the coordinates of the point A or the point B are substituted into a linear equation to obtain:
Figure BDA0003011236780000032
thus, the equation for any one line can be expressed as:
Figure BDA0003011236780000033
suppose the coordinates of two points on the inner contour are P1And P2Then P is1P2The line segments are equidistant inner contour line segments which need to be generated; and a straight lineAB phase ratio, P1P2Producing an increment δ b, P on the Y-axis1P2The equation is:
Figure BDA0003011236780000034
Figure BDA0003011236780000035
wherein the sign of d is determined by the slope k and the x-axis increment; bringing δ b back to the equation, P1P2The equation becomes:
Figure BDA0003011236780000041
similarly, for another adjacent inner contour segment P2P3Of which is in contact with P1P2The intersection point of (A) is:
Figure BDA0003011236780000042
Figure BDA0003011236780000043
combining the two equations to obtain intersection point coordinates, and connecting all the intersection points to obtain the next-order equidistant migration profile; in MATLAB, the method can be implemented automatically using the Polybuffer command, and in Python, C + +, Java, and other languages, it can be implemented by programming step by step according to the above scheme.
The step 3 specifically includes: establishing a contour line shadow filling model on the basis of a polygon equidistant migration algorithm;
the contour line filling of the single connected graph only needs to repeat the equidistant migration process of the polygon for a plurality of times until the blank area is completely covered, and the multi-connected graph can be regarded as an intersection area of a plurality of single connected graphs;
setting the outermost layer as the first layer and the second and the third layers … … inwards, wherein the patterns of the odd layers are shifted inwards and the patterns of the even layers are shifted outwards; compared with a single connected graph, the equidistant offset of the multi-connected graph is easy to have the phenomena of interruption, overlapping, dislocation and the like at the positions of intersection points, inflection points and the like, so that the operation efficiency is greatly reduced, and even algorithm loopholes are generated; therefore, the shadow generation algorithm of the multi-connected graph needs to be further optimized on the basis of single connection;
when the shadows of the AB two singly connected graphs overlap:
firstly, judging an overlapping part between two closed shadow curves of the contour of the same layer by using an inpegg function;
secondly, taking the starting point and the end point of the overlapped line segment, matching according to the minimum distance principle, and then reconnecting, and removing the overlapped curve between the two points;
then, equidistant shift is carried out on the basis of the composite graph, and if the graph is broken into two or more than two sub-graphs in the shift process, the equidistant shift can be independently carried out in the next step respectively, so that mutual influence cannot be generated until the blank area is completely covered;
and finally, setting a threshold value to be 1/3 times of the offset distance, detecting a curve with the length exceeding the threshold value, namely a misconnection line segment, deleting the curve, and finally forming a complete smooth equidistant contour line filling shadow.
The step 4 specifically includes:
first, the original coordinate set is interpolated according to the parallel line spacing requirements, keeping the horizontal and vertical resolution above 1/4 for the parallel line spacing.
Then, a contour line shadow filling model is utilized to realize first-order equidistant deviation of a peripheral curve, and finally, a character 'Z' parallel line shadow is generated on the basis of a first-order sub-contour;
different from the contour shadow filling scheme, the parallel shadow filling algorithm of the multi-connected graph is also suitable for the single-connected domain graph: taking the x direction as the direction pointed by the parallel lines, and the y direction as the direction perpendicular to the parallel lines; respectively solving the upper boundary Y of the graph in the Y direction by utilizing a max function and a min functionmaxAnd a lower boundary YminAt this time, the boundary of the graph is appropriately expanded and Y is designatedmax+0.2*(Ymax-Ymin) Is the top boundary of the graph, Ymin-0.2*(Ymax-Ymin) Drawing equidistant parallel lines between the top and bottom boundaries to intersect with the sub-outlines according to the parallel line interval specified by the user for the bottom boundary of the graph, and obtaining an intersection point set Iinter
Then judging and removing line segments outside the odd layer contour and inside the even layer contour by utilizing an Inpolygon function; the points in the remaining line segment are stored in a point set IsegDuring storage, the data are sequentially arranged according to the trend sequence of the zigzag, namely the odd rows are arranged from left to right, and the even rows are arranged from right to left;
after point sets I and J are obtained, all adjacent points with y-direction displacement in the point set J are circularly searched to form a jumping point set IjumpSet of points IjumpThe outer contour points between all the adjacent jumping points form a point set Iboundary
The zigzag shadow is characterized in that a left boundary is reserved in the odd-numbered lines in a connected mode, a right boundary is removed, a right boundary is reserved in the even-numbered lines, and the left boundary is removed;
according to the rule, firstly, I isboundaryAll the points in the image are classified, and all the points forming the same edge are classified into one class; at the moment, the figure outline may turn between one or two parallel lines to form a non-monotonous bent line segment, thereby disturbing the odd-even sequencing of the point class; therefore, it is necessary to perform monotonicity test on each kind of points, multiply the difference between the vertical coordinates of the first two points and the difference between the vertical coordinates of the last two points, and if the difference is negative, remove all the points of this kind to obtain the optimized point set Iboundary-1
Then, sequentially to Iboundary-1If the point belongs to the right boundary of the odd line or the left boundary of the even line, all the points in the class are judged from Iboundary-1Removing;
finally, connecting each remaining point type to obtain the zigzag shadow.
The step 5 specifically includes: the two filling methods are realized by packaging through MATLAB, and the graphic outline data is input through an appointed file, so that the method can be compatible with a table, a text document, a mat file and a data stream file, and can also be used for directly reading a picture file and converting the picture file into a gray value matrix.
The invention realizes the open source of the laser marking shadow generating program, and the open source of the laser marking function enables a user to change the marking algorithm at any time according to the actual situation, thereby improving the algorithm plasticity of the drawing program and the compatibility of the data type and the programming language; the method realizes the contour line and parallel line shadow filling based on MATLAB, has simple and easy algorithm and high calculation speed, is suitable for laser marking of all multi-connected domain patterns, overcomes the problems of shadow curve breakpoints, misconnection, excessive deviation and the like, and fills the problem of open source program shortage adaptive to the laser marking machine. The method is simple and efficient, makes full use of the program function of the MATLAB, and solves the problems of opening of the traditional filling curve end point position, mistaken connection of end points, excessive deviation of equidistant lines and the like. The designed MATLAB open source program is suitable for more complex graphs and can be rewritten according to other programming languages, so that the open source of shadow generation is realized, more platform choices are provided for a laser marked shadow generation module, and the application prospect is wide.
Drawings
FIG. 1 is a schematic diagram of an equidistant migration method for extracting and interpolating image edge data in step 1 according to the present invention;
FIG. 2 is an optimized scheme of the equidistant contour filling method of the present invention when a multi-connected graph is applied;
FIG. 3 shows the filling results of the present invention at 1mm and 0.1mm spacing.
Detailed Description
The present invention is described in detail below with reference to the drawings and examples, but the present invention is not limited thereto.
The MATLAB-based method for automatically generating the laser marking shadows of the parallel lines and the contour lines of the multi-connected domain graph is implemented by the following steps:
the first step is as follows: by MATLAB self-bandOr extracting the outer contour data set I of the target pattern by other graph edge detection methodsoutline
The second step is that: controlling the resolution ratio of the outer contour data set in the x direction and the y direction to be more than 0.2 time of the line spacing by a linear interpolation method to obtain an interpolated contour data set Iinterp
The third step: equidistant shift of polygon
And solving a curve equation of the target contour according to the contour boundary coordinate data set. In a Cartesian coordinate system, an arbitrary figure is considered as a polygon formed by a series of straight lines and has coordinates (X) at two adjacent pointsA,YA) And (X)B,YB) In the known case, the slope k of the straight line connecting the two points is calculated:
Figure BDA0003011236780000061
let the equation for AB be: and y is kx + B, and the coordinates of the point A or the point B are substituted into a linear equation to obtain:
Figure BDA0003011236780000071
the equation for any one line can thus be expressed as:
Figure BDA0003011236780000072
the coordinates of two points on the inner contour are assumed to be P1And P2Then P is1P2The line segments are the equidistant inner contour line segments that we need to generate. Compared with AB line, P1P2Producing an increment δ b, P on the Y-axis1P2The equation is:
Figure BDA0003011236780000073
Figure BDA0003011236780000074
the sign of d is determined by the slope k and the x-axis increment. Bringing δ b back to the equation, P1P2The equation becomes:
Figure BDA0003011236780000075
for another adjacent inner contour segment P2P3Of which is in contact with P1P2The intersection point of (A) is:
Figure BDA0003011236780000076
and (4) combining the two equations to obtain intersection point coordinates, and connecting all the intersection points to obtain the next-order equidistant migration profile. The algorithm can be realized by using a Polybuffer command in MATLAB, and can be realized by programming according to the steps on other programming platforms such as Python, C + +, Java and the like.
The fourth step: establishing equidistant parallel line shadow filling model of multi-connected pattern
And establishing a contour shadow filling model on the basis of the polygon equidistant migration algorithm. The contour filling of the single connected graph only needs to repeat the equidistant migration process of the polygon for a plurality of times until the blank area is completely covered, and the multi-connected graph can be regarded as an intersection area of a plurality of single connected graphs. Let the outermost layer pattern be the first layer and inwardly in sequence the second and third layers … …, wherein the patterns of the odd layers are offset inwardly and the patterns of the even layers are offset outwardly. Compared with a single connected graph, the equidistant offset of the multi-connected graph is easy to have the phenomena of interruption, overlapping, dislocation and the like at the positions of intersection points, inflection points and the like, so that the operation efficiency is greatly reduced, and even algorithm loopholes are generated. Therefore, the shadow generation algorithm of the multi-connected graph needs to be further optimized on the basis of single connection.
When the shadows of the AB two single connected graphs overlap, firstly, the overlapping part between the two closed shadow curves of the contour of the same layer is judged by using an inpigon function. And secondly, taking the starting point and the end point of the overlapped line segment, matching according to the minimum distance principle, and then reconnecting, and removing the overlapped curve between the two points. And then, carrying out equidistant offset on the basis of the composite graph, and if the graph is broken into two or more than two sub-graphs in the offset process, respectively and independently carrying out equidistant offset in the next step without mutual influence until the blank area is completely covered. And finally, setting a threshold value to be 1/3 times of the offset distance, detecting and deleting the curve (misconnection line segment) with the length exceeding the threshold value, and finally forming a complete and smooth equidistant contour filling shadow.
The fifth step: establishing a zigzag shadow filling model;
firstly, a contour line shadow filling model is utilized to realize first-order equidistant offset of peripheral curves, and then the direction x is taken as the direction pointed by parallel lines, and the direction y is taken as the direction vertical to the parallel lines. Respectively obtaining an upper boundary Y of the graph in the Y direction by utilizing a max function and a min function in MATLABmaxAnd a lower boundary YminSpecifying Ymax+0.2*(Ymax-Ymin) Is the top boundary of the graph, Ymin-0.2*(Ymax-Ymin) Drawing equidistant parallel lines between the top and bottom boundaries to intersect with the sub-outlines according to the parallel line interval specified by the user for the bottom boundary of the graph, and obtaining an intersection point set Iinter. And then judging and removing line segments outside the odd layer contour and inside the even layer contour by using an Inpolygon function. The points in the remaining line segment are stored in a point set IsegDuring storage, the data are sequentially arranged according to the trend sequence of the zigzag, namely the odd rows are arranged from left to right, and the even rows are arranged from right to left. After point sets I and J are obtained, all adjacent points with y-direction displacement in the point set J are circularly searched to form a jumping point set IjumpSet of points IjumpThe outer contour points between all the adjacent jumping points form a point set Iboundary. Finally, mixing IboundaryAll points in (a) are classified, and all points constituting the same edge are classified into one class. Multiplying the difference between the vertical coordinates of the first two points and the difference between the vertical coordinates of the last two points, if the difference is negative,all the points in the class are removed to obtain an optimized point set Iboundary. Finally, in sequence to IboundaryIf the point belongs to the right boundary of the odd line or the left boundary of the even line, all the points in the class are judged from IboundaryIs removed. Finally, each of the remaining points is connected to obtain a zigzag shadow, as shown in FIG. 3.
And a sixth step: packaging implementation based on MATLAB open source programming language
The two methods are realized by step-by-step programming through an MATLAB programming language according to a calculation sequence, the spatial resolution of the contour coordinate set obtained in the current round is thinned to 0.2 times of the distance between equidistant lines before each circulation, and unnecessary operation is reduced. The graphic outer contour data is input by specifying the file type, is compatible with multiple file forms such as Excel tables, text documents, mat matrix data files, dat data stream files and the like, and can also be directly read and converted into a gray value matrix. The output data is also compatible with the above format.
The resulting polylinked graph is shown in FIG. 3 for contour fill and zigzag contour fill at 1mm and 0.1mm resolutions. The pattern is clear, the curve distance is equal, and there is no breakpoint.
The invention constructs the MATLAB-based equidistant contour line and zigzag shadow filling method of the multi-connected graph, can realize the high-efficiency and quick filling of the multi-connected graph, and solves the problems of poor plasticity, low calculation speed, breakpoint, misconnection, excessive deviation frequency and the like of a laser marking drawing program.
The foregoing shows and describes the general principles, essential features, and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, and the preferred embodiments of the present invention are described in the above embodiments and the description, and are not intended to limit the present invention. The scope of the invention is defined by the appended claims and equivalents thereof.

Claims (6)

1. An automatic generation method of laser marking shadow based on MATLAB comprises the following steps:
step 1: extracting and interpolating graphic edge data;
step 2: equally shifting the polygon;
and step 3: establishing a contour shadow filling model;
and 4, step 4: establishing an equidistant parallel line shadow filling model;
and 5: and packaging implementation is carried out based on MATLAB open source programming language.
2. The method for automatically generating laser marking shadows based on MATLAB according to claim 1, wherein the step 1 specifically comprises:
and acquiring a contour boundary coordinate set of a given graph by using an Incontour or Edge function of MATLAB or by using other graphical methods, and linearly interpolating the boundary coordinates through an interp function to control the horizontal and vertical distances among all points within 1/4 of an offset distance.
3. The method for automatically generating laser marking shadows based on MATLAB according to claim 1, wherein the step 2 specifically comprises:
firstly, solving a curve equation of a target contour according to a contour boundary coordinate data set; the target contour curve is not a smooth curve in nature, but a polygon formed by connecting a plurality of straight lines end to end; in a cartesian coordinate system, taking a simple polygon as an example, assuming two coordinates (XA, YA) and (XB, YB) on the outer contour, as shown in fig. 1, the slope k of the straight line AB can be expressed as:
Figure FDA0003011236770000011
let the equation for line AB be: and y is kx + B, and the coordinates of the point A or the point B are substituted into a linear equation to obtain:
Figure FDA0003011236770000012
thus, the equation for any one line can be expressed as:
Figure FDA0003011236770000013
suppose the coordinates of two points on the inner contour are P1And P2Then P is1P2The line segments are equidistant inner contour line segments which need to be generated; compared with the straight line AB, P1P2Producing an increment δ b, P on the Y-axis1P2The equation is:
Figure FDA0003011236770000014
Figure FDA0003011236770000015
wherein the sign of d is determined by the slope k and the x-axis increment; bringing δ b back to the equation, P1P2The equation becomes:
Figure FDA0003011236770000021
similarly, for another adjacent inner contour segment P2P3Of which is in contact with P1P2The intersection point of (A) is:
Figure FDA0003011236770000022
Figure FDA0003011236770000023
and (4) combining the two equations to obtain intersection point coordinates, and connecting all the intersection points to obtain the next-order equidistant migration profile.
4. The method for automatically generating laser marking shadows based on MATLAB according to claim 1, wherein the step 3 specifically comprises: establishing a contour line shadow filling model on the basis of a polygon equidistant migration algorithm;
the contour line filling of the single connected graph only needs to repeat the equidistant migration process of the polygon for a plurality of times until the blank area is completely covered, and the multi-connected graph can be regarded as an intersection area of a plurality of single connected graphs;
setting the outermost layer as the first layer and the second and the third layers … … inwards, wherein the patterns of the odd layers are shifted inwards and the patterns of the even layers are shifted outwards;
when the shadows of the AB two singly connected graphs overlap:
firstly, judging an overlapping part between two closed shadow curves of the contour of the same layer by using an inpegg function;
secondly, taking the starting point and the end point of the overlapped line segment, matching according to the minimum distance principle, and then reconnecting, and removing the overlapped curve between the two points;
then, equidistant shift is carried out on the basis of the composite graph, and if the graph is broken into two or more than two sub-graphs in the shift process, the equidistant shift can be independently carried out in the next step respectively, so that mutual influence cannot be generated until the blank area is completely covered;
and finally, setting a threshold value to be 1/3 times of the offset distance, detecting a curve with the length exceeding the threshold value, namely a misconnection line segment, deleting the curve, and finally forming a complete smooth equidistant contour line filling shadow.
5. The method for automatically generating laser marking shadows based on MATLAB according to claim 1, wherein the step 4 specifically comprises:
first, the original coordinate set is interpolated according to the parallel line spacing requirements, keeping the horizontal and vertical resolution above 1/4 for the parallel line spacing.
Then, a contour line shadow filling model is utilized to realize first-order equidistant deviation of a peripheral curve, and finally, a character 'Z' parallel line shadow is generated on the basis of a first-order sub-contour;
different from the contour shadow filling scheme, the parallel shadow filling algorithm of the multi-connected graph is also suitable for the single-connected domain graph: taking the x direction as the direction pointed by the parallel lines, and the y direction as the direction perpendicular to the parallel lines; respectively solving the upper boundary Y of the graph in the Y direction by utilizing a max function and a min functionmaxAnd a lower boundary YminAt this time, the boundary of the graph is appropriately expanded and Y is designatedmax+0.2*(Ymax-Ymin) Is the top boundary of the graph, Ymin-0.2*(Ymax-Ymin) Drawing equidistant parallel lines between the top and bottom boundaries to intersect with the sub-outlines according to the parallel line interval specified by the user for the bottom boundary of the graph, and obtaining an intersection point set Iinter
Then judging and removing line segments outside the odd layer contour and inside the even layer contour by utilizing an Inpolygon function; the points in the remaining line segment are stored in a point set IsegDuring storage, the data are sequentially arranged according to the trend sequence of the zigzag, namely the odd rows are arranged from left to right, and the even rows are arranged from right to left;
after point sets I and J are obtained, all adjacent points with y-direction displacement in the point set J are circularly searched to form a jumping point set IjumpSet of points IjumpThe outer contour points between all the adjacent jumping points form a point set Iboundary
The zigzag shadow is characterized in that a left boundary is reserved in the odd-numbered lines in a connected mode, a right boundary is removed, a right boundary is reserved in the even-numbered lines, and the left boundary is removed;
according to the rule, firstly, I isboundaryAll the points in the image are classified, and all the points forming the same edge are classified into one class; performing monotonicity test on each point, multiplying the difference of the vertical coordinates of the first two points and the difference of the vertical coordinates of the last two points, if the difference is a negative number, removing all points of the type, and obtaining an optimized point set Iboundary-1
Then, sequentially to Iboundary-1If the point belongs to the right boundary of the odd line or the left boundary of the even line, all the points in the class are judged from Iboundary-1Removing;
finally, connecting each remaining point type to obtain the zigzag shadow.
6. The method for automatically generating laser marking shadows based on MATLAB according to claim 1, wherein the step 5 specifically comprises: the two filling methods are realized by packaging through MATLAB, and the graphic outline data is input through an appointed file, so that the method can be compatible with a table, a text document, a mat file and a data stream file, and can also be used for directly reading a picture file and converting the picture file into a gray value matrix.
CN202110376152.1A 2021-04-08 2021-04-08 MATLAB-based automatic laser marking shadow generation method Expired - Fee Related CN113096147B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110376152.1A CN113096147B (en) 2021-04-08 2021-04-08 MATLAB-based automatic laser marking shadow generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110376152.1A CN113096147B (en) 2021-04-08 2021-04-08 MATLAB-based automatic laser marking shadow generation method

Publications (2)

Publication Number Publication Date
CN113096147A true CN113096147A (en) 2021-07-09
CN113096147B CN113096147B (en) 2022-07-29

Family

ID=76675055

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110376152.1A Expired - Fee Related CN113096147B (en) 2021-04-08 2021-04-08 MATLAB-based automatic laser marking shadow generation method

Country Status (1)

Country Link
CN (1) CN113096147B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113793352A (en) * 2021-09-30 2021-12-14 中国人民解放军国防科技大学 Laser filling method and device of single-layer contour pattern based on contour line
CN113878254A (en) * 2021-09-29 2022-01-04 江苏铁锚玻璃股份有限公司 Drawing method and drawing graph for special-shaped glass laser etching and film removing pattern
CN113894428A (en) * 2021-09-30 2022-01-07 中国人民解放军国防科技大学 Laser filling method and device of single-layer profile pattern based on zigzag

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007307723A (en) * 2006-05-16 2007-11-29 Miyachi Technos Corp Laser marking method and apparatus
GB2520945A (en) * 2013-12-03 2015-06-10 Spi Lasers Uk Ltd Method for laser marking an anodized metal surface with a desired colour
WO2018169630A1 (en) * 2017-03-15 2018-09-20 General Electric Company Constantly varying hatch for additive manufacturing
CN110290930A (en) * 2016-10-10 2019-09-27 艾迪密身份与安全美国有限责任公司 Mark document with contour surface image
CN112008248A (en) * 2020-07-29 2020-12-01 大连理工大学 Method for generating surface pattern track by adopting laser double-scanning strategy

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007307723A (en) * 2006-05-16 2007-11-29 Miyachi Technos Corp Laser marking method and apparatus
GB2520945A (en) * 2013-12-03 2015-06-10 Spi Lasers Uk Ltd Method for laser marking an anodized metal surface with a desired colour
CN110290930A (en) * 2016-10-10 2019-09-27 艾迪密身份与安全美国有限责任公司 Mark document with contour surface image
WO2018169630A1 (en) * 2017-03-15 2018-09-20 General Electric Company Constantly varying hatch for additive manufacturing
CN112008248A (en) * 2020-07-29 2020-12-01 大连理工大学 Method for generating surface pattern track by adopting laser double-scanning strategy

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
DALIN HUANG 等;: "《Laser Marking Hatch Contour Generation》", 《ASSOCIATION FOR COMPUTING MACHINERY》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113878254A (en) * 2021-09-29 2022-01-04 江苏铁锚玻璃股份有限公司 Drawing method and drawing graph for special-shaped glass laser etching and film removing pattern
CN113793352A (en) * 2021-09-30 2021-12-14 中国人民解放军国防科技大学 Laser filling method and device of single-layer contour pattern based on contour line
CN113894428A (en) * 2021-09-30 2022-01-07 中国人民解放军国防科技大学 Laser filling method and device of single-layer profile pattern based on zigzag
CN113793352B (en) * 2021-09-30 2023-04-28 中国人民解放军国防科技大学 Laser filling method and device for single-layer outline pattern based on contour lines
CN113894428B (en) * 2021-09-30 2024-02-20 中国人民解放军国防科技大学 Laser filling method and device for single-layer outline pattern based on zigzag shape

Also Published As

Publication number Publication date
CN113096147B (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN113096147B (en) MATLAB-based automatic laser marking shadow generation method
CN110428479B (en) Method for adaptively adjusting dimension marking error correction of two-dimensional engineering drawing of Solid works
JP6250901B2 (en) A robot system in which a CNC and a robot controller are connected via a communication network
CN106528937B (en) System and method for avoiding label information overlapping based on PDMS (polydimethylsiloxane) map
CN109241555B (en) Multi-primitive Gerber file analyzing and drawing method for improving drawing precision
Behera et al. Tool path generation for single point incremental forming using intelligent sequencing and multi-step mesh morphing techniques
CN110795835A (en) Three-dimensional process model reverse generation method based on automatic synchronous modeling
CN115861368A (en) Multi-class contour tracking method, device and medium for multi-class images
CN116737301A (en) Alignment method and device for layer elements
CN105447284A (en) Technical allowance adding method
CN101458726A (en) Wire cutting program generating system and method
Shah et al. From Deterministic to Data-Driven: AI and Machine Learning for Next-Generation Production Line Optimization
CN110705650B (en) Sheet metal layout method based on deep learning
CN105759724A (en) Intelligent programming method
CN117292141A (en) Automatic identification method and system for processing characteristics based on three-dimensional convolutional neural network
CN101739497A (en) Method for automatically computing figure labeling position
CN116541912A (en) Method and device for generating wiring diagram based on CAD image recognition
CN114186298B (en) Intelligent mechanical part manufacturing and operating method and system
CN110348163B (en) Fitting method for continuous tangent circular arc of tire pattern boundary
US10902170B2 (en) Method for computer assisted planning of a technical system
CN102012691A (en) Mechanical line-cutting data processing method, device and system based on UG (Unigraphics) platform
CN111260723B (en) Barycenter positioning method of bar and terminal equipment
CN114694159A (en) Engineering drawing BOM identification method and device, electronic equipment and storage medium
Shen et al. A parameterized automatic programming solution for composite grinding based on digital image processing
Atia Classification and elimination of overlapped entities in DXF files

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
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20220729