Image-based embroidery path intelligent planning method and system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUZHOU HUICHUANG INTELLIGENT CONTROL TECHNOLOGY CO LTD
- Filing Date
- 2026-04-09
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies struggle to intelligently and synchronously process contour lines and color blocks from arbitrarily complex images, generating an embroidery path scheme optimized in terms of color, fill path, contour connection, and execution order, resulting in low efficiency and poor embroidery quality.
The binarized foreground mask of the embroidery target is extracted by image segmentation technology, pixel-level outline is generated and converted into vector graphics, adaptive color merging is used to generate the filling needle path, and the order of filling blocks is optimized by the traveling salesman problem approximation algorithm to automatically generate boundary strengthening outline path, forming a solidified 'fill-outline' process chain, and integrating it to generate an executable file.
It achieves end-to-end automated generation from image to embroidery path, improving generation efficiency and intelligence, reducing manual intervention, ensuring the quality and aesthetics of embroidery, and broadening the application scope of digital embroidery.
Smart Images

Figure CN122435259A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer-aided design and manufacturing technology, and in particular to an image-based intelligent planning method and system for embroidery paths. Background Technology
[0002] In traditional embroidery, transforming an image into an embroidered piece relies heavily on manual experience. Embroidery pattern makers manually trace the image outline, define color blocks, and plan the stitch direction. This method is not only inefficient and requires highly skilled personnel, but it also makes it difficult to ensure optimal needle paths, often resulting in frequent skipped stitches and messy stitches on the back of the embroidery, affecting production efficiency and the aesthetics of the finished product.
[0003] With the development of computer-aided design technology, some automated or semi-automated solutions have emerged. Some of these solutions extract lines from images and automatically generate chain stitch or stem stitch paths, effectively solving the problem of automated embroidery of graphic outlines. However, traditional methods are limited to the graphic outlines themselves in terms of both processing objects and output results, and cannot handle images containing large areas of color (such as cartoon characters, landscapes, logos, etc.), thus limiting their application scenarios.
[0004] While commercial embroidery software (such as Wilcom, Tajima DG / ML, etc.) supports filling color blocks with techniques like tatami stitch, it suffers from a series of inherent drawbacks: 1. The connection between the outline and fill path relies on manual intervention, resulting in skipped stitches: The fill path and the boundary edging path within the area usually need to be drawn and sorted manually. The system cannot automatically connect the end point of the fill path to the start point of the outline path, resulting in redundant skipped stitches during the embroidery process and increasing the number of thread ends on the back.
[0005] 2. Color merging and separation rely on manual labor: For multi-color images, it is usually necessary to manually extract different color regions layer by layer and manually assign a limited number of embroidery thread spool color numbers (usually around 9 colors). This process is tedious and subjective, lacking an intelligent method that can automatically perform color segmentation, quantization, and clustering based on image color features to adaptively match the physical color thread limitations of industrial embroidery.
[0006] 3. Insufficient Adaptability of Region Fill Path Generation: For irregularly shaped color block regions obtained through image segmentation, existing software filling algorithms are not adaptable. The generated needle paths easily lead to uneven stitch density and unreasonable start and end point positions, affecting the aesthetics and durability of the fill effect. In particular, there is a lack of an adaptive filling algorithm that can automatically determine the fill axis, generate uniform and effective fill line segments, and intelligently select the start and end points of the boundaries.
[0007] 4. Lack of global optimization of embroidery execution sequence: When the number of generated embroidery units (such as multiple fill blocks and outline blocks) is large, existing systems usually lack intelligent planning for the embroidery order of these units within the same color layer. They cannot optimize the execution sequence with the goal of minimizing the idle travel distance of the machine head, affecting the overall embroidery efficiency. At the same time, in the process chain of filling and outline, existing technologies usually require manual selection or are fixed to a single mode, failing to intelligently solidify and optimize the "fill first, then immediately perform boundary binding" process in an automated process, and failing to ensure the seamless connection and sequence between the two.
[0008] In summary, existing technologies struggle to intelligently and synchronously process contour lines and color blocks from arbitrarily complex images, and generate an integrated path scheme that is optimized in terms of color, fill path, contour connection, and execution order, and can directly drive the embroidery machine.
[0009] Therefore, how to provide an image-based intelligent embroidery path planning method and system to improve the efficiency, intelligence level and final embroidery quality of image-to-embroidery path generation has become an urgent technical problem to be solved. Summary of the Invention
[0010] The technical problem to be solved by the present invention is to provide an image-based intelligent planning method and system for embroidery paths, thereby improving the efficiency, intelligence level and final embroidery quality of the generation from images to embroidery paths.
[0011] In a first aspect, the present invention provides an image-based intelligent embroidery path planning method, comprising the following steps: Step S10: Obtain the original image containing the embroidery target, separate the image foreground and image background of the original image using an image segmentation method, and generate a binarized foreground mask of the embroidery target; Step S20: Extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. Step S30: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; perform adaptive color merging on the initial color regions to obtain corresponding color layers to match the preset number of embroidery spool colors. Each color layer contains several fill blocks, and a fill needle path is generated for each fill block. Step S40: Plan the embroidery sequence for multiple fill blocks within the same color layer to minimize the total idle distance, and obtain the embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path with the ending point of the current fill block's fill needle path; integrate all the single-line needle paths, boundary reinforcement outline embroidery paths, and fill needle paths after the embroidery block execution sequence has been planned in sequence, and generate an executable file to drive the embroidery machine to execute.
[0012] Furthermore, step S20 specifically includes: Step S21: Extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the center line of the vector graphic using the median division method; Step S22: Based on the geometric features of the center line, divide the vector graphic into multiple embroidery block units; Step S23: Generate a single-line needle path from the start point to the end point along the center line for each embroidery block unit.
[0013] Furthermore, step S30 specifically includes: Step S31: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; Step S32: Extract the average color of all the initial color regions and convert it to a uniform color space. Use a clustering algorithm to group the average colors in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. Step S33: Generate filling needle paths for each filling block using an adaptive tatami needle generation algorithm: Determine the main axis direction of the filler block; A set of equally spaced parallel scan lines are generated along the main axis direction. The intersection of the scan lines with the region boundary of the fill block yields an effective fill line segment located inside the fill block. Insert needle points at a preset needle spacing on each effective filling line segment, and make the needle movement directions on adjacent scan lines opposite to form a zigzag reciprocating needle point sequence; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the filling needle path.
[0014] Furthermore, step S40 specifically includes: Step S41: With the goal of minimizing the total empty walking distance, the Traveling Salesman Problem approximation algorithm is used to sort multiple fill blocks in the same color layer to obtain the embroidery block execution sequence; During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. Step S42: Extract the boundary contour from the binarized foreground mask of the filling block and vectorize it to obtain the vector contour. Generate a boundary reinforcement contour embroidery path of type edge binding stitch or stem embroidery stitch along the vector contour. The starting point of the boundary enhancement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path; Step S43: Physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current fill block's fill needle path. Step S44: Integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning of the embroidery block execution sequence to generate an executable file that drives the embroidery machine to execute.
[0015] Furthermore, in step S44, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order, and color-changing instructions and thread-cutting instructions are inserted between different color layers; embroidery thread segments exceeding the maximum allowable step length of the embroidery machine are automatically segmented.
[0016] Secondly, the present invention provides an image-based intelligent embroidery path planning system, comprising the following modules: The binarized foreground mask generation module is used to acquire the original image containing the embroidery target, separate the image foreground and image background of the original image through an image segmentation method, and generate a binarized foreground mask of the embroidery target. The single-line needle path generation module is used to extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. The fill needle path generation module is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; perform adaptive color merging on the initial color regions to obtain corresponding color layers to match the preset number of embroidery spool colors, each color layer contains several fill blocks, and a fill needle path is generated for each fill block. An executable file generation module is used to plan the embroidery sequence of multiple fill blocks within the same color layer to minimize the total idle distance, thereby obtaining an embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path to the ending point of the current fill block's fill stitch path; integrate all the single-line stitch paths, boundary reinforcement outline embroidery paths, and fill stitch paths after the embroidery block execution sequence has been sequentially planned, and generate an executable file to drive the embroidery machine to execute.
[0017] Furthermore, the single-thread needle path generation module specifically includes: The centerline calculation unit is used to extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the centerline of the vector graphic using the median division method. An embroidery block unit is used to divide the vector graphic into multiple embroidery block units based on the geometric features of the center line. A single-line path generation unit is used to generate a single-line needlework path from the start point to the end point along the center line for each of the embroidery block units.
[0018] Furthermore, the filling needle path generation module specifically includes: The color segmentation unit is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; The color clustering unit is used to extract the average color of all the initial color regions and convert it to a uniform color space. The clustering algorithm is used to group the average colors in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. The fill path generation unit is used to generate a fill stitch path for each fill block using an adaptive tatami stitch generation algorithm. Determine the main axis direction of the filler block; A set of equally spaced parallel scan lines are generated along the main axis direction. The intersection of the scan lines with the region boundary of the fill block yields an effective fill line segment located inside the fill block. Insert needle points at a preset needle spacing on each effective filling line segment, and make the needle movement directions on adjacent scan lines opposite to form a zigzag reciprocating needle point sequence; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the filling needle path.
[0019] Furthermore, the executable file generation module specifically includes: The fill block sorting unit is used to sort multiple fill blocks in the same color layer with the goal of minimizing the total empty walking distance, and to obtain the embroidery block execution sequence. During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. The boundary enhancement contour embroidery path generation unit is used to extract the boundary contour from the binary foreground mask of the fill block and vectorize it to obtain a vector contour, and generate a boundary enhancement contour embroidery path of type edge binding stitch or stem embroidery stitch along the vector contour. The starting point of the boundary enhancement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path; A physical connection unit is used to physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current fill block's fill needle path. The path integration unit is used to integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning by the embroidery block execution sequence, and generate an executable file to drive the embroidery machine to execute.
[0020] Furthermore, in the path integration unit, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order, and color-changing instructions and thread-cutting instructions are inserted between different color layers; embroidery thread segments exceeding the maximum allowable step length of the embroidery machine are automatically segmented.
[0021] The advantages of this invention are: 1. By constructing an end-to-end automated process from image to executable file, the efficiency, intelligence level, and final embroidery quality of embroidery path generation are systematically improved. In terms of efficiency, automated image segmentation, color clustering and merging, and color separation replace tedious manual outlining and color selection. Optimized algorithms automatically plan the execution order of multiple fill blocks within the same color layer to minimize idle time, significantly reducing manual intervention and machine downtime. In terms of intelligence, the adaptive tatami stitch can intelligently determine the optimal filling direction and start / end point based on the shape of the fill block, while the intelligent color merging algorithm can automatically match image colors to a limited physical embroidery thread color library. In terms of embroidery quality, after each fill block is completed, it is immediately and automatically connected from its fill path end point and an outline is embroidered to reinforce the contour. This solidified "fill-contour" process chain fundamentally eliminates skipped stitches that may occur during manual splicing, ensuring neat stitches on the back and a clear and beautiful front contour.
[0022] 2. A complete automated pipeline from image input to machine instruction output has been built. Users only need to provide an original image containing the embroidery target, and the system can automatically perform a series of complex steps such as image segmentation, contour extraction, color processing, and path planning, and finally generate a file that can directly drive the embroidery machine. This completely changes the traditional embroidery pattern making situation that relies on manual design and experience, and is cumbersome and time-consuming. It enables non-professionals to quickly and conveniently convert any image into an embroidery work, greatly expanding the application scope and production efficiency of digital embroidery.
[0023] 3. Not only does it generate filling stitch paths within the pattern to achieve color expression, but it also innovatively generates and physically connects boundary reinforcement outline embroidery paths for each filling block. This design cleverly simulates the "embroider the surface first, then outline" process logic in high-end hand embroidery. On the one hand, the boundary reinforcement outline embroidery path can wrap and fix the internal filling stitches, effectively preventing the stitches in the edge area from becoming loose, rough, or overflowing, making the pattern boundary clear and neat. On the other hand, the protrusion of the boundary reinforcement outline embroidery path enhances the three-dimensionality and delicacy of the pattern, thereby significantly improving the simulation and artistic expression of machine embroidery as a whole.
[0024] 4. By clustering and merging colors, the potentially rich colors in an image are automatically grouped into a limited number of primary colors that match the number of available embroidery thread color axes. This maintains the original color appearance as much as possible while avoiding unrealistic frequent thread changes. More importantly, by transforming the sorting problem of multiple fill blocks within the same color layer into a traveling salesman problem for approximate solution, and innovatively allowing the needle direction of the fill blocks to be reversed to find better connection points, the "idle travel" distance of the embroidery machine needle between blocks is systematically minimized, significantly reducing ineffective running time and thread waste, and directly improving production efficiency.
[0025] 5. The center line of the vector graphic is calculated using the "median division method". Compared with simple contour offset, this method can handle irregular and asymmetrical complex graphics more robustly, ensuring that the generated single-line path is located in the visual center position. For area filling, an adaptive tatami stitch method with a determinable main axis direction is adopted, which allows the direction of the filling line to be optimized according to the shape of each filling block, thereby obtaining a more uniform, beautiful and less deformable filling effect. These improvements in underlying algorithms together ensure the robustness of generating high-quality embroidery paths from various complex images.
[0026] 6. In the final stage, the embroidery order of different color layers is arranged according to a preset order, and color change instructions, thread cutting instructions, and safe segmentation of excessively long thread segments are automatically inserted. These detailed processing measures enable the generated file to be executed accurately, safely, and efficiently by the embroidery machine. Attached Figure Description
[0027] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0028] Figure 1 This is a flowchart of an image-based intelligent embroidery path planning method according to the present invention.
[0029] Figure 2 This is a schematic diagram of the structure of an image-based intelligent embroidery path planning system according to the present invention.
[0030] Figure 3 This is a schematic diagram of the original image of the present invention.
[0031] Figure 4 This is a schematic diagram of the foreground of the original image of the present invention.
[0032] Figure 5 This is a schematic diagram of the binarized foreground mask of the present invention.
[0033] Figure 6 This is a schematic diagram of the single-line needle path of the present invention.
[0034] Figure 7 This is a schematic diagram of the filling needle path of the present invention.
[0035] Figure 8 This is a schematic diagram of the boundary reinforcement outline embroidery path of the present invention. Detailed Implementation
[0036] The overall approach of the technical solution in this application is as follows: The embroidery target is extracted using image segmentation technology, and its outline and color block areas are processed separately. For the outline, a single-line needle path located at the visual center is automatically generated. For the color blocks, color segmentation and adaptive merging are used to group rich colors into a finite color layer, and an adaptive internal filling path is generated for each irregular fill block. To achieve high quality and high efficiency, the core innovation lies in intelligent global optimization and connection: First, a boundary-strengthened outline path is automatically generated for each fill block, and its starting point is physically connected to the end point of the corresponding fill path, forming a fixed "fill-outline" process chain to eliminate skipped stitches and ensure neat and beautiful edges. Second, the embroidery sequence planning of multiple fill blocks within the same color layer is transformed into a traveling salesman problem for optimization. By dynamically adjusting the needle direction, the machine head's idle travel distance is minimized, thereby significantly improving production efficiency. Finally, all paths, color-changing, and thread-cutting instructions are integrated and directly output as files to drive the embroidery machine, achieving end-to-end automated generation from complex images to high-quality embroidery paths.
[0037] Please refer to Figures 1 to 8 As shown, a preferred embodiment of the image-based intelligent embroidery path planning method of the present invention includes the following steps: Step S10: Obtain the original image (original color image or original grayscale image) containing the embroidery target, and separate the image foreground and image background of the original image using an image segmentation method to generate a binarized foreground mask of the embroidery target; in specific implementation, a mask-based image segmentation method (such as semantic segmentation model, chroma key matting, adaptive threshold segmentation, etc.) is used to accurately separate the image foreground and image background of the original image to obtain a binarized foreground mask; Step S20: Extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. Step S30: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; perform adaptive color merging on the initial color regions to obtain corresponding color layers to match the preset number of embroidery spool colors. Each color layer contains several fill blocks, and a fill needle path is generated for each fill block. Step S40: Plan the embroidery sequence for multiple fill blocks within the same color layer to minimize the total idle distance, and obtain the embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path with the ending point of the current fill block's fill needle path; integrate all the single-line needle paths, boundary reinforcement outline embroidery paths, and fill needle paths after the embroidery block execution sequence has been planned in sequence, and generate an executable file to drive the embroidery machine to execute.
[0038] Step S20 specifically includes: Step S21: Extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the center line of the vector graphic using the median division method (equally spaced cross sections along the stroke extension direction, calculate the midpoint of the corresponding points on both sides of the contour on each cross section, and connect all the midpoints to form the center line describing the stroke skeleton). Pixel-level contour extraction involves performing contour detection on the foreground mask (such as the Suzuki85 contour tracking algorithm) to obtain the pixel set of all external and internal contours of the embroidery target; then, the pixel-level contours are converted into vector graphics described by Bézier curves or straight line segments to eliminate pixel jaggedness and obtain smooth and scalable graphic boundaries. Step S22: Based on the geometric characteristics of the center line (curvature change point, inflection point, branch point), the vector graphic is divided into multiple embroidery block units; that is, the continuous center line in the vector graphic is divided into multiple smooth, easy-to-embroider line segment units, and each line segment unit is defined as an embroidery block unit. Step S23: Generate a single-line needlework path from the start point to the end point along the center line for each embroidery block unit (applicable to stem embroidery and chain embroidery).
[0039] Step S30 specifically includes: Step S31: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; Based on the foreground mask, and combined with the original image, color-driven segmentation is performed on the foreground image: using region growing, watershed, or mean shift algorithms, consecutive pixels with similar colors in the foreground image are aggregated into initial color regions; each initial color region records its color mean, pixel coordinate set, area, boundary, and other information. Step S32: Extract the average color of all the initial color regions and convert it to a uniform color space (such as CIELAB). Use a clustering algorithm (K-means clustering or hierarchical clustering) to group the average colors in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. Since the number of industrial embroidery spools is limited (usually limited to about 9 colors), it is necessary to cluster and merge the initial color areas. Step S33: Use the adaptive tatami stitch generation algorithm (an adaptive filling stitch algorithm for arbitrary shape regions) to generate filling stitch paths for each filling block (suitable for large area color block filling): Calculate the minimum bounding rectangle (MBR) of the fill block, and determine the main axis direction of the fill block based on the major axis direction of the minimum bounding rectangle; if there is a clear texture direction (detected by gradient histogram or Hough transform), it is adaptively adjusted to the main texture direction; Based on the preset stitch density (e.g., 10 stitches per centimeter), the scan line spacing d is calculated, and a set of equally spaced parallel scan lines are generated along the main axis. The intersection of the scan lines with the boundary of the filling block area yields the effective filling line segment located inside the filling block. Insert a needle drop point at a preset stitch distance (e.g., 0.4mm) on each effective filling line segment, and make the needle movement directions of adjacent scanning lines opposite to form a zigzag reciprocating needle drop point sequence; if there are multiple non-connected effective line segments on the same scanning line (the area has holes or recesses), then connect each segment sequentially through short connecting lines (embroidery threads) to ensure that there are no needle lifts or skipped stitches in the area; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the fill needle path. That is, automatically select the position close to the boundary of the region and easy to connect with the subsequent contour path as the start and end points of the fill needle path; by default, the start point of the fill needle path is set on the side of the boundary region close to the previous fill block, and the end point is set on the side of the boundary region close to the boundary and easy to connect with the contour path.
[0040] Step S40 specifically includes: Step S41: With the goal of minimizing the total empty walking distance, the Traveling Salesman Problem (TSP) approximation algorithm is used to sort multiple fill blocks in the same color layer to obtain the embroidery block execution sequence; During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. Step S42: Extract the boundary contour (outer and inner boundaries) from the binarized foreground mask of the fill block and vectorize it to obtain a vector contour. Generate a boundary reinforcement contour embroidery path (equivalent to embroidering another layer of contour) along the vector contour, which is of the type of Satin Stitch or Run Stitch. The starting point of the boundary reinforcement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path to minimize subsequent skipped stitches. Step S43: Physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current filling block's filling needle path (including the embroidery path, not empty skipping lines) to achieve an integrated process of "filling and binding at the same time". Step S44: Integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning of the embroidery block execution sequence, and generate executable files (.DST, .EXP, .DSB) to drive the embroidery machine to execute.
[0041] In step S44, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order (such as embroidering dark colors first and light colors later), and color change instructions and thread cutting instructions are inserted between different color layers; embroidery thread segments that exceed the maximum allowable step length of the embroidery machine (usually 12.7mm) are automatically segmented; and absolute coordinates are converted into relative pulse coordinates of the embroidery machine.
[0042] A preferred embodiment of the image-based intelligent embroidery path planning system of the present invention includes the following modules: The binarized foreground mask generation module is used to acquire the original image (original color image or original grayscale image) containing the embroidery target, separate the image foreground and image background of the original image through image segmentation methods, and generate a binarized foreground mask of the embroidery target; in specific implementation, a mask-based image segmentation method (such as semantic segmentation model, chroma key matting, adaptive threshold segmentation, etc.) is used to accurately separate the image foreground and image background of the original image to obtain the binarized foreground mask; The single-line needle path generation module is used to extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. The fill needle path generation module is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; perform adaptive color merging on the initial color regions to obtain corresponding color layers to match the preset number of embroidery spool colors, each color layer contains several fill blocks, and a fill needle path is generated for each fill block. An executable file generation module is used to plan the embroidery sequence of multiple fill blocks within the same color layer to minimize the total idle distance, thereby obtaining an embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path to the ending point of the current fill block's fill stitch path; integrate all the single-line stitch paths, boundary reinforcement outline embroidery paths, and fill stitch paths after the embroidery block execution sequence has been sequentially planned, and generate an executable file to drive the embroidery machine to execute.
[0043] The single-line needle path generation module specifically includes: The centerline calculation unit is used to extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the centerline of the vector graphic using the median division method (equally spaced cross sections along the stroke extension direction, calculating the midpoint of the corresponding points on both sides of the contour on each cross section, and connecting all midpoints to form the centerline describing the stroke skeleton). Pixel-level contour extraction involves performing contour detection on the foreground mask (such as the Suzuki85 contour tracking algorithm) to obtain the pixel set of all external and internal contours of the embroidery target; then, the pixel-level contours are converted into vector graphics described by Bézier curves or straight line segments to eliminate pixel jaggedness and obtain smooth and scalable graphic boundaries. The embroidery block unit segmentation unit is used to divide the vector graphic into multiple embroidery block units according to the geometric characteristics of the center line (curvature change point, inflection point, branch point); that is, to divide the continuous center line in the vector graphic into multiple smooth and easy-to-embroider line segment units, and each line segment unit is defined as an embroidery block unit. A single-line path generation unit is used to generate a single-line needlework path from the start point to the end point along the center line for each embroidery block unit (applicable to stem embroidery and chain embroidery).
[0044] The filling needle path generation module specifically includes: The color segmentation unit is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; Based on the foreground mask, and combined with the original image, color-driven segmentation is performed on the foreground image: using region growing, watershed, or mean shift algorithms, consecutive pixels with similar colors in the foreground image are aggregated into initial color regions; each initial color region records its color mean, pixel coordinate set, area, boundary, and other information. The color clustering unit is used to extract the average color of all the initial color regions and convert it to a uniform color space (such as CIELAB). The clustering algorithm (K-means clustering or hierarchical clustering) is used to group the average color in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. Since the number of industrial embroidery spools is limited (usually limited to about 9 colors), it is necessary to cluster and merge the initial color areas. The fill path generation unit is used to generate fill stitch paths for each of the fill blocks using an adaptive tatami stitch generation algorithm (an adaptive fill stitch algorithm for arbitrary shape regions) (suitable for filling large areas of color blocks): Calculate the minimum bounding rectangle (MBR) of the fill block, and determine the main axis direction of the fill block based on the major axis direction of the minimum bounding rectangle; if there is a clear texture direction (detected by gradient histogram or Hough transform), it is adaptively adjusted to the main texture direction; Based on the preset stitch density (e.g., 10 stitches per centimeter), the scan line spacing d is calculated, and a set of equally spaced parallel scan lines are generated along the main axis. The intersection of the scan lines with the boundary of the filling block area yields the effective filling line segment located inside the filling block. Insert a needle drop point at a preset stitch distance (e.g., 0.4mm) on each effective filling line segment, and make the needle movement directions of adjacent scanning lines opposite to form a zigzag reciprocating needle drop point sequence; if there are multiple non-connected effective line segments on the same scanning line (the area has holes or recesses), then connect each segment sequentially through short connecting lines (embroidery threads) to ensure that there are no needle lifts or skipped stitches in the area; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the fill needle path. That is, automatically select the position close to the boundary of the region and easy to connect with the subsequent contour path as the start and end points of the fill needle path; by default, the start point of the fill needle path is set on the side of the boundary region close to the previous fill block, and the end point is set on the side of the boundary region close to the boundary and easy to connect with the contour path.
[0045] The executable file generation module specifically includes: The fill block sorting unit is used to sort multiple fill blocks within the same color layer with the goal of minimizing the total empty walking distance, using the Traveling Salesman Problem (TSP) approximation algorithm to obtain the embroidery block execution sequence; During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. The boundary enhancement contour embroidery path generation unit is used to extract the boundary contour (outer boundary and inner boundary) from the binary foreground mask of the fill block and vectorize it to obtain a vector contour. A boundary enhancement contour embroidery path (equivalent to embroidering another layer of contour) of type Satin Stitch or Run Stitch is generated along the vector contour. The starting point of the boundary reinforcement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path to minimize subsequent skipped stitches. The physical connection unit is used to physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current filling block's filling needle path (including the embroidery path, not empty skipping stitches), to achieve an integrated process of "filling and binding at the same time". The path integration unit is used to integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning by the embroidery block execution sequence, and generate executable files (.DST, .EXP, .DSB) to drive the embroidery machine to execute.
[0046] In the path integration unit, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order (such as embroidering dark colors first and light colors later), and color change instructions and thread cutting instructions are inserted between different color layers; embroidery line segments that exceed the maximum allowable step length of the embroidery machine (usually 12.7mm) are automatically segmented; and absolute coordinates are converted into relative pulse coordinates of the embroidery machine.
[0047] To facilitate understanding of the present invention, the following examples are provided for further illustration: The user needs to create a cartoon panda head badge, consisting of a white face (large fill area), black eye circles / ears (small fill area), and a red bow (fill area + outline reinforcement). The designer wants the embroidery to have a full tatami-like fill, a clear black border outline, and to minimize skipped stitches.
[0048] The process is as follows: Foreground extraction: The user imports a panda head image, and the semantic segmentation model is automatically invoked to remove the white background and generate a foreground mask.
[0049] Outline path generation: Extract the overall outer outline of the panda, vectorize it, and calculate the center line using the median division method; divide the center line to obtain multiple embroidery blocks (such as the top arc, ear line, etc.); generate the stem embroidery needle path.
[0050] Color region segmentation and merging: Based on the foreground mask, region growing is performed on the original color image to obtain areas such as face (white), left eye ring (dark gray), right eye ring (dark gray), nose (black), and bow (red); Color clustering: The color difference ΔE between the left and right eye circles is 2.1, and they are grouped into the same dark gray cluster, which is mapped to the black line axis; The white face is in a separate cluster, and the red bow is in a separate cluster; a total of 3 color layers are output.
[0051] Fill needle path generation: For white faces: The minimum bounding rectangle is horizontal along its major axis, with the main axis set to 0° and the line spacing to 0.8mm. A zigzag tatami-style fill path is generated, with the endpoint automatically positioned near the boundary on the lower right jaw. For dark circles: use a 45° angle along the long axis to create a flat-bottomed filling effect; For bows: If the shape is complex, the filling path is automatically segmented to ensure no omissions.
[0052] Embroidery thread merging and global optimization: The black layer contains three fill blocks: the left eye circle, the right eye circle, and the nose. The order is based on the TSP algorithm: left eye circle (fill first) → right eye circle (connect in reverse, embroider from right to left) → nose (connect directly); total jumper distance is 0.3 meters. Automatically generate boundary reinforcement outline embroidery paths for each filled area: Extract the outer contour of the face, use the edge binding stitch, and set the starting point near the end point of the fill path to achieve a seamless connection; For the eye contour, first embroider the outline (outline first, then fill in), then fill in the inside to make the outline perfectly cover the edge; The start and end points of the contour path and the fill path are physically connected, with no additional jumpers.
[0053] Post-processing and output: Inspect all line segments and automatically segment straight lines exceeding 12.7mm; Output the layers in the order of darkest colors first: black layer → red layer → white layer; Insert color change and line trimming commands between layers; Compile to generate a .DST file.
[0054] In summary, the advantages of this invention are as follows: 1. By constructing an end-to-end automated process from image to executable file, the efficiency, intelligence level, and final embroidery quality of embroidery path generation are systematically improved. In terms of efficiency, automated image segmentation, color clustering and merging, and color separation replace tedious manual outlining and color selection. Optimized algorithms automatically plan the execution order of multiple fill blocks within the same color layer to minimize idle time, significantly reducing manual intervention and machine downtime. In terms of intelligence, the adaptive tatami stitch can intelligently determine the optimal filling direction and start / end point based on the shape of the fill block, while the intelligent color merging algorithm can automatically match image colors to a limited physical embroidery thread color library. In terms of embroidery quality, after each fill block is completed, it is immediately and automatically connected from its fill path end point and an outline is embroidered to reinforce the contour. This solidified "fill-contour" process chain fundamentally eliminates skipped stitches that may occur during manual splicing, ensuring neat stitches on the back and a clear and beautiful front contour.
[0055] 2. A complete automated pipeline from image input to machine instruction output has been built. Users only need to provide an original image containing the embroidery target, and the system can automatically perform a series of complex steps such as image segmentation, contour extraction, color processing, and path planning, and finally generate a file that can directly drive the embroidery machine. This completely changes the traditional embroidery pattern making situation that relies on manual design and experience, and is cumbersome and time-consuming. It enables non-professionals to quickly and conveniently convert any image into an embroidery work, greatly expanding the application scope and production efficiency of digital embroidery.
[0056] 3. Not only does it generate filling stitch paths within the pattern to achieve color expression, but it also innovatively generates and physically connects boundary reinforcement outline embroidery paths for each filling block. This design cleverly simulates the "embroider the surface first, then outline" process logic in high-end hand embroidery. On the one hand, the boundary reinforcement outline embroidery path can wrap and fix the internal filling stitches, effectively preventing the stitches in the edge area from becoming loose, rough, or overflowing, making the pattern boundary clear and neat. On the other hand, the protrusion of the boundary reinforcement outline embroidery path enhances the three-dimensionality and delicacy of the pattern, thereby significantly improving the simulation and artistic expression of machine embroidery as a whole.
[0057] 4. By clustering and merging colors, the potentially rich colors in an image are automatically grouped into a limited number of primary colors that match the number of available embroidery thread color axes. This maintains the original color appearance as much as possible while avoiding unrealistic frequent thread changes. More importantly, by transforming the sorting problem of multiple fill blocks within the same color layer into a traveling salesman problem for approximate solution, and innovatively allowing the needle direction of the fill blocks to be reversed to find better connection points, the "idle travel" distance of the embroidery machine needle between blocks is systematically minimized, significantly reducing ineffective running time and thread waste, and directly improving production efficiency.
[0058] 5. The center line of the vector graphic is calculated using the "median division method". Compared with simple contour offset, this method can handle irregular and asymmetrical complex graphics more robustly, ensuring that the generated single-line path is located in the visual center position. For area filling, an adaptive tatami stitch method with a determinable main axis direction is adopted, which allows the direction of the filling line to be optimized according to the shape of each filling block, thereby obtaining a more uniform, beautiful and less deformable filling effect. These improvements in underlying algorithms together ensure the robustness of generating high-quality embroidery paths from various complex images.
[0059] 6. In the final stage, the embroidery order of different color layers is arranged according to a preset order, and color change instructions, thread cutting instructions, and safe segmentation of excessively long thread segments are automatically inserted. These detailed processing measures enable the generated file to be executed accurately, safely, and efficiently by the embroidery machine.
[0060] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. An image-based intelligent embroidery path planning method, characterized in that: Includes the following steps: Step S10: Obtain the original image containing the embroidery target, separate the image foreground and image background of the original image using an image segmentation method, and generate a binarized foreground mask of the embroidery target; Step S20: Extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. Step S30: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; Adaptive color merging is performed on the initial color area to obtain the corresponding color layer to match the preset number of embroidery spool colors. Each color layer contains several fill blocks, and a fill needle path is generated for each fill block. Step S40: Plan the embroidery sequence for multiple fill blocks within the same color layer to minimize the total idle distance, and obtain the embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path with the ending point of the current fill block's fill needle path; integrate all the single-line needle paths, boundary reinforcement outline embroidery paths, and fill needle paths after the embroidery block execution sequence has been planned in sequence, and generate an executable file to drive the embroidery machine to execute.
2. The image-based intelligent embroidery path planning method as described in claim 1, characterized in that: Step S20 specifically includes: Step S21: Extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the center line of the vector graphic using the median division method; Step S22: Based on the geometric features of the center line, divide the vector graphic into multiple embroidery block units; Step S23: Generate a single-line needle path from the start point to the end point along the center line for each embroidery block unit.
3. The image-based intelligent embroidery path planning method as described in claim 1, characterized in that: Step S30 specifically includes: Step S31: Based on the binarized foreground mask and the original image, perform color segmentation on the foreground image to obtain multiple initial color regions; Step S32: Extract the average color of all the initial color regions and convert it to a uniform color space. Use a clustering algorithm to group the average colors in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. Step S33: Generate filling needle paths for each filling block using an adaptive tatami needle generation algorithm: Determine the main axis direction of the filler block; A set of equally spaced parallel scan lines are generated along the main axis direction. The intersection of the scan lines with the region boundary of the fill block yields an effective fill line segment located inside the fill block. Insert needle points at a preset needle spacing on each effective filling line segment, and make the needle movement directions on adjacent scan lines opposite to form a zigzag reciprocating needle point sequence; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the filling needle path.
4. The image-based intelligent embroidery path planning method as described in claim 1, characterized in that: Step S40 specifically includes: Step S41: With the goal of minimizing the total empty walking distance, the Traveling Salesman Problem approximation algorithm is used to sort multiple fill blocks in the same color layer to obtain the embroidery block execution sequence; During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. Step S42: Extract the boundary contour from the binarized foreground mask of the filling block and vectorize it to obtain the vector contour. Generate a boundary reinforcement contour embroidery path of type edge binding stitch or stem embroidery stitch along the vector contour. The starting point of the boundary enhancement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path; Step S43: Physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current fill block's fill needle path. Step S44: Integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning of the embroidery block execution sequence to generate an executable file that drives the embroidery machine to execute.
5. The image-based intelligent embroidery path planning method as described in claim 4, characterized in that: In step S44, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order, and color change instructions and thread cutting instructions are inserted between different color layers; embroidery thread segments that exceed the maximum allowable step length of the embroidery machine are automatically segmented.
6. An image-based intelligent embroidery path planning system, characterized in that: Includes the following modules: The binarized foreground mask generation module is used to acquire the original image containing the embroidery target, separate the image foreground and image background of the original image through an image segmentation method, and generate a binarized foreground mask of the embroidery target. The single-line needle path generation module is used to extract the pixel-level outline of the embroidery target based on the binarized foreground mask, convert the pixel-level outline into a vector graphic, and generate a single-line needle path suitable for outline embroidery based on the vector graphic. The fill needle path generation module is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; Adaptive color merging is performed on the initial color area to obtain the corresponding color layer to match the preset number of embroidery spool colors. Each color layer contains several fill blocks, and a fill needle path is generated for each fill block. An executable file generation module is used to plan the embroidery sequence of multiple fill blocks within the same color layer to minimize the total idle distance, thereby obtaining an embroidery block execution sequence; automatically generate a boundary reinforcement outline embroidery path for each fill block, and physically connect the starting point of the boundary reinforcement outline embroidery path to the ending point of the current fill block's fill stitch path; integrate all the single-line stitch paths, boundary reinforcement outline embroidery paths, and fill stitch paths after the embroidery block execution sequence has been sequentially planned, and generate an executable file to drive the embroidery machine to execute.
7. The image-based intelligent embroidery path planning system as described in claim 6, characterized in that: The single-line needle path generation module specifically includes: The centerline calculation unit is used to extract the pixel-level contour of the embroidery target based on the binarized foreground mask, convert the pixel-level contour into a vector graphic, and calculate the centerline of the vector graphic using the median division method. An embroidery block unit is used to divide the vector graphic into multiple embroidery block units based on the geometric features of the center line. A single-line path generation unit is used to generate a single-line needlework path from the start point to the end point along the center line for each of the embroidery block units.
8. The image-based intelligent embroidery path planning system as described in claim 6, characterized in that: The filling needle path generation module specifically includes: The color segmentation unit is used to perform color segmentation on the foreground image based on the binarized foreground mask and the original image to obtain multiple initial color regions; The color clustering unit is used to extract the average color of all the initial color regions and convert it to a uniform color space. The clustering algorithm is used to group the average colors in the uniform color space into a preset number of primary color clusters. The initial color areas belonging to the same primary color cluster are merged into the same color layer, and each color layer is assigned a uniform embroidery spool color number. Each color layer contains several fill blocks. The fill path generation unit is used to generate a fill stitch path for each fill block using an adaptive tatami stitch generation algorithm. Determine the main axis direction of the filler block; A set of equally spaced parallel scan lines are generated along the main axis direction. The intersection of the scan lines with the region boundary of the fill block yields an effective fill line segment located inside the fill block. Insert needle points at a preset needle spacing on each effective filling line segment, and make the needle movement directions on adjacent scan lines opposite to form a zigzag reciprocating needle point sequence; Select the start and end points of the needle drop sequence near the boundary of the region to obtain the filling needle path.
9. The image-based intelligent embroidery path planning system as described in claim 6, characterized in that: The executable file generation module specifically includes: The fill block sorting unit is used to sort multiple fill blocks in the same color layer with the goal of minimizing the total empty walking distance, and to obtain the embroidery block execution sequence. During sorting, if the endpoint of the first filling block is closest to the endpoint of the second filling block, then the needle direction of the second filling block is reversed, making the endpoint of the second filling block the starting point, and connecting it with the endpoint of the first filling block. The boundary enhancement contour embroidery path generation unit is used to extract the boundary contour from the binary foreground mask of the fill block and vectorize it to obtain a vector contour, and generate a boundary enhancement contour embroidery path of type edge binding stitch or stem embroidery stitch along the vector contour. The starting point of the boundary enhancement outline embroidery path is automatically positioned at the position closest to the end point of the current filler block's filler stitch path; A physical connection unit is used to physically connect the starting point of the boundary reinforcement contour embroidery path with the ending point of the current fill block's fill needle path. The path integration unit is used to integrate all the single-line needle paths, boundary reinforcement outline embroidery paths and filling needle paths after sequential planning by the embroidery block execution sequence, and generate an executable file to drive the embroidery machine to execute.
10. The image-based intelligent embroidery path planning system as described in claim 9, characterized in that: In the path integration unit, before generating the executable file, the embroidery order of each color layer is arranged according to a preset color priority order, and color change instructions and thread cutting instructions are inserted between different color layers; embroidery thread segments that exceed the maximum allowable step length of the embroidery machine are automatically segmented.