[go: up one dir, main page]

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

MATLAB-based automatic laser marking shadow generation method Download PDF

Info

Publication number
CN113096147B
CN113096147B CN202110376152.1A CN202110376152A CN113096147B CN 113096147 B CN113096147 B CN 113096147B CN 202110376152 A CN202110376152 A CN 202110376152A CN 113096147 B CN113096147 B CN 113096147B
Authority
CN
China
Prior art keywords
contour
points
boundary
shadow
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.)
Expired - Fee Related
Application number
CN202110376152.1A
Other languages
Chinese (zh)
Other versions
CN113096147A (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

本发明提供了一种基于MATLAB的激光标记阴影的自动生成方法,包括以下步骤:图形边缘数据的提取与插值处理,多边形等距偏移,建立多连通图案的等距等高线阴影填充模型,建立多连通图案的“之”字形阴影填充模型,基于等距等高线和“之”字形阴影填充方法,最终可以得到清晰、均匀、无间断点的多连通图形激光标记阴影填充。本发明构建了基于MATLAB的多连通图形等距等高线和“之”字形阴影填充方法,能够实现对多连通图形的高效、快速填充,解决了激光标记绘图程序可塑性差,计算速度慢,结果出现断点、误连、偏移次数过量等问题。

Figure 202110376152

The invention provides an automatic generation method of laser marking shadow based on MATLAB, comprising the following steps: extraction and interpolation processing of graphic edge data, polygon equidistant offset, establishment of an equidistant contour shadow filling model of multi-connected patterns, A "zigzag" shadow filling model for multi-connected patterns is established. Based on the equidistant contour lines and the "zigzag" shadow filling method, a clear, uniform, and discontinuous multi-connected graphics laser marking shadow filling can be finally obtained. The invention constructs a multi-connected graph isometric contour line and "zigzag" shadow filling method based on MATLAB, which can realize efficient and fast filling of multi-connected graphs, and solves the problem of poor plasticity of laser marking drawing programs, slow calculation speed, and results. Problems such as breakpoints, misconnections, and excessive offsets occur.

Figure 202110376152

Description

一种基于MATLAB的激光标记阴影的自动生成方法An automatic generation method of laser marking shadow based on MATLAB

技术领域technical field

本发明属于激光标记技术领域,涉及一种基于MATLAB的激光标记阴影的自动生成方法,具体来说是根据线性插值后的多连通域图形的边界坐标集合,基于多边形等距偏移和等距平行线切割算法,在MATLAB上实现对任意多连通域图形的等高线和“之”字形阴影填充,并将该功能开源化。The invention belongs to the technical field of laser marking, and relates to a method for automatically generating laser marking shadows based on MATLAB. The line cutting algorithm implements the contour line and "zigzag" shadow filling of any multi-connected domain graph on MATLAB, and makes this function open source.

背景技术Background technique

激光标记作为一种现代精密加工方法,常用于对模型或产品上文字,符号,图像等信息进行标注,与传统的腐蚀加工法和气动加工法相比,具有工件无接触,轨迹高精细,标记强耐久等优势,标记的过程中不会对环境产生污染。目前,激光标记技术已广泛用于各行各业,为优质、高效、无污染和低成本的现代加工生产开辟了广阔的前景。As a modern precision machining method, laser marking is often used to mark text, symbols, images and other information on models or products. Compared with traditional corrosion processing methods and pneumatic processing methods, laser marking has the advantages of no workpiece contact, high-precision trajectory and strong marking. Durability and other advantages, the marking process will not pollute the environment. At present, laser marking technology has been widely used in all walks of life, opening up broad prospects for high-quality, high-efficiency, pollution-free and low-cost modern processing and production.

激光标记的基本原理是在高能激光束的照射下,沿着特定的轨迹,在工件表面留下一定的熔化、汽化、加热变色等物理化学痕迹,从而实现工件表面的信息标注。激光打标机的核心系统是激光控制系统,而绘图系统又是控制系统的关键分支系统。激光标记首先要解决的问题就是对图案的二维轮廓进行识别,在此基础上生成轮廓内的一系列等距照射轨迹,激光沿轨迹照射便形成了清晰醒目的阴影标记。目前,激光标记常用的轮廓填充方案包括封闭曲线填充,对角线填充,交叉影线填充,等高线填充和之字形填充等。其中,等高线和之字形填充是最常见的两种填充方式:之字形填充的基本原理是利用等距平行线切割轮廓线形成一系列的平行线段,再将这些线段按照之字形顺序首尾相连,得到离散的激光轨迹。平行等高线填充的基本原理是利用多边形向内等距偏移,自外轮廓不断向内衍生新的子边界,直到等距等高线覆盖整个图形。实际应用中,选择何种填充方案很大程度上取决于标记材料的理化性质和标记过程对加工任务的影响。The basic principle of laser marking is that under the irradiation of a high-energy laser beam, along a specific trajectory, certain physical and chemical traces such as melting, vaporization, and heating discoloration are left on the surface of the workpiece, so as to realize the information marking on the surface of the workpiece. The core system of the laser marking machine is the laser control system, and the drawing system is the key branch system of the control system. The first problem to be solved by laser marking is to identify the two-dimensional contour of the pattern, and then generate a series of equidistant irradiation trajectories within the contour. At present, the commonly used contour filling schemes for laser marking include closed curve filling, diagonal filling, cross-hatching, contour filling and zigzag filling, etc. Among them, contour lines and zigzag filling are the two most common filling methods: the basic principle of zigzag filling is to use equidistant parallel lines to cut contour lines to form a series of parallel line segments, and then connect these line segments in zigzag order. , the discrete laser trajectories are obtained. The basic principle of parallel contour line filling is to use polygons to offset inward equidistantly, and continuously derive new sub-boundaries inward from the outer contour until the equidistant contour lines cover the entire figure. In practical applications, the choice of filling scheme largely depends on the physical and chemical properties of the marking material and the impact of the marking process on the processing task.

激光标记常见的绘图模块主要有两种:一种是机器自带的绘图软件,程序, App等,通过一定的算法自动识别物体的轮廓,颜色等特征信息,通过比对软件自带的图库,批量生成不同类型的填充阴影。优点是能在短时间内完成轨迹文件制作并上传控制中心,不仅效率高,而且实现了自动化。但最大的缺点是不能对打印对象进行实时处理,可塑性弱,比如标记镭雕LOGO等复杂图案时仍需外源软件再加工,一旦绘图软件出现故障,整个激光打标机都会停止运作,设备维修方面也必须考虑拆解组装打标机造成的成本问题和安全问题。另一种是借助外源绘图软件辅助制作阴影文件,常见的有CorelDraw,CAD等,能够在打标机外部生成阴影并规划激光轨迹,再将输出的阴影文件(通常是pdf或者jpg等图片格式)传回控制系统并执行后续操作。这类软件大多是国外研发的非开源软件,需要购买使用权,且软件内部代码无法或者很难更改,程序可塑性不高。此外,绝大多数软件对输入和输出数据的文件格式也有一定的要求,不兼容现象时常存在。当前,我国在激光标记绘图软件和程序的开发方面仍属空白,随着激光标记技术的不断推广,面向多种编程语言的阴影自动生成程序已成为潜在需求。There are two common drawing modules for laser marking: one is the drawing software, program, App, etc. that comes with the machine, which automatically recognizes the outline, color and other characteristic information of the object through a certain algorithm. Batch generate different types of fill shadows. The advantage is that the trajectory file can be produced and uploaded to the control center in a short time, which is not only efficient, but also automated. But the biggest disadvantage is that it cannot process the printed object in real time, and the plasticity is weak. For example, when marking complex patterns such as laser engraving LOGO, it still needs external software to reprocess. Once the drawing software fails, the entire laser marking machine will stop working. Equipment maintenance The cost and safety issues caused by dismantling and assembling the marking machine must also be considered. The other is to use external drawing software to assist in the production of shadow files, such as CorelDraw, CAD, etc., which can generate shadows outside the marking machine and plan the laser trajectory, and then output the shadow files (usually in pdf or jpg and other image formats) ) back to the control system and perform subsequent operations. Most of this kind of software is non-open source software developed abroad, which requires the purchase of the right to use, and the internal code of the software cannot or is difficult to change, and the program plasticity is not high. In addition, most software also have certain requirements on the file format of input and output data, and incompatibility often exists. At present, the development of laser marking software and programs in my country is still blank. With the continuous promotion of laser marking technology, automatic shadow generation programs for various programming languages have become a potential demand.

目前,激光标记阴影的自动生成模块仍以打标机自带的图形处理程序为主,暂时没有共享的开源程序,且处理速度不理想。MATLAB自带的Polygon程序包可以完成多边形的等距偏移,理论上可以实现等距等高线的阴影生成,但偏移后的多边形阴影曲线仍然存在终点位置开口,端点连接混乱,过量偏移等问题,尤其针对多连通域图形来说,仍需进一步的优化处理。之字形阴影暂无MATLAB命令可以一键生成,需要手动编程实现。总的来说,基于MATLAB等各类编程语言的激光标记阴影程序设计还有很大发展空间。At present, the automatic generation module of laser marking shadow is still mainly based on the graphics processing program that comes with the marking machine. There is no shared open source program for the time being, and the processing speed is not ideal. The Polygon package that comes with MATLAB can complete the equidistant offset of polygons. In theory, the shadow generation of equidistant contour lines can be achieved. However, the offset polygon shadow curve still has an end position opening, and the end point connection is chaotic and excessive offset. and other problems, especially for multi-connected domain graphs, further optimization is still needed. There is currently no MATLAB command that can generate zigzag shadows with one click, which requires manual programming. In general, there is still a lot of room for development of laser marking shadow programming based on various programming languages such as MATLAB.

为解决开源绘图程序短缺问题,并实现激光标记阴影的高效、快速生成,本发明引入多边形等距偏移和等距平行线切割两种算法,根据MATLAB的图形处理命令和编程特点,建立多连通域图形平行线与等高线激光标记阴影自动生成模型和程序。首先读取多连通域图形数据并将二维分辨率插值至1/5间距,通过最大次数等距偏移,去除叠边,断点识别重连和删除错位连接四个步骤实现等高线阴影的自动生成,并通过单次等距偏移,等距线切割,交点排序,奇偶边处理和非单调边去除五个步骤实现“之”字形阴影的自动生成。In order to solve the problem of shortage of open source drawing programs and realize the efficient and rapid generation of laser marking shadows, the present invention introduces two algorithms of polygon equidistant offset and equidistant parallel line cutting, and establishes multi-connectivity according to the graphics processing commands and programming characteristics of MATLAB. Domain graphics parallel lines and contour lines laser mark shading automatically generate models and programs. First, read the multi-connected domain graphic data and interpolate the two-dimensional resolution to 1/5 spacing. Through the maximum number of equidistant offsets, remove overlapping edges, breakpoint identification, reconnection, and delete dislocation connections to achieve contour shadowing The automatic generation of zigzag shadows is realized through five steps of single equidistant offset, equidistant line cutting, intersection sorting, parity edge processing and non-monotonic edge removal.

发明内容SUMMARY OF THE INVENTION

本发明解决的技术问题在于提供一种多连通域图形平行线与等高线激光标记阴影自动生成方法,并利用MATLAB开源编程语言对算法进行包装实现。The technical problem solved by the present invention is to provide an automatic generation method for laser marking shadows of multi-connected domain graphics parallel lines and contour lines, and to package and implement the algorithm by using the MATLAB open source programming language.

一种基于MATLAB的激光标记阴影的自动生成方法,包括以下步骤:An automatic generation method of laser marking shadow based on MATLAB, including the following steps:

步骤1:图形边缘数据的提取与插值处理;Step 1: Extraction and interpolation of graphic edge data;

步骤2:多边形等距偏移;Step 2: Polygon equidistant offset;

步骤3:建立等高线阴影填充模型;Step 3: Establish contour line shadow filling model;

步骤4:建立等距平行线阴影填充模型;Step 4: Create an equidistant parallel line shadow fill model;

步骤5:基于MATLAB开源编程语言进行包装实现。Step 5: Package implementation based on MATLAB open source programming language.

所述步骤1具体包括:The step 1 specifically includes:

利用MATLAB自带的Incontour或Edge函数,或者借助其他图形学方法,获取给定图形的轮廓边界坐标集,通过interp函数对边界坐标线性插值,将各个点之间的水平和垂直距离控制在偏移间距的1/4以内。Use the Incontour or Edge function that comes with MATLAB, or with the help of other graphics methods, to obtain the contour boundary coordinate set of a given graph, and linearly interpolate the boundary coordinates through the interp function to control the horizontal and vertical distances between each point at the offset. within 1/4 of the distance.

MATLAB是美国MathWorks公司出品的商业数学软件,用于数据分析、无线通信、深度学习、图像处理与计算机视觉、信号处理、量化金融与风险管理、机器人,控制系统等领域。MATLAB is a commercial mathematical software produced by MathWorks in the United States. It is used in data analysis, wireless communication, deep learning, image processing and computer vision, signal processing, quantitative finance and risk management, robotics, control systems and other fields.

所述步骤2具体包括:The step 2 specifically includes:

首先,根据轮廓边界坐标数据集求解目标轮廓的曲线方程;目标轮廓曲线实质上并不是光滑曲线,而是由多条直线首尾相连构成的多边形;在笛卡尔坐标系下,以一个简单的多边形为例,假设外轮廓上有两点坐标为(XA,YA)和(XB,YB),如图1所示,直线AB的斜率k可以表示成:First, the curve equation of the target contour is solved according to the contour boundary coordinate data set; the target contour curve is not a smooth curve in essence, but a polygon formed by multiple straight lines connected end to end; in the Cartesian coordinate system, a simple polygon is used as For example, assuming that there are two points on the outer contour whose coordinates are (XA, YA) and (XB, YB), as shown in Figure 1, the slope k of the straight line AB can be expressed as:

Figure BDA0003011236780000031
Figure BDA0003011236780000031

设直线AB的方程为:y=kx+b,将点A或点B的坐标带入直线方程,得到:Let the equation of straight line AB be: y=kx+b, put the coordinates of point A or point B into the straight line equation, we get:

Figure BDA0003011236780000032
Figure BDA0003011236780000032

因此,任意一条直线的方程可以表示为:Therefore, the equation of any line can be expressed as:

Figure BDA0003011236780000033
Figure BDA0003011236780000033

假设内轮廓上两点坐标为P1和P2,则P1P2线段就是我们需要生成的等距内轮廓线段;与直线AB相比,P1P2在Y轴上产生一个增量δb,P1P2方程为:Assuming that the coordinates of the two points on the inner contour are P 1 and P 2 , then the P 1 P 2 line segment is the equidistant inner contour line segment we need to generate; compared with the straight line AB, P 1 P 2 generates an increment δb on the Y axis , the P 1 P 2 equation is:

Figure BDA0003011236780000034
Figure BDA0003011236780000034

Figure BDA0003011236780000035
Figure BDA0003011236780000035

其中,d的符号由斜率k和x轴增量决定;把δb带回方程,P1P2方程变成:where the sign of d is determined by the slope k and the x-axis increment; bringing δb back into the equation, the P 1 P 2 equation becomes:

Figure BDA0003011236780000041
Figure BDA0003011236780000041

同理,对于另一条相邻的内轮廓线段P2P3,其与P1P2的交点为:Similarly, for another adjacent inner contour line segment P 2 P 3 , its intersection with P 1 P 2 is:

Figure BDA0003011236780000042
Figure BDA0003011236780000042

Figure BDA0003011236780000043
Figure BDA0003011236780000043

联立上述两方程得到交点坐标,连接所有交点即可得到下一阶等距偏移轮廓;在MATLAB中,该方法可以利用Polybuffer命令自动实现,而在Python、C++, Java等语言中,可以根据上述方案逐步编程实现。Simultaneously combine the above two equations to obtain the coordinates of the intersection points, and connect all the intersection points to obtain the next-order equidistant offset contour; in MATLAB, this method can be automatically implemented using the Polybuffer command, while in Python, C++, Java and other languages, it can be based on The above scheme is implemented step by step.

所述步骤3具体包括:在多边形等距偏移算法的基础上,建立等高线阴影填充模型;The step 3 specifically includes: establishing a contour shadow filling model on the basis of the polygon equidistant offset algorithm;

单连通图形的等高线填充只需要多次重复多边形等距偏移过程,直到空白区域完全被覆盖,对于多连通图形,则可以视为多个单连通图形的交集区;The contour filling of a single-connected graph only needs to repeat the polygon equidistant offset process several times until the blank area is completely covered. For a multi-connected graph, it can be regarded as the intersection area of multiple simply-connected graphs;

设最外层图形为第一层,向内依次为第二、第三层……,其中奇数层的图形向内偏移,偶数层图形向外偏移;与单连通图形相比,多连通图形的等距偏移在交点、拐点等位置容易出现中断、重叠、错位等现象,使得运算效率大幅降低,甚至产生算法漏洞;因此,多连通图形的阴影生成算法需要在单连通的基础上进一步优化;Let the outermost graph be the first layer, and the graphs of the odd-numbered layers are shifted inward, and the graphs of the even-numbered layers are shifted outward. Compared with the single-connected graphs, the multi-connected graphs The equidistant offset of the graph is prone to interruptions, overlaps, and dislocations at intersections, inflection points, etc., which greatly reduces the computational efficiency and even generates algorithm loopholes. optimization;

当AB两个单连通图形的阴影出现重叠时:When the shadows of two simply connected graphs of AB overlap:

首先,利用inpolygon函数判断同层轮廓的两条闭合阴影曲线之间的重叠部分;First, use the inpolygon function to determine the overlap between the two closed shadow curves of the same layer contour;

其次,取重叠线段的起点和终点,按照最小距离原则配对后重新连接,去除两点之间的重叠曲线;Secondly, take the start and end points of the overlapping line segments, and then reconnect them according to the principle of minimum distance to remove the overlapping curve between the two points;

之后,在复合图形的基础上做等距偏移,偏移的过程中如果图形断裂为两个或两个以上的子图形,则会在下一步分别独立进行等距偏移,不会产生相互影响,直到空白区域被完全覆盖;After that, equidistant offset is performed on the basis of the compound graph. If the graph is broken into two or more sub-graphs during the offset process, the equidistant offset will be performed independently in the next step, and there will be no mutual influence. , until the blank area is completely covered;

最后,设定阈值为偏移间距的1/3倍,检测长度超过阈值的曲线,即误连线段,并删除,最终形成完整平滑的等距等高线填充阴影。Finally, set the threshold to 1/3 of the offset spacing, detect curves whose length exceeds the threshold, that is, misconnected line segments, and delete them, and finally form a complete and smooth equidistant contour line filled with shadows.

所述步骤4具体包括:The step 4 specifically includes:

首先,根据平行线间距要求对原始坐标集进行插值,将水平和垂直分辨率保持在平行线间距的1/4以上。First, the original set of coordinates is interpolated according to the parallel line spacing requirements, keeping the horizontal and vertical resolution above 1/4 of the parallel line spacing.

然后利用等高线阴影填充模型实现外围曲线的一阶等距偏移,最后在一阶子轮廓的基础上生成“之”字平行线阴影;Then use the contour line shadow filling model to realize the first-order equidistant offset of the peripheral curve, and finally generate the "zigzag" parallel line shadow on the basis of the first-order sub-contour;

与等高线阴影填充方案不同,多连通图形的平行线阴影填充算法也适用于单连通域图形:以x方向为平行线所指方向,y方向为垂直平行线方向;利用max函数和min函数分别求图形在y方向的上边界Ymax和下边界Ymin,此时对图形边界进行适当扩充,指定Ymax+0.2*(Ymax-Ymin)为图形顶边界,Ymin-0.2*(Ymax-Ymin)为图形底边界,根据用户指定的平行线间隔,在顶底边界之间绘制等间距的平行线与子轮廓相交,并得到交点集IinterDifferent from the contour line shadow filling scheme, the parallel line shadow filling algorithm for multi-connected graphs is also suitable for single connected domain graphs: the x direction is the direction of the parallel line, and the y direction is the vertical parallel line direction; the max function and the min function are used. Find the upper boundary Y max and the lower boundary Y min of the graph in the y direction respectively. At this time, the graph boundary is appropriately expanded. Specify Y max +0.2*(Y max -Y min ) as the top boundary of the graph, Y min -0.2*( Y max -Y min ) is the bottom boundary of the graph. According to the parallel line interval specified by the user, parallel lines with equal spacing are drawn between the top and bottom boundaries to intersect with the sub-contour, and the intersection point set I inter is obtained;

然后利用Inpolygon函数判断和去掉奇数层轮廓以外、偶数层轮廓以内的线段;剩余线段中的点存储在点集Iseg中,存储时按照“之字形”的走向顺序依次排列,即奇数行从左到右排列,偶数行从右到左排列;Then use the Inpolygon function to judge and remove the line segments outside the contours of the odd-numbered layers and within the contours of the even-numbered layers; the points in the remaining line segments are stored in the point set I seg , and are arranged in the order of the "zigzag" trend during storage, that is, the odd-numbered lines are from the left. Arrange to the right, and even rows are arranged from right to left;

得到点集I,J之后,循环寻找点集J中存在y方向位移的所有相邻点,组成跳跃点集Ijump,点集Ijump所有相邻跳跃点之间的外轮廓点构成点集IboundaryAfter obtaining point sets I and J, loop to find all adjacent points in point set J that have displacement in the y-direction to form a jump point set I jump , and the outer contour points between all adjacent jump points in point set I jump form point set I boundary ;

“之字形”阴影的特点是在奇数行连接保留左边界,去掉右边界,在偶数行保留右边界,去掉左边界;The feature of the "zigzag" shadow is that the left border is reserved in odd-numbered lines, and the right border is removed, and the right border is reserved in even-numbered lines, and the left border is removed;

按此规律,首先将Iboundary中的所有点进行归类,构成同一条边的全部点归为一类;此时,由于图形轮廓可能在某一两条平行线之间发生转弯,形成不单调的弯曲线段,从而打乱了点类的奇偶排序;因此,需要对每一类点进行单调性检验,将开头两点的纵坐标之差与末尾两点的纵坐标之差相乘,若为负数,则去掉该类所有点,得到优化后的点集Iboundary-1According to this rule, all points in the I boundary are firstly classified, and all points that constitute the same edge are classified into one category; at this time, since the graph outline may turn between one or two parallel lines, it is not monotonous. Therefore, it is necessary to check the monotonicity of each type of points, and multiply the difference between the ordinates of the first two points and the difference of the ordinates of the last two points. If If the number is negative, all points of this type are removed to obtain the optimized point set I boundary-1 ;

然后,依次对Iboundary-1中的各个点类进行循环判断,若该类点属于奇数行的右边界或偶数行的左边界,则将该类的所有点其从Iboundary-1中移除;Then, cyclic judgment is performed on each point class in I boundary-1 in turn. If the point of this class belongs to the right boundary of odd-numbered rows or the left boundary of even-numbered rows, all points of this class are removed from I boundary-1 . ;

最后,将剩下的每一类点连接起来,就得到“之”字形阴影。Finally, connect each remaining class of points to get the zig-zag shadow.

所述步骤5具体包括:将两种填充方法通过MATLAB进行包装实现,图形外轮廓数据通过指定文件输入,能够兼容表格、文本文档、mat文件、数据流文件,还可以直接读取图片文件并转化为灰度值矩阵。The step 5 specifically includes: packaging the two filling methods through MATLAB, and inputting the outline data of the graph through a specified file, which can be compatible with tables, text documents, mat files, and data stream files, and can also directly read and convert image files. is the gray value matrix.

本发明实现了激光标记阴影生成程序的开源,将激光标记功能开源化使得用户可以随时根据实际情况对标记算法进行更改,提高了绘图程序的算法可塑性以及数据类型和编程语言的兼容性;实现了基于MATLAB的等高线和平行线阴影填充,算法简单易行,计算速度快,适用于所有多连通域图案的激光标记,克服了阴影曲线断点、误连、过量偏移等问题,填补了与激光打标机适配的开源程序短缺问题。本方法简单、高效,充分利用了MATLAB自带的程序功能,并且解决了传统填充曲线终点位置开口,端点误连,等距线过量偏移等问题。设计的 MATLAB开源程序适用于更复杂的图形,并可以按照其他编程语言进行改写,实现了阴影生成的开源化,为激光标记的阴影生成模块提供了更多平台选择,应用前景广泛。The invention realizes the open source of the laser marking shadow generation program, makes the laser marking function open source, enables the user to change the marking algorithm at any time according to the actual situation, improves the algorithm plasticity of the drawing program and the compatibility of data types and programming languages; Contour and parallel line shadow filling based on MATLAB, the algorithm is simple and easy to operate, the calculation speed is fast, and it is suitable for laser marking of all multi-connected domain patterns. There is a shortage of open source programs compatible with laser marking machines. The method is simple and efficient, fully utilizes the program function of MATLAB, and solves the problems of the traditional filling curve end position opening, end point misconnection, excessive offset of the equidistant line and so on. The designed MATLAB open source program is suitable for more complex graphics, and can be rewritten according to other programming languages, realizes the open source of shadow generation, provides more platform choices for the shadow generation module of laser marking, and has wide application prospects.

附图说明Description of drawings

图1为本发明步骤1图形边缘数据的提取与插值处理的等距偏移方法示意图;Fig. 1 is the schematic diagram of the equidistant offset method of extraction and interpolation processing of graphic edge data in step 1 of the present invention;

图2为本发明等距等高线填充方法在多连通图形应用时的优化方案;Fig. 2 is the optimization scheme of the equidistant contour line filling method of the present invention in the application of multi-connected graphs;

图3为本发明在1mm和0.1mm间距下的填充结果。Figure 3 shows the filling results of the present invention at 1mm and 0.1mm pitches.

具体实施方式Detailed ways

下面结合附图和实施例对本发明进行详细的描述,但并不以此作为对本申请保护范围的限定。The present invention will be described in detail below with reference to the accompanying drawings and embodiments, but this is not intended to limit the protection scope of the present application.

基于MATLAB的多连通域图形平行线与等高线激光标记阴影自动生成方法通过如下步骤进行实施:The automatic generation method of laser marking shadows for multi-connected domain graphics based on MATLAB is implemented through the following steps:

第一步:通过MATLAB自带的图形和数据读取功能,或通过其他图形边缘检测方法提取目标图案的外轮廓数据集Ioutline Step 1: Extract the outer contour dataset I outline of the target pattern through MATLAB's own graphics and data reading functions, or through other graphics edge detection methods

第二步:通过线性插值方法,将外轮廓数据集的x方向和y方向分辨率控制在0.2倍线间距以上,得到插值后的轮廓数据集Iinterp Step 2: Control the x-direction and y-direction resolutions of the outer contour data set to be more than 0.2 times the line spacing through the linear interpolation method, and obtain the interpolated contour data set I interp

第三步:多边形等距偏移Step 3: Polygon Offset Offset

根据轮廓边界坐标数据集求解目标轮廓的曲线方程。在笛卡尔坐标系下,对于任意图形,将其看作一系列直线构成的多边形,在两相邻点坐标(XA,YA) 和(XB,YB)已知的情况下,计算两点所连直线的斜率k:Solve the curve equation of the target contour based on the contour boundary coordinate data set. In the Cartesian coordinate system, for any figure, it is regarded as a polygon composed of a series of straight lines. When the coordinates of two adjacent points (X A , Y A ) and (X B , Y B ) are known, calculate The slope k of the line connecting the two points:

Figure BDA0003011236780000061
Figure BDA0003011236780000061

设AB的方程为:y=kx+b,将点A或点B的坐标带入直线方程,得到:Let the equation of AB be: y=kx+b, put the coordinates of point A or point B into the equation of the straight line, we get:

Figure BDA0003011236780000071
Figure BDA0003011236780000071

从而任意一条直线的方程可以表示为:So the equation of any straight line can be expressed as:

Figure BDA0003011236780000072
Figure BDA0003011236780000072

内轮廓上两点坐标假设为P1和P2,则P1P2线段就是我们需要生成的等距内轮廓线段。与AB线相比,P1P2在Y轴上产生一个增量δb,P1P2方程为:The coordinates of the two points on the inner contour are assumed to be P 1 and P 2 , then the P 1 P 2 line segment is the equidistant inner contour line segment that we need to generate. Compared with the AB line, P 1 P 2 produces an increment δb on the Y axis, and the equation of P 1 P 2 is:

Figure BDA0003011236780000073
Figure BDA0003011236780000073

Figure BDA0003011236780000074
Figure BDA0003011236780000074

d的符号由斜率k和x轴增量决定。把δb带回方程,P1P2方程变成:The sign of d is determined by the slope k and the x-axis increment. Bringing δb back into the equation, the P 1 P 2 equation becomes:

Figure BDA0003011236780000075
Figure BDA0003011236780000075

对于另一条相邻的内轮廓线段P2P3,其与P1P2的交点为:For another adjacent inner contour line segment P 2 P 3 , its intersection with P 1 P 2 is:

Figure BDA0003011236780000076
Figure BDA0003011236780000076

联立上述两方程得到交点坐标,连接所有交点得到下一阶等距偏移轮廓。在MATLAB中可以利用Polybuffer命令实现该算法,而在Python、C++,Java等其他编程平台上,只需根据上述步骤编程实现。Simultaneously combine the above two equations to obtain the coordinates of the intersection points, and connect all the intersection points to obtain the next-order equidistant offset contour. In MATLAB, the Polybuffer command can be used to implement the algorithm, and on other programming platforms such as Python, C++, Java, etc., it only needs to be programmed according to the above steps.

第四步:建立多连通图案的等距平行线阴影填充模型Step 4: Create an equidistant parallel line shadow fill model of a multi-connected pattern

在多边形等距偏移算法的基础上,建立等高线阴影填充模型。单连通图形的等高线填充只需要多次重复多边形等距偏移过程,直到空白区域完全被覆盖,对于多连通图形,则可以视为多个单连通图形的交集区。设最外层图形为第一层,向内依次为第二、第三层……,其中奇数层的图形向内偏移,偶数层图形向外偏移。与单连通图形相比,多连通图形的等距偏移在交点、拐点等位置容易出现中断、重叠、错位等现象,使得运算效率大幅降低,甚至产生算法漏洞。因此,多连通图形的阴影生成算法需要在单连通的基础上进一步优化。Based on the polygon equidistant offset algorithm, the contour line shadow filling model is established. The contour filling of a simply connected graph only needs to repeat the polygon equidistant offset process many times until the blank area is completely covered. Let the outermost layer of graphics be the first layer, and the inward layers are the second and third layers. Compared with single-connected graphs, the equidistant offsets of multi-connected graphs are prone to interruptions, overlaps, and dislocations at intersections and inflection points, which greatly reduces computational efficiency and even generates algorithm loopholes. Therefore, the shadow generation algorithm of multi-connected graphs needs to be further optimized on the basis of single-connectivity.

当AB两个单连通图形的阴影出现重叠时,首先,利用inpolygon函数判断同层轮廓的两条闭合阴影曲线之间的重叠部分。其次,取重叠线段的起点和终点,按照最小距离原则配对后重新连接,去除两点之间的重叠曲线。之后,在复合图形的基础上做等距偏移,偏移的过程中如果图形断裂为两个或两个以上的子图形,则会在下一步分别独立进行等距偏移,不会产生相互影响,直到空白区域被完全覆盖。最后,设定阈值为偏移间距的1/3倍,检测长度超过阈值的曲线(误连线段)并删除,最终形成完整平滑的等距等高线填充阴影。When the shadows of the two single-connected graphs of AB overlap, first, use the inpolygon function to determine the overlap between the two closed shadow curves of the contours of the same layer. Second, take the start and end points of the overlapping line segments, and then reconnect them according to the principle of minimum distance to remove the overlapping curve between the two points. After that, equidistant offset is performed on the basis of the compound graph. If the graph is broken into two or more sub-graphs during the offset process, the equidistant offset will be performed independently in the next step, and there will be no mutual influence. , until the white space is completely covered. Finally, the threshold is set to 1/3 of the offset spacing, and the curves whose length exceeds the threshold (misconnected line segments) are detected and deleted, and finally a complete and smooth equidistant contour line is filled with shadows.

第五步:建立“之”字形阴影填充模型;The fifth step: establish a "zigzag" shadow fill model;

首先利用等高线阴影填充模型实现外围曲线的一阶等距偏移,之后,以x方向为平行线所指方向,y方向为垂直平行线方向。在MATLAB中利用max函数和min 函数分别得到图形在y方向的上边界Ymax和下边界Ymin,指定Ymax+0.2*(Ymax-Ymin)为图形顶边界,Ymin-0.2*(Ymax-Ymin)为图形底边界,根据用户指定的平行线间隔,在顶底边界之间绘制等间距的平行线与子轮廓相交,并得到交点集Iinter。然后利用Inpolygon函数判断和去掉奇数层轮廓以外、偶数层轮廓以内的线段。剩余线段中的点存储在点集Iseg中,存储时按照“之字形”的走向顺序依次排列,即奇数行从左到右排列,偶数行从右到左排列。得到点集I,J之后,循环寻找点集J 中存在y方向位移的所有相邻点,组成跳跃点集Ijump,点集Ijump所有相邻跳跃点之间的外轮廓点构成点集Iboundary。最后,将Iboundary中的所有点进行归类,构成同一条边的全部点归为一类。将开头两点的纵坐标之差与末尾两点的纵坐标之差相乘,若为负数,则去掉该类所有点,得到优化后的点集Iboundary。最后,依次对Iboundary中的各个点类进行循环判断,若该类点属于奇数行的右边界或偶数行的左边界,则将该类的所有点其从Iboundary中移除。最后,将剩下的每一类点连接起来,就得到“之”字形阴影,如图3所示。First, the contour line shadow filling model is used to realize the first-order equidistant offset of the peripheral curve. Then, the x direction is the direction of the parallel line, and the y direction is the vertical parallel line direction. In MATLAB, use the max function and the min function to obtain the upper boundary Y max and the lower boundary Y min of the graph in the y direction respectively, and specify Y max +0.2*(Y max -Y min ) as the top boundary of the graph, Y min -0.2*( Y max -Y min ) is the bottom boundary of the graph. According to the parallel line interval specified by the user, parallel lines with equal spacing are drawn between the top and bottom boundaries to intersect with the sub-contour, and the intersection point set I inter is obtained. Then use the Inpolygon function to judge and remove the line segments outside the contours of odd-numbered layers and within the contours of even-numbered layers. The points in the remaining line segments are stored in the point set I seg , and are arranged in the order of the "zigzag" trend during storage, that is, the odd-numbered lines are arranged from left to right, and the even-numbered lines are arranged from right to left. After obtaining point sets I and J, loop to find all adjacent points in point set J with displacement in the y direction to form a jump point set I jump , and the outer contour points between all adjacent jump points in point set I jump form point set I boundary . Finally, all the points in the I boundary are classified, and all the points that constitute the same edge are classified into one class. Multiply the difference between the ordinates of the first two points and the difference of the ordinates of the last two points. If it is a negative number, remove all points of this type to obtain the optimized point set I boundary . Finally, cyclic judgment is performed on each point class in the I boundary in turn. If the point of this type belongs to the right boundary of the odd-numbered row or the left boundary of the even-numbered row, all points of this type are removed from the I boundary . Finally, connect each remaining class of points to get a zig-zag shadow, as shown in Figure 3.

第六步:基于MATLAB开源编程语言进行包装实现Step 6: Package implementation based on MATLAB open source programming language

将上述两种方法按照计算顺序,通过MATLAB编程语言逐步编程实现,每次循环之前都将本轮所得轮廓坐标集的空间分辨率稀疏至等距线间距的0.2倍,减少不必要的运算。图形外轮廓数据通过指定文件类型输入,兼容Excel表格、文本文档、mat矩阵数据文件、dat数据流文件等多种文件形式,还可以直接读取图片文件并转化为灰度值矩阵。输出数据也兼容上述格式。The above two methods are implemented step by step through the MATLAB programming language according to the calculation sequence. Before each cycle, the spatial resolution of the contour coordinate set obtained in this round is sparsed to 0.2 times of the equidistant line spacing to reduce unnecessary operations. The graphic outline data is input through the specified file type, which is compatible with various file forms such as Excel table, text document, mat matrix data file, dat data stream file, etc. It can also directly read the picture file and convert it into a gray value matrix. The output data is also compatible with the above formats.

最终多连通图形在1mm和0.1mm分辨率下等距等高线填充和“之”字形等距线填充效果如图3所示。图案清晰,曲线距离均等,且无断点。The final multi-connected graphics are filled with equidistant contour lines and "zigzag" equidistant lines at 1mm and 0.1mm resolutions, as shown in Figure 3. The pattern is clear, the curve distance is equal, and there are no breakpoints.

本发明构建了基于MATLAB的多连通图形等距等高线和“之”字形阴影填充方法,能够实现对多连通图形的高效、快速填充,解决了激光标记绘图程序可塑性差,计算速度慢,结果出现断点、误连、偏移次数过量等问题。The invention constructs a multi-connected graph isometric contour line and "zigzag" shadow filling method based on MATLAB, which can realize efficient and fast filling of multi-connected graphs, and solves the problem of poor plasticity of laser marking drawing programs, slow calculation speed, and results. Problems such as breakpoints, misconnections, and excessive offsets occur.

以上显示和描述了本发明的基本原理、主要特征和本发明的优点。本行业的技术人员应该了解,本发明不受上述实施例的限制,上述实施例和说明书中描述的仅为本发明的优选例,并不用来限制本发明,在不脱离本发明精神和范围的前提下,本发明还会有各种变化和改进,这些变化和改进都落入要求保护的本发明范围内。本发明要求保护范围由所附的权利要求书及其等效物界定。The foregoing has shown and described the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above-mentioned embodiments, and the above-mentioned embodiments and descriptions are only preferred examples of the present invention, and are not intended to limit the present invention, without departing from the spirit and scope of the present invention. Under the premise, the present invention will also have various changes and improvements, and these changes and improvements all fall within the scope of the claimed invention. The claimed scope of the present invention is defined by the appended claims and their equivalents.

Claims (1)

1.一种基于MATLAB的激光标记阴影的自动生成方法,包括以下步骤:1. A method for automatically generating laser marking shadows based on MATLAB, comprising the following steps: 步骤1:图形边缘数据的提取与插值处理;具体包括利用MATLAB自带的Incontour或Edge函数,获取给定图形的轮廓边界坐标集,通过interp函数对边界坐标线性插值,将各个点之间的水平和垂直距离控制在偏移间距的1/4以内;Step 1: Extraction and interpolation processing of graphic edge data; specifically, using the Incontour or Edge function that comes with MATLAB to obtain the contour boundary coordinate set of a given graphic, and linearly interpolate the boundary coordinates through the interp function. And the vertical distance is controlled within 1/4 of the offset spacing; 步骤2:多边形等距偏移;具体包括:首先,根据轮廓边界坐标数据集求解目标轮廓的曲线方程;目标轮廓曲线实质上并不是光滑曲线,而是由多条直线首尾相连构成的多边形;在笛卡尔坐标系下,以一个简单的多边形为例,设多边形上任意两相邻点的坐标为A(XA,YA),B(XB,YB),直线AB的斜率k可以表示成:Step 2: Polygon equidistant offset; specifically includes: first, solving the curve equation of the target contour according to the contour boundary coordinate data set; the target contour curve is not a smooth curve in essence, but a polygon formed by a plurality of straight lines connected end to end; In the Cartesian coordinate system, taking a simple polygon as an example, set the coordinates of any two adjacent points on the polygon to be A(XA,YA), B(XB,YB), the slope k of the straight line AB can be expressed as:
Figure FDA0003692756710000011
Figure FDA0003692756710000011
设直线AB的方程为:y=kx+b,将点A或点B的坐标带入直线方程,得到:Let the equation of straight line AB be: y=kx+b, put the coordinates of point A or point B into the straight line equation, we get:
Figure FDA0003692756710000012
Figure FDA0003692756710000012
因此,任意一条直线的方程可以表示为:Therefore, the equation of any line can be expressed as:
Figure FDA0003692756710000013
Figure FDA0003692756710000013
假设内轮廓上两点坐标为P1和P2,则P1P2线段就是我们需要生成的等距内轮廓线段;与直线AB相比,P1P2在Y轴上产生一个增量δb,P1P2方程为:Assuming that the coordinates of the two points on the inner contour are P 1 and P 2 , then the P 1 P 2 line segment is the equidistant inner contour line segment we need to generate; compared with the straight line AB, P 1 P 2 generates an increment δb on the Y axis , the P 1 P 2 equation is:
Figure FDA0003692756710000014
Figure FDA0003692756710000014
Figure FDA0003692756710000015
Figure FDA0003692756710000015
其中,d的符号由斜率k和x轴增量决定;把δb带回方程,P1P2方程变成:where the sign of d is determined by the slope k and the x-axis increment; bringing δb back into the equation, the P 1 P 2 equation becomes:
Figure FDA0003692756710000016
Figure FDA0003692756710000016
同理,对于另一条相邻的内轮廓线段P2P3,其与P1P2的交点为:Similarly, for another adjacent inner contour line segment P 2 P 3 , its intersection with P 1 P 2 is:
Figure FDA0003692756710000017
Figure FDA0003692756710000017
Figure FDA0003692756710000018
Figure FDA0003692756710000018
联立上述两方程得到交点坐标,连接所有交点即可得到下一阶等距偏移轮廓Simultaneously combine the above two equations to obtain the coordinates of the intersection point, and connect all the intersection points to obtain the next-order equidistant offset contour 步骤3:建立等高线阴影填充模型;具体包括:在多边形等距偏移算法的基础上,建立等高线阴影填充模型;Step 3: establish a contour line shadow filling model; specifically, it includes: establishing a contour line shadow filling model on the basis of the polygon equidistant offset algorithm; 单连通图形的等高线填充只需要多次重复多边形等距偏移过程,直到空白区域完全被覆盖,对于多连通图形,则可以视为多个单连通图形的交集区;The contour filling of a single-connected graph only needs to repeat the polygon equidistant offset process several times until the blank area is completely covered. For a multi-connected graph, it can be regarded as the intersection area of multiple simply-connected graphs; 设最外层图形为第一层,向内依次为第二、第三层,其中奇数层的图形向内偏移,偶数层图形向外偏移;Let the outermost layer of graphics be the first layer, and the second and third layers inward, wherein the graphics of the odd-numbered layers are shifted inward, and the graphics of the even-numbered layers are shifted outwards; 当AB两个单连通图形的阴影出现重叠时:When the shadows of two simply connected graphs of AB overlap: 首先,利用inpolygon函数判断同层轮廓的两条闭合阴影曲线之间的重叠部分;First, use the inpolygon function to determine the overlap between the two closed shadow curves of the same layer contour; 其次,取重叠线段的起点和终点,按照最小距离原则配对后重新连接,去除两点之间的重叠曲线;Secondly, take the start and end points of the overlapping line segments, and then reconnect them according to the principle of minimum distance to remove the overlapping curve between the two points; 之后,在复合图形的基础上做等距偏移,偏移的过程中如果图形断裂为两个或两个以上的子图形,则会在下一步分别独立进行等距偏移,不会产生相互影响,直到空白区域被完全覆盖;After that, equidistant offset is performed on the basis of the compound graph. If the graph is broken into two or more sub-graphs during the offset process, the equidistant offset will be performed independently in the next step, and there will be no mutual influence. , until the blank area is completely covered; 最后,设定阈值为偏移间距的1/3倍,检测长度超过阈值的曲线,即误连线段,并删除,最终形成完整平滑的等距等高线填充阴影Finally, set the threshold to 1/3 of the offset spacing, detect the curve whose length exceeds the threshold, that is, the misconnected line segment, and delete it, and finally form a complete and smooth equidistant contour line filled with shadows 步骤4:建立等距平行线阴影填充模型;具体包括首先,根据平行线间距要求对原始坐标集进行插值,将水平和垂直分辨率保持在平行线间距的1/4以上;Step 4: Establish an equidistant parallel line shadow filling model; specifically, first, interpolate the original coordinate set according to the parallel line spacing requirements, and keep the horizontal and vertical resolutions above 1/4 of the parallel line spacing; 然后利用等高线阴影填充模型实现外围曲线的一阶等距偏移,最后在一阶子轮廓的基础上生成“之”字平行线阴影;Then use the contour line shadow filling model to realize the first-order equidistant offset of the peripheral curve, and finally generate the "zigzag" parallel line shadow on the basis of the first-order sub-contour; 与等高线阴影填充方案不同,多连通图形的平行线阴影填充算法也适用于单连通域图形:以x方向为平行线所指方向,y方向为垂直平行线方向;利用max函数和min函数分别求图形在y方向的上边界Ymax和下边界Ymin,此时对图形边界进行适当扩充,指定Ymax+0.2*(Ymax-Ymin)为图形顶边界,Ymin-0.2*(Ymax-Ymin)为图形底边界,根据用户指定的平行线间隔,在顶底边界之间绘制等间距的平行线与子轮廓相交,并得到交点集IinterDifferent from the contour line shadow filling scheme, the parallel line shadow filling algorithm for multi-connected graphs is also suitable for single connected domain graphs: the x direction is the direction of the parallel line, and the y direction is the vertical parallel line direction; the max function and the min function are used. Find the upper boundary Y max and the lower boundary Y min of the graph in the y direction respectively. At this time, the graph boundary is appropriately expanded. Specify Y max +0.2*(Y max -Y min ) as the top boundary of the graph, Y min -0.2*( Y max -Y min ) is the bottom boundary of the graph. According to the parallel line interval specified by the user, parallel lines with equal spacing are drawn between the top and bottom boundaries to intersect with the sub-contour, and the intersection point set I inter is obtained; 然后利用Inpolygon函数判断和去掉奇数层轮廓以外、偶数层轮廓以内的线段;剩余线段中的点存储在点集Iseg中,存储时按照“之字形”的走向顺序依次排列,即奇数行从左到右排列,偶数行从右到左排列;Then use the Inpolygon function to judge and remove the line segments outside the contours of the odd-numbered layers and within the contours of the even-numbered layers; the points in the remaining line segments are stored in the point set I seg , and are arranged in the order of the "zigzag" trend during storage, that is, the odd-numbered lines are from the left. Arrange to the right, and even rows are arranged from right to left; 得到点集I,J之后,循环寻找点集J中存在y方向位移的所有相邻点,组成跳跃点集Ijump,点集Ijump所有相邻跳跃点之间的外轮廓点构成点集IboundaryAfter obtaining point sets I and J, loop to find all adjacent points in point set J that have displacement in the y-direction to form a jump point set I jump , and the outer contour points between all adjacent jump points in point set I jump form point set I boundary ; “之字形”阴影的特点是在奇数行连接保留左边界,去掉右边界,在偶数行保留右边界,去掉左边界;The feature of the "zigzag" shadow is that the left border is reserved in odd-numbered lines, and the right border is removed, and the right border is reserved in even-numbered lines, and the left border is removed; 按此规律,首先将Iboundary中的所有点进行归类,构成同一条边的全部点归为一类;对每一类点进行单调性检验,将开头两点的纵坐标之差与末尾两点的纵坐标之差相乘,若为负数,则去掉该类所有点,得到优化后的点集Iboundary-1According to this rule, first classify all points in the I boundary , and all points that constitute the same edge are classified into one category; perform monotonicity test on each category of points, and compare the difference between the ordinates of the first two points and the last two points. Multiply the difference between the ordinates of the points, and if it is a negative number, remove all points of this type to obtain the optimized point set I boundary-1 ; 然后,依次对Iboundary-1中的各个点类进行循环判断,若该类点属于奇数行的右边界或偶数行的左边界,则将该类的所有点其从Iboundary-1中移除;Then, cyclic judgment is performed on each point class in I boundary-1 in turn. If the point of this class belongs to the right boundary of odd-numbered rows or the left boundary of even-numbered rows, all points of this class are removed from I boundary-1 . ; 最后,将剩下的每一类点连接起来,就得到“之”字形阴影;Finally, connect each remaining class of points to get a "zigzag" shadow; 步骤5:基于MATLAB开源编程语言进行包装实现;具体包括:将两种填充模型通过MATLAB进行包装实现,图形外轮廓数据通过指定文件输入,两种填充模型为等高线阴影填充模型和等距平行线阴影填充模型,能够兼容表格、文本文档、mat文件、数据流文件,还可以直接读取图片文件并转化为灰度值矩阵。Step 5: Packaging implementation based on MATLAB open source programming language; specifically including: packaging and implementing two filling models through MATLAB, inputting graphic outline data through a specified file, and two filling models are contour line shadow filling model and equidistant parallel The line shadow filling model is compatible with tables, text documents, mat files, data flow files, and can also directly read image files and convert them into gray value matrices.
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 CN113096147A (en) 2021-07-09
CN113096147B true 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)

Families Citing this family (3)

* 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
CN113894428B (en) * 2021-09-30 2024-02-20 中国人民解放军国防科技大学 Laser filling method and device for single-layer outline pattern based on zigzag shape
CN113793352B (en) * 2021-09-30 2023-04-28 中国人民解放军国防科技大学 Laser filling method and device for single-layer outline pattern based on contour lines

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5106787B2 (en) * 2006-05-16 2012-12-26 ミヤチテクノス株式会社 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
AU2017344035A1 (en) * 2016-10-10 2019-05-02 Idemia Identity & Security USA LLC Identification document with contoured surface image
US20180264598A1 (en) * 2017-03-15 2018-09-20 General Electric Company Constantly varying hatch for additive manufacturing
CN112008248B (en) * 2020-07-29 2021-05-18 大连理工大学 Method for generating surface pattern track by laser double scanning strategy

Also Published As

Publication number Publication date
CN113096147A (en) 2021-07-09

Similar Documents

Publication Publication Date Title
CN113096147B (en) MATLAB-based automatic laser marking shadow generation method
CN104252558B (en) A kind of non-standard construction fender member digital control processing preprocess method based on BIM platform
CN110580376B (en) Revit and Dynamo-based pile foundation model creation method
CN104217063B (en) Emulation design method for steel rail rolling pass
CN102568038B (en) Method for translating dimensions on two-dimensional engineering drawing to three-dimensional CAD (computer aided design) model
CN110633518B (en) Simple parameterization unit type curtain wall material classification statistical method based on BIM
CN110428479B (en) Method for adaptively adjusting dimension marking error correction of two-dimensional engineering drawing of Solid works
CN105551077A (en) Sheet metal processing three-dimensional technological model construction method and device
CN108537892A (en) The method that threedimensional model and contextual data are automatically imported UE4
CN107168696A (en) The automatic optimization method of graphic programming control layout
CN105759724A (en) Intelligent programming method
CN105447284A (en) Technical allowance adding method
CN110705442B (en) A test paper answer automatic acquisition method, terminal equipment and storage medium
CN103631996A (en) Product structure and process parallel design method based on model maturity
CN104715092A (en) Method for rapidly building connection relation between Label and graph in hierarchical layout verification
CN108898679B (en) Automatic labeling method for serial numbers of parts
CN101458726A (en) Wire cutting program generating system and method
TWI514180B (en) System and method for processing information of measurement numbers
CN113505424B (en) Interactive construction method for derived component of linear engineering
CN104281727A (en) Method for designing tire die on basis of Excel and CAD (computer aided design) platform
CN111210520A (en) Reverse forming method and system for physical model
CN105955191B (en) A kind of method that path planning is carried out based on image feature data
CN108170641B (en) Layout method based on tolerant layering strategy
CN110705650A (en) Metal plate layout method based on deep learning
CN114781013B (en) A method for realizing avoidance arrangement of annotation characters in design drawings

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

Granted publication date: 20220729

CF01 Termination of patent right due to non-payment of annual fee