Laser engraving image vectorization methods, devices, and software products
By identifying and breaking intersections, recombining pixel chains, and performing cubic B-spline fitting, the problems of overheating and uneven lines in laser engraving of silk fabric were solved, achieving overheat protection and smooth lines in laser engraving.
Patent Information
- Application Number
- CN202610095105.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-23
- Publication Date
- 2026-05-26
AI Technical Summary
When using existing laser engraving technology to draw embroidery patterns, silk fabric is easily overburned and damaged due to the accumulation of laser energy, and the lines are generated with harsh jagged edges, resulting in an uneven drawing process.
By extracting the skeleton image, identifying and breaking the intersections, reconstructing the pixel chain, and using cubic B-spline fitting to generate a vector image, combined with super-resolution resampling and bilateral filtering, a vector image without intersections is generated.
It effectively avoids overheating damage to the silk fabric during laser engraving, improves the smoothness and consistency of the lines, and ensures the smoothness of laser engraving.
Smart Images

Figure CN122089874A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing and computer-aided manufacturing technology, specifically relating to a method, apparatus, and program product for vectorizing laser-engraved images. Background Technology
[0002] In the embroidery industry, before officially starting the embroidery, it is usually necessary to draw a line draft on the fabric. The traditional method for this is mainly to rely on hand drawing or copying, but hand drawing is extremely inefficient and it is difficult to guarantee the smoothness and consistency of the lines.
[0003] With the rise of laser engraving technology, it has become possible to transfer the above-mentioned drafting work to machines. First, the draft image is converted into a DXF format vector image and input into the laser marking machine. Then, the draft pattern is drawn on the silk fabric by laser marking.
[0004] However, existing image-to-vector algorithms (such as simple contour tracking algorithms) often generate stiff, jagged lines, causing the laser trajectory to jitter. Furthermore, silk is an extremely thin material and is highly sensitive to heat (heat-sensitive fabric); complex embroidery patterns often contain numerous intersecting lines. During laser marking, these intersections are repeatedly swept by the laser beam; combined with the acceleration and deceleration process in laser path planning, the energy accumulation at these intersections increases significantly. Ultimately, these multiple factors make the silk fabric at the intersections prone to burning through, yellowing, or carbonizing, directly leading to fabric damage. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a laser engraving image vectorization method, apparatus, and program product to solve the problem of fabric overheating in the creation of embroidery draft images using laser engraving.
[0006] The present invention achieves the above-mentioned technical objectives through the following technical means.
[0007] A method for vectorizing laser-engraved images includes:
[0008] Step 1: Extract the skeleton map from the target image;
[0009] Step 2: Break the lines at their intersections in the skeleton diagram;
[0010] Step 3: Extract the pixel chains of each independent connected region from the broken skeleton graph;
[0011] Step 4, Pixel Chain Reorganization: Merge pixel chains that meet the following conditions:
[0012] The distance between the endpoints of two pixel chains is less than the distance threshold, and the lines between these two endpoints are collinear. and gap continuity It also meets the preset range requirements;
[0013] Step 5: Fit the recombined pixel chains to generate a vector image.
[0014] Furthermore, in step 4, the collinearity of the lines... and gap continuity The calculation is as follows:
[0015]
[0016]
[0017] In the formula, and They are respectively and The unit tangent vector at the two points, For the reason point to unit vector, and The two endpoints where the spacing is less than the threshold.
[0018] Furthermore, in step 4, the preset range requirement is as follows: and , This is the alignment threshold.
[0019] Further, in step 4, the spacing threshold is 12 pixels, and the alignment threshold... It is 0.6.
[0020] Further, step 1 includes:
[0021] Step 1.1, Super-resolution resampling: The entered target image is magnified using a bicubic interpolation algorithm;
[0022] Step 1.2, edge-preserving denoising: The magnified image is denoised by bilateral filtering, where the standard deviation of the spatial Gaussian function and the standard deviation of the gray value similarity are set to 75.
[0023] Step 1.3, Binarization: Perform binarization processing on the denoised image;
[0024] Step 1.4, Morphological Restoration: Perform morphological closing operation on the binarized image using elliptical structuring elements;
[0025] Step 1.5, Centerline skeleton extraction: The morphologically repaired binary image is iteratively eroded using a thinning algorithm until all foreground regions are reduced to a centerline skeleton line of a single pixel width.
[0026] Further, step 2 includes:
[0027] Step 2.1, Intersection point identification: Perform convolution operation on the skeleton map using a 3×3 all-1 convolution kernel to obtain the number of eight neighboring pixels of each skeleton pixel. Points with more than 2 eight neighboring pixels are identified as intersection points.
[0028] Step 2.2, Topology Break: Construct a mask containing all intersection points, and perform a morphological dilation operation on the mask, wherein the range is set to 1~2 pixels; in the original skeleton map, set the pixel value of the corresponding mask region to 0.
[0029] Furthermore, step 3 includes:
[0030] Step 3.1, Connected Component Analysis and Noise Removal: For the broken skeleton graph, a connected component labeling algorithm is used to count the number of pixels in each connected component and remove connected components with a pixel count lower than a preset threshold.
[0031] Step 3.2, Pixel sorting: For each retained connected component, calculate its geometric centroid, select the pixel farthest from the centroid as the starting point, and then use a greedy search algorithm to search for the next unvisited pixel in the eight neighborhoods of each pixel in the connected component, starting from the starting point, in order to generate a pixel chain.
[0032] Furthermore, step 5 includes:
[0033] Step 5.1, Sparsification: For each pixel chain, calculate the distance between adjacent pixels and remove redundant points with a spacing smaller than the sampling threshold;
[0034] Step 5.2, Global Cubic B-Spline Fitting: Based on the sparsed pixel chain, the pixels in it are used as control points, and spline curves are generated through the cubic B-spline algorithm;
[0035] Step 5.3, Vector Output: Resample the fitted spline curve to generate a smooth polyline, and map the pixel coordinates back to the original image size to generate a vector graphic.
[0036] A computer device, including a memory and a processor;
[0037] The memory is used to store computer programs;
[0038] The processor is used to execute the computer program and, in executing the computer program, implement the laser-engraved image vectorization method described above.
[0039] A computer program product includes a computer program that, when executed by a processor, implements the above-described laser-engraved image vectorization method.
[0040] The beneficial effects of this invention are as follows:
[0041] (1) The present invention provides a method for vectorizing laser engraved images. By creating a physical “break” at all line intersections, the laser head is temporarily shut off when it reaches this point, and then emits light again after passing the intersection by inertia. In this way, energy superposition is eliminated, and the silk fabric is protected from overheating damage, thus achieving overheat protection for the laser engraved draft of the silk fabric.
[0042] (2) The present invention combines super-resolution resampling and cubic B-spline fitting to transform lines with pixel jaggedness in the original image into mathematically smooth curves, thereby improving the smoothness of subsequent laser engraving.
[0043] (3) The present invention introduces an intelligent judgment mechanism based on tangent vectors, which merges only broken line segments with collinear geometric trends, while retaining the physical disconnection state of cross / T-shaped intersections. While ensuring the extremely smooth lines, it perfectly solves the contradiction between "overburning of intersection points" and "disconnection of broken lines" in laser processing. Attached Figure Description
[0044] Figure 1 This is a flowchart of the laser engraving image vectorization method of the present invention;
[0045] Figure 2 This is a comparison of laser marking based on the present invention and vector graphics generated by conventional methods;
[0046] Figure 3 for Figure 2 A magnified view of the laser marking pattern implemented using the method of this invention on the left side;
[0047] Figure 4 for Figure 2 The image on the right is a magnified portion of the laser marking image performed using conventional methods. Detailed Implementation
[0048] The embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, but should not be construed as limiting the present invention.
[0049] I. Laser Engraving Image Vectorization Method
[0050] Reference Figure 1 As shown, the steps of the laser-engraved image vectorization method of the present invention are as follows:
[0051] Step 1, Image Preprocessing and Skeletonization
[0052] This involves extracting subpixel-level line information from the original bitmap (usually a PNG or JPG line drawing), including:
[0053] Step 1.1, Super-resolution resampling: The original image is magnified using a bicubic interpolation algorithm (specifically magnified by 2 times in this embodiment). This transforms the original 1-pixel-wide "hard jagged edges" into a multi-pixel-wide grayscale transition band, providing sub-pixel-level geometric accuracy for subsequent algorithms and significantly reducing quantization noise.
[0054] Step 1.2, Edge Preservation and Denoising: The magnified image is denoised using bilateral filtering; the standard deviation of the spatial Gaussian function and the standard deviation of the grayscale similarity are set to 75. Unlike conventional Gaussian blur, bilateral filtering here can smooth the background noise of the fabric texture while maintaining the gradient steepness of the line edges, preventing fine lines from blurring and disappearing.
[0055] Step 1.3, Binarization: The denoised image is binarized using an adaptive thresholding algorithm, which dynamically calculates the binarization threshold for each pixel based on the pixel distribution in the local area of the image.
[0056] Step 1.4, Morphological Repair: Use elliptical structuring elements to perform morphological closing operations on the binarized image to automatically connect tiny broken lines in the image and fill in the holes inside the lines.
[0057] Step 1.5, centerline skeleton extraction: Use a thinning algorithm (such as the Zhang-Suen algorithm) to iteratively erode the morphologically repaired binary image until all foreground areas are reduced to a centerline skeleton line of a single pixel width, and extract the skeleton image of the draft in this way.
[0058] Step 2, break at the intersection
[0059] To solve the problem of "repeated burning at intersections" in the laser processing process, this embodiment forcibly breaks all complex intersection structures in the skeleton diagram through the following steps.
[0060] Step 2.1, Intersection point identification: Construct a 3×3 all-1 convolution kernel and perform convolution operation on the skeleton map. Calculate the number of pixels in the eight-neighborhood (i.e., the eight pixels surrounding each target pixel) of each skeleton pixel in this way. If the number of pixels in the eight-neighborhood of a skeleton pixel is greater than 2, then the skeleton pixel is determined to be an intersection point.
[0061] Step 2.2, Topology Breaking: Construct a mask containing all intersections, and perform a morphological dilation operation on the mask, with the range set to 1~2 pixels; in the original skeleton image, set the pixel values of the corresponding mask regions to 0 (i.e., background color). Through the above processing, the originally mesh-connected skeleton is physically divided into several independent line segments that are not connected to each other. At this time, all "cross" or "T" intersections in the skeleton image are in a broken state.
[0062] Step 3, Pixel chain extraction
[0063] It is used to convert discrete pixels in a skeleton diagram into an ordered sequence of coordinates that can be processed by a computer.
[0064] Step 3.1, Connected Component Analysis and Noise Removal: For the broken skeleton graph, a connected component labeling algorithm is used to count the number of pixels in each connected component and remove connected components with a pixel count lower than a preset threshold. In this embodiment, the threshold is set to 4 to cooperate with the previous super-resolution resampling, so as to retain as many short effective lines as possible while removing noise and to recover details that are easily lost by traditional algorithms.
[0065] Step 3.2, Pixel sorting: For each retained connected component, calculate its geometric centroid and select the pixel farthest from the centroid as the starting point. Then, using a greedy search algorithm, starting from the starting point, search for the next unvisited pixel in the eight-neighborhood of each pixel in the connected component until the end, thus generating an ordered coordinate sequence (i.e., pixel chain).
[0066] Step 4, pixel chain reassembly
[0067] Used to repair "unnecessary interruptions" and retain the remaining "necessary interruptions".
[0068] Step 4.1: Extract the endpoints of each pixel chain and calculate the Euclidean distance between the endpoints of different pixel chains. If the distance between the endpoints of two pixel chains is less than a preset threshold (set to 12 pixels in this embodiment), then this pair of endpoints is considered a candidate for merging. For ease of description, let the two endpoints be denoted as... and .
[0069] Step 4.2: For each candidate merge pair, calculate the line collinearity between the two endpoints. and gap continuity :
[0070]
[0071]
[0072] In the formula, and They are respectively and The unit tangent vector at two points is the unit vector of the tangent direction of the line in the pixel chain at that endpoint. Specifically, the endpoint ( or The calculation is performed using a point that extends 5 pixels inward from the line as a reference point. For the reason point to The unit vector.
[0073] The smoother the connection between the two pixel chains, the better. The closer to -1; the closer the gap between the two endpoints is to -1. On the extension of the line, then The closer it is to 1, the better. Therefore, an alignment threshold is set. (In this embodiment, the specific value is 0.6). If the candidate merging pairs satisfy: and If so, the candidate merge pair is determined to be a pair to be merged.
[0074] Step 4.3: For the selected pairs to be merged, splice the two pixel chains containing the two endpoints to merge them into a new pixel chain. Note: This does not merge the two endpoints into one point, but rather merges the pixels of the two pixel chains into a new pixel chain.
[0075] Step 5: Generate spline curves
[0076] Mathematical fitting is performed on the recombined pixel chains to generate a vector graphic.
[0077] Step 5.1, Sparsification: For each pixel chain, calculate the distance between adjacent pixels and remove redundant points with a spacing smaller than the sampling threshold (2.5 pixels in this embodiment). This step eliminates the microscopic stair-like effect caused by the pixel grid.
[0078] Step 5.2, Global Cubic B-Spline Fitting: Based on the sparsed pixel chain, the pixels in it are used as control points, and a spline curve is generated by the cubic B-spline algorithm; the smoothing factor is dynamically adjusted according to the number of pixels in the pixel chain. In this embodiment, the smoothing factor is specifically twice the number of pixels.
[0079] This invention first reassembles the pixel chain and then fits the merged pixel chain. Since the global fitting is performed on the merged long chain in one go, the generated curve has C2 continuity (curvature continuity) at the original breakpoints, which can completely eliminate the "bamboo joint" or "inflection point" phenomenon that may be generated by first fitting the segmented curves and then splicing the spline curves, and the lines are extremely smooth and rounded.
[0080] Step 5.3, Vector Output: Resample the fitted spline curve to generate a smooth polyline recognizable in DXF format, and map the pixel coordinates back to the original image size (i.e., divide by the magnification factor of the original super-resolution resampling), thereby completing the vectorization conversion of the line graphic and obtaining the final required DXF vector graphic.
[0081] Based on the above methods, a vector image without intersections is generated, which is then input into a laser marking machine to draw the embroidery pattern on the silk fabric. Specifically, the algorithm of this invention automatically creates physical "breaks" at all line intersections. When the laser head reaches these points, the laser temporarily shuts off due to the interrupted path and relies on inertia to cross the intersection before resuming laser emission. This method eliminates energy superposition and protects heat-sensitive materials such as silk and chiffon from overheating damage.
[0082] Figure 2 The image shows an actual comparative test. Both patterns were drawn on the same silk fabric by the same laser marking machine. The left pattern is a laser marking based on the vector image converted by the vectorization method of this invention, while the right pattern is a laser marking based on the vector image directly converted by the conventional method.
[0083] Figure 3 and Figure 4 Corresponding to Figure 2 Enlarged views of parts of the left and right images. Figure 4 The vector graphic shown, converted using conventional vectorization methods, will exhibit laser overburning issues at the intersections of lines in the pattern; while Figure 3 At the same positions shown, there is no overburning phenomenon, thus verifying that the vectorization method of the present invention can effectively avoid the problem of laser overburning when drawing embroidery pattern using a laser marking machine.
[0084] II. Devices, storage media, and software products
[0085] 1. Based on the same inventive concept as the laser-engraved image vectorization method described above, this application also provides an electronic device, which includes a processor and a memory, wherein computer-readable code is stored in the memory, and when the computer-readable code is executed by the processor, the laser-engraved image vectorization method of the present invention is implemented.
[0086] The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium can store the operating system and computer-readable code. The computer-readable code includes program instructions that, when executed, cause the processor to perform a laser-engraved image vectorization method. The processor provides computational and control capabilities to support the operation of the entire electronic device. The memory provides an environment for the execution of the computer-readable code in the non-volatile storage medium, which, when executed by the processor, causes the processor to perform a laser-engraved image vectorization method.
[0087] It should be understood that a processor can be a central processing unit, other general-purpose processors, digital signal processors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, transistor logic devices, discrete hardware components, etc. Among them, a general-purpose processor can be a microprocessor or any conventional processor.
[0088] 2. This application also provides a readable storage medium, which may be an internal storage unit of the electronic device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, smart memory card, or secure digital card equipped on the electronic device.
[0089] 3. This application also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the laser engraving image vectorization method of the present invention.
[0090] This invention is not limited to the above-described embodiments. Any obvious improvements, substitutions, or modifications that can be made by those skilled in the art without departing from the essence of this invention are within the scope of protection of this invention.
Claims
1. A method for vectorizing laser-engraved images, characterized in that: Comprising: Step 1, extracting skeleton graph from target image; Step 2, implementing breaking processing on line intersection position in skeleton graph; Step 3, extracting pixel chain of each independent connected domain from broken skeleton graph; Step 4, pixel chain reorganization: merging pixel chains meeting the following conditions: the end points between two pixel chains have a distance less than a distance threshold, and the line collinearity between the two end points and gap continuity also meet the preset range requirement; Step 5, fitting each pixel chain after reorganization to generate vector graph.
2. The method of claim 1, wherein: In step 4, the line collinearity and gap regularity is calculated as: wherein and are respectively and unit tangent vectors at the two points, is a unit vector pointing from to , and are the two end points for which the distance is less than a threshold.
3. The method of claim 1, wherein: In step 4, the preset range requirement is: and , is an alignment threshold.
4. The method of claim 3, wherein: In step 4, the spacing threshold is 12 pixels, and the alignment threshold is... It is 0.
6.
5. The method of claim 1, wherein: Step 1 comprises: Step 1.1, super-resolution resampling: for the input target image, magnifying by bicubic interpolation algorithm; Step 1.2, edge-preserving denoising: denoising the magnified image by bilateral filtering, wherein the spatial Gaussian function standard deviation is set to 75 and the gray value similarity standard deviation is set to 75; Step 1.3, binarization: binarizing the denoised image; Step 1.4, morphological repair: performing morphological closing operation on the binarized image using an elliptical structural element; Step 1.5, centerline skeleton extraction: iteratively eroding the morphologically repaired binary image using a thinning algorithm until all foreground regions are reduced to single-pixel-width center skeleton lines.
6. The method of claim 1, wherein: Step 2 comprises: Step 2.1, intersection point recognition: performing convolution operation on the skeleton graph using a 3x3 all-1 convolution kernel to obtain the number of eight-neighbor pixels for each skeleton pixel point, and determining that the number of eight-neighbor pixels greater than 2 is an intersection point; Step 2.2, topological breaking: constructing a mask containing all intersection points, performing morphological dilation operation on the mask, wherein the range is set to 1-2 pixels; in the original skeleton graph, setting the pixel value corresponding to the mask region to 0.
7. The method of claim 1, wherein: Step 3 comprises: Step 3.1, connected component analysis and noise removal: for the broken skeleton graph, using connected component labeling algorithm to count the number of pixels in each connected domain, and removing the connected domains with pixel number below the preset threshold; Step 3.2, pixel point sorting: for each retained connected domain, calculating its geometric center of gravity, selecting the pixel point farthest from the center of gravity as the starting point, and then using the greedy search algorithm to find the next unvisited pixel point in the connected domain from the starting point, thereby generating a pixel chain.
8. The method of claim 1, wherein: Step 5 comprises: Step 5.1, sparsification: for each pixel chain, calculate the distance between adjacent pixel points, and remove redundant points with a distance less than the sampling threshold; Step 5.2, global cubic B-spline fitting: based on the sparsified pixel chain, taking the pixel points as control points, generating a spline curve by cubic B-spline algorithm; Step 5.3, vector output: resampling the fitted spline curve to generate a smooth polyline, and mapping the pixel coordinates back to the original image size to generate a vector graph.
9. A computer apparatus, characterized by: Comprising a memory and a processor; The memory is used to store a computer program; The processor is used to execute the computer program and implement the laser engraving image vectorization method according to any one of claims 1-8 when executing the computer program.
10. A computer program product, characterised in that: The computer program is executed by the processor to implement the laser engraving image vectorization method according to any one of claims 1-8.
