Embroidery stitch generation method and system based on texture feature extraction
By constructing an interlacing region determination index and a layered interlacing potential energy model based on texture feature extraction, the problems of disordered stacking of texture conflict regions and fabric damage in existing technologies are solved. This achieves high-precision stitch generation and adaptability to multiple fabric materials, thereby improving the quality of finished embroidery products.
Patent Information
- Application Number
- CN202611572148.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-12
- Publication Date
- 2026-11-27
AI Technical Summary
Existing embroidery stitch generation technology struggles to accurately identify the competing relationships of the main texture direction when processing complex images. This results in disordered stacking of sewing threads, tangled stitches, and an inability to adaptively control the density of the streamlined stitching. Consequently, it can easily puncture the fabric or cause exposed areas, limiting the adaptability of automated pattern making to different fabric materials and the quality of finished products.
By using a texture feature extraction method, an interlacing region determination index is constructed to identify texture conflict areas and perform hierarchical decoupling. This generates upper and lower layer stitch guide flow fields with physical coverage order. Combined with adaptive step length correction and fabric deformation resistance parameters, the needle drop point and stitch length are adaptively determined to generate embroidery machine drive instructions.
It achieves precise decoupling of texture conflict areas, avoids disordered crossing of sewing threads, ensures the flatness of embroidery and smooth flow of texture, prevents fabric holes and exposed bottoms, and improves the finished product quality and processing stability of multi-material fabrics.
Smart Images

Figure CN123181526A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embroidery pattern making technology, specifically to a method and system for generating embroidery stitches based on texture feature extraction. Background Technology
[0002] With the rapid development of modern computer graphics, digital art design, and intelligent manufacturing technologies, automated embroidery pattern making and digital stitch generation technologies have been widely applied in the manufacturing of textiles, apparel, industrial embroidery, and personalized cultural and creative products. Especially when faced with complex artistic designs that are high-precision, multi-textured, and interwoven with colors, how to convert two-dimensional images into embroidery stitches that conform to the mechanical and physical characteristics of embroidery and the principles of visual aesthetics has become a focus of industry attention. Currently, image processing-based automated pattern making technology has been introduced into the field of embroidery stitch generation.
[0003] Existing embroidery stitch generation technology faces the following technical challenges when processing complex images and converting them into physical stitch patterns:
[0004] 1. Most existing embroidery pattern making algorithms rely on single-direction field fitting or global smoothing strategies. When dealing with conflict areas in images where there are multiple texture intersections, occlusions, or drastic color changes (such as overlapping feathers, interwoven petals, or fabric texture intersections), it is difficult to accurately identify the competitive relationship of the main texture direction. Due to the lack of an expression mechanism for the order of physical texture coverage, directly generating stitches will cause the sewing threads of different levels to be stacked disorderly at the intersection center and the stitches to be messed up, which will seriously damage the surface flatness and texture layering of the embroidery.
[0005] 2. Existing streamline generation algorithms typically employ a discrete integral tracking strategy with a fixed step size, which cannot perform real-time adaptive correction based on the spatial distance of adjacent streamlines. In areas with drastic curvature changes or vector contraction, fixed step size tracking is prone to causing adjacent streamlines to squeeze, overlap, or collide, resulting in overly dense embroidery stitches that puncture the fabric (holes). In areas with vector diffusion, the sparse streamlines can easily lead to embroidery gaps (exposed fabric), making it difficult to achieve dynamic adaptive balance of the stitch spacing.
[0006] 3. Existing algorithms often use equidistant sampling or purely geometric discretization strategies based solely on geometric curvature when discretizing continuous streamlines into needle points. This ignores the interaction between fabric deformation resistance (such as warp and weft tensile modulus and shear yield strength) and thread physical properties (such as thread diameter, thickness density, and bending radius) during the embroidery process. This purely geometric fitting can easily lead to fabric arching and folding, thread breakage, or distortion of corner patterns due to concentrated tension at high curvature corners, which greatly limits the adaptability of automated pattern making to different fabric materials and the quality of finished products.
[0007] To address the aforementioned issues, there is an urgent need for a method and system for generating embroidery stitches based on texture feature extraction. This system would enable precise hierarchical decoupling of texture conflict areas, adaptive control of streamlined thread density, and high-precision discrete generation of stitches that integrates the physical parameter constraints of fabric and thread. Summary of the Invention
[0008] The purpose of this invention is to provide a method and system for generating embroidery stitches based on texture feature extraction, so as to solve the problems mentioned in the background art.
[0009] To achieve the above objectives, the present invention provides the following technical solution: an embroidery stitch generation method based on texture feature extraction, the method comprising the following steps:
[0010] S1: Obtain the target image to be embroidered, extract the local texture principal direction field of the target image, and calculate the color gradient feature field of the target image. The color gradient feature field includes the color gradient vector and gradient magnitude corresponding to each pixel position.
[0011] S2: Based on the local texture principal direction field and color gradient feature field, construct an interlacing region determination index to characterize the interlacing relationship between texture direction and color change structure, and identify texture conflict regions with multi-directional texture competition based on the interlacing region determination index.
[0012] S3: Perform hierarchical decoupling of texture conflict regions based on texture interweaving relationship, construct a layered interweaving potential energy model corresponding to the texture conflict region, determine the coverage priority relationship between different texture directions based on the layered interweaving potential energy model, and decompose the two-dimensional texture of the texture conflict region into an upper needle-guided flow field and a lower needle-guided flow field with physical coverage order.
[0013] S4: In the upper and lower needle-guided flow fields, streamlines are tracked along the vector direction, and the flow step size is adaptively corrected based on the real-time vertical distance between the tracking paths. This ensures that adjacent streamlines maintain a preset line spacing and suppresses disordered intersections of streamlines at different levels, generating vector streamline clusters that correspond to different levels of texture and have a predetermined line spacing.
[0014] S5: Calculate the local curvature of the vector streamline cluster at each sampling point, obtain the fabric deformation resistance parameters and thread characteristic parameters corresponding to the sampling points, perform collaborative constraints on the needle step length based on the local curvature and fabric deformation resistance parameters, adaptively determine the needle drop point coordinates and needle step length, and determine the needle execution order based on the coverage relationship between different levels of needle stitches, and generate the embroidery machine drive instruction set.
[0015] Preferably, the step S2 of constructing the interlacing region determination index and identifying texture conflict regions includes the following steps:
[0016] S21: Calculate the principal direction vector of texture and coherence of each pixel in the target image using the structure tensor matrix;
[0017] S22: Use gradient operators to calculate the color gradient vector and gradient magnitude of each pixel;
[0018] S23: Calculate the directional relationship parameters between the principal texture direction vector and the color gradient vector, and combine the coherence of the principal texture direction to characterize the stability of the local texture direction;
[0019] S24: The coherence, gradient magnitude and directional relationship parameters are weighted and multiplied to construct the judgment index. The boundary of the interlacing region is determined by combining the index continuity of adjacent pixels in the texture conflict region. When the judgment index is greater than the preset threshold and a continuous high index value region is formed between adjacent pixels, the corresponding region is determined to belong to the texture conflict region.
[0020] Preferably, the hierarchical decoupling of texture conflict areas in step S3 includes the following steps:
[0021] S31: Extract two intersecting texture directions with high coherence within the texture conflict region, and determine the main direction vector and the secondary direction vector respectively;
[0022] S32: Based on the light and dark distribution and color connectivity of the edge of the conflict area, calculate the saliency score of the texture block corresponding to the main direction vector and the secondary direction vector respectively;
[0023] S33: Based on the directional relationship between the main direction vector and the secondary direction vector, the saliency score of the corresponding texture block, the edge connectivity relationship, and the local gradient change relationship, a hierarchical interweaving potential energy model is constructed to calculate the interweaving intensity and coverage priority relationship between the texture blocks corresponding to the main direction vector and the secondary direction vector.
[0024] S34: Based on the layered interlacing potential energy model, determine the coverage priority relationship, assign the texture direction with higher interlacing intensity and higher coverage priority to the upper needle guide flow field, assign the other texture direction to the lower needle guide flow field, and apply a density attenuation coefficient to the lower needle guide flow field in the region where it overlaps with the upper needle guide flow field, so that the line density of the lower streamline is gradually adjusted outward from the intersection center.
[0025] Preferably, step S4, which adaptively corrects the flow step size based on real-time vertical distance and generates a vector streamline cluster, includes the following steps:
[0026] S41: Initial seed points are placed at equal intervals at the edges of the needle-guided flow field and in areas where texture density changes;
[0027] S42: Starting from each initial seed point, perform numerical integration tracking along the tangent direction of the flow field with a preset initial step size to generate continuous streamlines;
[0028] S43: During the integral tracking process, the minimum vertical distance between the current tracking point and the generated adjacent streamlines is calculated in real time, and the corresponding target line spacing is determined according to the level of the current streamline.
[0029] S44: When the minimum vertical distance is less than the preset minimum safe distance, shorten the current integration step or terminate the tracking of the current streamline. When the minimum vertical distance is greater than the preset maximum allowable distance, insert a new seed point between adjacent streamlines and continue tracking so that the generated adjacent streamlines remain within the allowable range corresponding to the target streamline spacing.
[0030] Preferably, the adaptive determination of the needle drop point coordinates and needle step length in S5 includes the following steps:
[0031] S51: Extract the local curvature parameters formed by continuous sampling points along the vector streamline cluster, and determine the degree of curvature change corresponding to each sampling point;
[0032] S52: Obtain the preset set of fabric deformation resistance parameters, as well as the wire thickness and flexibility parameters;
[0033] S53: Determine the geometric constraint range of the needle step length based on the local curvature parameters, and determine the deformation constraint range of the needle step length based on the set of fabric deformation resistance parameters. Perform a coordinated matching between the geometric constraint range and the deformation constraint range to obtain the adaptive target needle step length corresponding to each sampling point, and constrain the adaptive target needle step length within the preset maximum needle length and minimum needle length limit range.
[0034] S54: Discretize the needle drop point coordinates on the vector streamline according to the determined target needle step length, determine the needle density according to the curvature change between adjacent needle drop points, and insert lock needle compensation points at positions where the corner curvature is greater than the preset threshold to form a needle path that satisfies the texture direction expression and fabric deformation constraints.
[0035] Preferably, the system includes:
[0036] The image feature extraction module is used to acquire the target image to be embroidered, extract the local texture principal direction field of the target image, and calculate the color gradient feature field of the target image.
[0037] The conflict region identification module is used to construct interlaced region judgment index based on the local texture main direction field and color gradient feature field, and to identify texture conflict regions with multi-directional texture competition.
[0038] The deep hierarchical decoupling module is used to perform hierarchical decoupling of texture conflict areas based on texture interweaving relationships. It decomposes the two-dimensional texture of the texture conflict area into an upper-layer needle-guided flow field and a lower-layer needle-guided flow field with a physical covering order.
[0039] The streamline tracing generation module is used to perform streamline tracing along the vector direction in the upper and lower needle-guided flow fields, respectively, and adaptively correct the flow step size based on the real-time vertical distance between the tracing paths to generate a vector streamline cluster with hierarchical correspondence and predetermined line spacing.
[0040] The needle step discretization and instruction generation module is used to calculate the local curvature of the vector streamline cluster at each sampling point, obtain the fabric deformation resistance parameters and thread characteristic parameters corresponding to the sampling points, perform collaborative constraints based on the local curvature and the fabric deformation resistance parameters, adaptively determine the needle drop point coordinates and needle step length, and determine the needle execution order based on the coverage relationship between different levels of needle stitches, and generate the embroidery machine drive instruction set.
[0041] Preferably, the system further includes a layered buffer architecture, wherein after the deep layer decoupling module decomposes and generates the upper layer needle-guided flow field and the lower layer needle-guided flow field, it writes the upper layer and lower layer flow field data in parallel into the corresponding upper layer buffer area and lower layer buffer area, respectively.
[0042] Preferably, the streamline tracing generation module includes a dual-channel parallel tracing unit, which independently reads data from the upper layer cache area and the lower layer cache area to perform streamline tracing, and synchronizes the vertical distance data between adjacent streamlines in real time through a shared memory area.
[0043] Preferably, the needle step discretization and instruction generation module includes a physical parameter constraint mapping unit and an instruction encoding unit. The physical parameter constraint mapping unit establishes a deformation resistance lookup table corresponding to different fabric materials. The instruction encoding unit generates a bitmap control sequence containing machine head lifting pulses, embroidery frame displacement vectors, and thread cutting control codes according to the adaptive target needle step length and lock needle compensation point and the control protocol of the embroidery machine.
[0044] Compared with the prior art, the present invention has the following beneficial effects:
[0045] 1. This invention constructs an interlacing region determination index by extracting the main direction and color gradient features of image texture, accurately locates multi-directional texture competition and occlusion areas, and uses a layered interlacing potential energy model to decouple the conflict area into upper and lower layer stitch guide flow fields with a clear physical covering order. The resulting stitch arrangement avoids the problem of disordered stacking and tangled stitches at the intersection center of different levels of sewing threads, ensuring the three-dimensionality of the interlacing pattern, the natural and smooth flow of texture, and the flatness of the embroidery finished product surface.
[0046] 2. This invention introduces an adaptive step size correction mechanism and a stitch collision detection logic in the vector streamline tracking generation process. It can dynamically adjust the tracking integration step size and sampling interval according to the spatial distance of adjacent streamlines and the convergence and divergence characteristics of the local vector field. It automatically increases the step size in the vector contraction and high curvature regions and avoids the intersection and collision of adjacent streamlines, preventing the fabric from being punctured due to excessive needle density. It adaptively supplements and guides streamlines in the vector diffusion region, ensuring the uniform adaptive balance of stitch spacing. It effectively solves the problems of fabric holes and embroidery leaks that are easy to occur in traditional algorithms.
[0047] 3. This invention breaks through the limitations of pure geometric fitting in the needle step discretization process. It coordinates the local curvature of the streamline with the fabric deformation resistance parameters and the thread characteristic parameters, adaptively calculates the target needle step length and applies physical range constraints, and automatically inserts lock-needle compensation points at corners. This mechanism effectively eliminates the local tension concentration at high curvature corners, greatly reducing fabric arching, wrinkling, thread breakage and corner distortion during the embroidery process. This allows the automated pattern making solution to be perfectly adapted to various fabrics such as soft elastic fabrics, hard denim and silk, and significantly improves the quality and processing stability of finished embroidery products. Attached Figure Description
[0048] Figure 1 This is an overall flowchart of the method of the present invention;
[0049] Figure 2 This is a system architecture diagram of the present invention;
[0050] Figure 3 This is a flowchart of the interlacing region identification and conflict determination process of the present invention;
[0051] Figure 4 The flowchart for constructing the layered intertwined potential energy model and layered decoupling in this invention is shown below;
[0052] Figure 5 This is a flowchart of the adaptive flow step size and vector streamline generation of the present invention;
[0053] Figure 6 This is a flowchart of the physical parameter collaborative constraint and needle drop point discretization of the present invention. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] Please see Figure 1 and Figure 2As shown, the embroidery stitch generation method and system based on texture feature extraction mainly run on a computing device containing a processor, high-capacity memory, and storage. This computing device can be an industrial control computer, an embroidery digital pattern-making workstation, or a dedicated image processing server. At the physical hardware connection level, this computing device achieves bidirectional data communication with the electronic control motherboard of the CNC embroidery machine through an industrial communication bus. The CNC embroidery machine, as the physical execution terminal for generating the embroidery drive instruction set, mainly includes the following core hardware components: an X-ray machine for driving the embroidery frame to perform high-precision positioning in a two-dimensional plane. The machine includes a Y-axis servo / stepper drive motor, a Z-axis spindle drive motor for driving the embroidery machine head needle to reciprocate up and down, and an automatic thread-cutting solenoid valve for cutting the bottom thread when changing colors or skipping stitches. In the actual embroidery process, the computing device sends the binary drive data packet containing displacement vectors, piercing actions, and control codes generated by this method to the CNC embroidery machine in real time or transmits it all at once through the communication bus. This, in turn, drives the above-mentioned servo motors and solenoid valves to run in a predetermined sequence, completing high-precision stitch embroidery on the fabric to be embroidered, which is taut on the embroidery frame.
[0056] Furthermore, the system first executes S1, namely the target image acquisition and dual-field feature extraction operation. This process is specifically implemented by the system's image feature extraction module. As the system's data input and front-end image processing unit, the image feature extraction module receives the original target image to be embroidered and parses out the dual-field feature data describing the geometric texture and color boundary of the image, providing basic data support for the accurate determination of subsequent texture conflicts.
[0057] Specifically, the system first acquires an image of the target to be embroidered through an image acquisition device (such as a high-resolution scanner or industrial camera) or a data transmission interface, and represents it as image data in the form of a two-dimensional matrix. To eliminate high-frequency random noise and smooth out minor imperfections in the input image, the system first processes the target image. The system performs grayscale conversion and Gaussian smoothing filtering preprocessing. Then, it calculates the partial derivatives of the preprocessed image in the horizontal (X-axis) and vertical (Y-axis) directions. and Construct the corresponding pixel points The two-dimensional structure tensor matrix at the location In discrete image space, the solution of partial derivatives specifically employs... The Sobel derivative operator is used to approximate the calculation by performing a two-dimensional convolution operation on the preprocessed grayscale image matrix, and the horizontal convolution kernel is obtained. Convolution kernel in the vertical direction They are defined as follows:
[0058] ;
[0059] In specific operations, firstly The center of the convolution kernel covers the target pixel. The weight coefficients within the convolution kernel are multiplied sequentially by the gray values of the corresponding nine neighboring pixels of the image, and then summed to calculate the discrete partial derivatives of that point in the horizontal and vertical directions. and (in (representing a two-dimensional convolution operation), thereby constructing a two-dimensional structural tensor matrix. Its form of expression is:
[0060] ;
[0061] in, The standard deviation is expressed as Two-dimensional Gaussian smoothing kernel, The value range is preset to 1.0 to 3.0 (preferably 1.5 in this scheme), due to the second-order structure tensor matrix As it is a symmetric real matrix, the system then solves its characteristic equation. Eigenvalue decomposition of the matrix is performed, and the two univariate closed-form eigenvalues are directly obtained using the quadratic formula. and :
[0062] ;
[0063] Among them, taking the plus sign yields the largest eigenvalue. Taking the minus sign yields the smallest eigenvalue. (and satisfy) After obtaining the eigenvalues, the smallest eigenvalue is... Substitute into the homogeneous linear equation By solving for the solution vector orthogonal to the direction of the gradient maxima, and normalizing it, the pixel can be accurately obtained. The principal direction vector of the local texture at the location :
[0064] ;
[0065] All pixels in the entire image Convergence mapping, or the construction of local texture principal direction fields that form the entire image. This is done after calculating the eigenvalues. and Simultaneously, the image feature extraction module calculates the coherence of each pixel. :
[0066] ;
[0067] in To prevent tiny constants with a denominator of zero, this coherence degree The range of values for is strictly limited to Between these, it is used to measure the uniformity and stability of local texture directions ( The closer it is to 1, the clearer the texture direction, and it is saved as basic feature data for direct use by S2 later.
[0068] Meanwhile, to prevent the loss of complementary color boundaries in traditional grayscale conversion, color gradients are independently extracted in a multi-dimensional color space (such as Lab or RGB color spaces). Firstly, in the... Each color channel (in Lab space) Taking three channels as an example The Sobel operator was used to calculate the partial derivatives of the channel in the horizontal and vertical directions, respectively. and Then, the channel gradient magnitude at that point can be calculated. Next, the system iterates through these three channels, selects the channel with the largest gradient magnitude as the dominant color change channel, and determines its maximum value as the final color gradient magnitude of that pixel. :
[0069] ;
[0070] Let the channel index that provides the maximum gradient magnitude be . The system then takes the partial derivative component corresponding to that channel. Normalize to generate the color gradient vector of this pixel. :
[0071] ;
[0072] Color gradient vector of all pixels in the entire image With color gradient amplitude These converge to form a color gradient feature field. After completing the above feature calculations, the image feature extraction module will extract the calculated local texture principal direction field (containing each pixel). ), color gradient feature field (containing each pixel) and and coherence The data is written in real time and in parallel to the feature matrix data buffer allocated in the main memory of the system, providing a continuous data input for the subsequent calls and calculations of the conflict region identification module in S2.
[0073] After S1 completes the parallel writing of data and temporarily stores it in the feature matrix data buffer, the system transitions to S2, which is the operation of constructing interlacing region determination indicators and identifying texture conflict regions. This process is implemented by the system's conflict region identification module. As the system's data analysis and region decision-making unit, the conflict region identification module calls the local texture main direction field data and color gradient feature field data temporarily stored in the aforementioned feature matrix data buffer. By quantifying and calculating the degree of conflict between the local texture trend and the color structure boundary in the image, it accurately locks and delineates the texture conflict region of multi-directional texture competition and precisely outlines the boundary of the interlacing region, providing spatial mask data for subsequent hierarchical decoupling.
[0074] Please see Figure 3 As shown, specifically, the conflict region identification module first directly reads the pixel points calculated in S1 from the feature matrix data buffer. Texture principal direction vector at the location and coherence coherence The value is strictly limited to [0,1] and is used to quantify the stability and anisotropy intensity of the local texture direction. The closer the value is to 1, the clearer and more stable the main local texture direction at that point. Subsequently, the conflict region identification module extracts each pixel from the buffer. Color gradient vector at the location and color gradient amplitude Pre-extracted color gradient amplitude After normalization (the values are mapped to the closed interval [0,1]), it directly reflects the intensity of color abrupt changes at the pixel (i.e., the intensity of color edges).
[0075] Next, the conflict region identification module reads the texture principal direction vector. Similar to the aforementioned color gradient vector Calculate the absolute value of the dot product between the two to obtain the directional relationship parameter that represents the spatial angle between the texture trend and the color change direction. Its mathematical expression is as follows:
[0076] ;
[0077] In the formula, Represents pixels The principal direction vector of the local texture at a given location. Represents pixels The unit color gradient vector at that location, This is the absolute value of the cosine of the angle between the two vectors, and its value is strictly limited to the range [0,1]. In this process, the system combines the previously calculated coherence. To characterize the stability of local texture direction, in the physical logic of CNC embroidery pattern making, the embroidery needle usually moves along the main texture direction. The direction of the boundary normal where the colors change drastically is the color gradient vector. When the principal direction of the texture is perpendicular to the color gradient vector, the dot product of the two... A value close to 0 indicates that the needle's direction follows the color boundary distribution, and the two are coordinated; conversely, when... When the value is close to 1, it indicates that the main direction of the texture is parallel to the color gradient vector. This means that the embroidery needle will pass directly through the color boundary at a large angle, which can easily cause edge line punctures, color seams, or edge jaggedness during actual embroidery.
[0078] After completing the above parameter extraction and calculation, the conflict region identification module will determine the coherence. Color gradient amplitude and directional relationship parameters We perform weighted product operations to construct an interlacing region determination index that represents the interlacing relationship between texture direction and color change structure. Its core mathematical formula is expressed as follows:
[0079] ;
[0080] In the formula, For coherence, The color gradient magnitude and the two together constrain the judgment criterion to respond only in the effective area where the texture is clear and the color changes drastically. These are directional relationship parameters; The weighting index for adjusting direction / conflict sensitivity is preset to a range of values. to (In this scheme, it is preferably set as) When the direction of the needle strikes a color and creates a strong penetrating conflict (i.e., near When, factor Approaching Judgment indicators A high output response indicates a strong conflict between texture trends and color structure at that location; conversely, when both are aligned or located in a flat, textureless area, a low response indicates a lack of texture. Outputs a low response value.
[0081] The criteria for determining the interlacing regions of all pixels in the entire image are obtained. Subsequently, the conflict region identification module combines an adaptive threshold segmentation algorithm with an eight-connected domain analysis algorithm to determine the continuity of high and low values of the indicator, thereby determining the boundary of the interlacing region and identifying texture conflict regions. Specifically, a preset threshold is used. The preset determination method adopts a dynamic adaptive determination mechanism based on the statistical characteristics of the whole image: the conflict region identification module first counts the determination index of all pixels in the whole image. arithmetic mean with standard deviation This will then set a preset threshold. Determined as ,in The adjustment coefficient (the range of values is...) to In this scheme, the preferred setting is as follows: After normalization mapping, a preset threshold is set. The value is ultimately limited to Within the closed interval, when a certain pixel point The judgment index is greater than the preset threshold. (Right now When a pixel is found to be high-value candidate pixel, the system marks it as such.
[0082] Subsequently, the conflict region identification module performs 8-connected clustering analysis on the high-value candidate pixels marked on the entire image. When adjacent high-value candidate pixels are spatially clustered through an 8-connected relationship, and the area of the clustered continuous pixel block (i.e., the total number of continuous pixels contained therein) is greater than a preset pixel block threshold, the conflict region identification module will be selected. ( The value of is determined based on the image resolution, and is usually preset to 50 to 200 pixels. In this scheme, it is preferred to set it to 50 pixels. When the conflict area identification module determines that the continuous area belongs to the texture conflict area with multi-directional texture competition, on this basis, the interlacing area boundary refers to the outermost closed contour line of the continuous high-value pixel block that is determined to be the texture conflict area on the two-dimensional image plane (its essence is a sequence of closed polygonal boundaries composed of pixel coordinates, used to accurately divide the conflict area and the flat non-conflict area). The texture conflict area refers to the continuous two-dimensional image sub-region in which the local texture main direction is stable (high coherence), the color edge contrast is intense (large gradient amplitude), and the embroidery needle direction directly penetrates the color boundary at a large angle, thereby causing multi-directional texture competition and physical embroidery stitch conflict.
[0083] When generating the data representation, the conflict region identification module constructs a binary mask matrix of the entire image based on the aforementioned threshold determination and connected component clustering filtering results. Its mathematical construction logic is expressed as follows:
[0084] ;
[0085] That is, in the matrix In the process, pixels identified as texture conflict areas are assigned a value of 1, while pixels in flat, non-conflict areas and those less than or equal to 1 are assigned a value of 1. Isolated noise regions are all assigned a value of 0. Meanwhile, the conflict region identification module identifies the conflict region by following this continuous high-value pixel block (i.e., ...). Edge contour tracking is performed on the outer pixels of the region to accurately extract the coordinates of the outer boundary polygon of the texture conflict area, generating the final binarized mask matrix data. The binarized mask matrix data and the corresponding region coordinate set are pushed and written to the input data buffer of the next module (i.e., the deep layer decoupling module) in real time to ensure the continuity and integrity of the data flow.
[0086] After S2 completes the identification of texture conflict areas, precise positioning of interlaced area boundaries, and generation and writing of binary mask matrix data into the data buffer, the system transitions to S3, which performs hierarchical decoupling of texture conflict areas based on texture interlacing relationships and constructs a layered interlacing potential energy model. This process is specifically implemented by the system's deep hierarchical decoupling module. As the system's data decomposition, three-dimensional spatial representation, and flow field construction unit, the deep hierarchical decoupling module reads the binary mask matrix data of texture conflict areas output by S2 from the data buffer in real time, and analyzes the complex interlacing physical structure of the two-dimensional texture conflict areas marked by the mask. It decouples the originally interlaced and overlapping two-dimensional textures into two unidirectional flow fields with a physical covering order, thereby solving the problems of disordered stitch crossing, excessive local embroidery thickness, and broken needles and threads caused by multi-directional texture competition in traditional pattern making, and providing clear and conflict-free path guidance data for subsequent flow line tracking generation.
[0087] Please see Figure 4 As shown, firstly, the deep-level decoupling module is based on the binarized mask matrix data. Guided by the text, retrieve the texture conflict area (i.e. The structure tensor matrix of each pixel in the corresponding region (in S1) is stored in the feature matrix data buffer. Because there are two or more interwoven texture directions within a texture conflict area, the depth-level decoupling module addresses this area. The structure tensor matrix is subjected to local spectral decomposition and quadratic eigenvalue solving to obtain two orthogonal eigenvalues. and the corresponding unit eigenvector and The deep-level decoupling module extracts the region with the highest coherence (coherence is usually greater than the preset basic coherence threshold). The two dominant feature vectors are determined as the main direction vectors representing the first main texture direction. (by the largest eigenvalue) corresponding feature vector (orthogonal vector representation) and secondary direction vector representing the second primary texture direction (by the second eigenvalue) corresponding feature vector (orthogonal vector representation), where the main direction vector and the secondary direction vector are both normalized two-dimensional unit vectors, used to characterize the two sets of core needle patterns that interweave and intersect within the conflict area.
[0088] Then, in order to determine the spatial occlusion and coverage relationship between the two sets of interwoven textures in the actual physical expression of embroidery, the deep hierarchical decoupling module starts from the geometric centroid of the conflict area and decouples them along the main direction vector. and secondary direction vector The geometric extension trajectory extends outwards from the texture conflict area with a length of... Ray tracing (preset to 20 pixels) is used to extract the light and dark distribution features and color connectivity features of the corresponding texture blocks outside the edges of the conflict area, and the saliency scores of the texture blocks corresponding to the principal direction vector and the secondary direction vector are calculated respectively. and Among them, the characteristics of light and dark distribution ( By extracting the sampling points along the ray tracing path in the CIELAB color space The channel luminance value is obtained by dividing by 255, normalizing, and then taking the arithmetic mean; color connectivity characteristics. CIELAB color difference between adjacent sampling points along the ray path was calculated. and according to the formula Calculation yields (where) To preset the color tolerance, this scheme preferably sets it to 10.0), and the significance score... (or The value of is strictly limited to the closed interval [0,1], and its expression is:
[0089] ;
[0090] In the formula, For the first The average brightness of each texture block after normalization For the first The normalized color connectivity intensity of each texture block and These are the preset brightness weighting coefficient and connectivity weighting coefficient (satisfying...) In this scheme, the preferred preset is... , The closer the saliency score is to 1, the more prominent the texture block is in visual presentation and the more obvious the foreground features are.
[0091] Next, the deep-level decoupling module integrates the main direction vector. and secondary direction vector The spatial directional relationship between them, and the significance score calculated above. and Edge connectivity coefficient and the relationship of local gradient changes A layered cross-potential energy model is constructed to characterize the physical properties of interwoven fabrics, so as to accurately calculate the interweaving intensity between the texture blocks corresponding to the principal and secondary direction vectors. and coverage priority indicators The hierarchical cross-potential energy model, in its physical essence, is a virtual three-dimensional physical potential energy field constructed based on a two-dimensional image grid, used to fit the comprehensive physical distribution of visual saliency, directional conflict degree, and edge connectivity; the edge connectivity coefficient... (The numerical range is within) The closed interval is represented as the texture vector passing through the boundary point of the interlacing region and the stable texture vector outside the boundary. The absolute value of the dot product, i.e. This is used to measure the geometric continuity of textures as they cross boundaries; local gradient variation relationships. (Numerical normalization in) The closed interval is represented by the color gradient magnitude of all pixels within the conflict region. The arithmetic mean, i.e. (in the formula) (Total number of pixels within the conflict area), interleaving intensity in the hierarchical cross potential energy model. and the coverage priority index of the texture block corresponding to the main direction vector The core mathematical formulas are as follows:
[0092] ;
[0093] ;
[0094] In the formula, It is the absolute value of the cross product of two direction vectors, used to measure the degree of orthogonal intersection of two texture directions; The equilibrium weighting coefficients of the potential energy model (satisfying) In this embodiment, it is preferred to set ), interlacing strength The value of is within the closed interval [0,1], and the larger the value, the more severe the physical conflict when the two textures overlap in space; Coverage priority index For real values, when When 0, determine the principal direction vector. The coverage priority of the corresponding texture block is higher than that of the secondary direction vector. Corresponding texture block; conversely, when When determining the secondary direction vector Coverage priority is higher.
[0095] After completing the solution of the layered interweaving potential energy model, the deep layer decoupling module, based on the determined coverage priority relationship, separates the texture directions (such as the main direction vector) with higher interweaving intensity and higher coverage priority. Distributed to the upper needle-guided flow field , and another texture direction with relatively low interweaving intensity or low coverage priority (such as a secondary direction vector) Distributed to the lower needle-track guiding flow field This allows the two-dimensional conflict texture to be successfully decomposed into a two-layer vector flow field with a physical covering sequence (first the base embroidery layer is applied, then the top embroidery layer is superimposed).
[0096] Meanwhile, to prevent the lower layer stitches from accumulating too thickly below the upper layer stitches, leading to local hardening or stitch breakage, the deep-level decoupling module further locates the intersection and superposition center of the upper and lower flow fields: specifically, the deep-level decoupling module first solves the full-map interlacing overlap matrix. The system then searches for local maxima in the matrix and determines the pixel coordinates corresponding to these maxima as the intersection center. Subsequently, the deep-level decoupling module calculates the values of each pixel in the lower-level flow field. To the center of the intersection Euclidean distance And guide the flow field of the lower needle track. In the flow field guided by the upper needle track Apply rate attenuation coefficient to overlapping and exposed areas The rate attenuation coefficient The control formula is expressed as follows:
[0097] ;
[0098] In the formula, This represents the Euclidean distance from the current pixel to the center of the intersection of the lower and upper streamlines; The maximum attenuation amplitude coefficient is preset to a closed interval of [0.3, 0.7] (in this scheme, it is preferably set to 0.5, that is, the lower layer cable density is the highest at the crossover center, thus achieving the highest sparsity). ; The attenuation radius is the radius of influence for the attenuation effect (based on image resolution and embroidery area, the preset closed range is 10 to 50 pixels, and in this scheme, 20 pixels is preferred). The density attenuation coefficient is calculated using this formula. (The range of values is within) The flow field is directly influenced by the needle tracks in the lower layer, causing the density of the lower layer streamlines to gradually transition from sparse to dense along the intersection center outwards, thus ensuring the physical stacking flatness after hierarchical decoupling.
[0099] Ultimately, to ensure the correctness of data flow and the connectivity of system operation, the deep-level decoupling module uses a system-integrated layered buffer architecture to guide the upper-layer needle-track flow field generated by the decomposition. Matrix data and lower-layer needle-guided flow field with applied density attenuation coefficient Matrix data is written in parallel and temporarily stored in the corresponding upper and lower layer buffers. These two independent layer buffers act as a buffering intermediary and will seamlessly connect to the dual-channel parallel tracing unit in the next module (i.e., the streamline tracing generation module), ensuring the data independence and parallel computing smoothness of the upper and lower layer vector streamline cluster generation process.
[0100] S3 completes the hierarchical decoupling of texture conflict regions and generates an upper-layer needle-guided flow field with a physical coverage order. Guided flow field with lower needle tracks After the data is written in parallel and temporarily stored in the upper and lower layer buffers of the layered buffer architecture, the system transitions to S4, which involves adaptively correcting the flow step size based on real-time vertical distance and generating vector streamline clusters in the upper and lower needle-guided flow fields. This process is implemented by the system's streamline tracing generation module, which acts as the system's data reading, streamline numerical integration tracking, and streamline density control unit. Its function is to retrieve the upper and lower needle-guided flow field matrix data in parallel from the upper and lower layer buffers of the layered buffer architecture, respectively. The dual-channel parallel tracking unit integrated within the streamline tracing generation module independently reads the upper and lower layer data. This dual-channel parallel tracking unit includes an upper tracking channel and a lower tracking channel. Utilizing a multi-threaded parallel computing architecture, it performs streamline tracing along the vector direction in the upper and lower needle-guided flow fields, and synchronizes the vertical distance data between adjacent streamlines in real time through a shared memory area, thereby adaptively correcting the flow step size to maintain a predetermined streamline spacing (i.e., target streamline spacing) between the generated adjacent streamlines. It also suppresses the disordered intersection of streamlines at different levels, and finally generates vector streamline clusters (including upper vector streamline clusters and lower vector streamline clusters) that correspond to different levels of texture and have a predetermined line spacing. This process completely solves the problems of stitch stacking, holes or cross-interference caused by the fixed step length of streamline tracking in traditional embroidery pattern making, and provides high-precision streamline trajectories for subsequent needle point discretization and needle step cooperative constraints.
[0101] Please see Figure 5 As shown, firstly, the streamline tracing generation module reads the upper-layer needle-guided flow field. Guided flow field with lower needle tracks Next, the seed point placement positions are determined. To ensure that the streamlines can completely cover the embroidery area without any omissions, the streamline tracking generation module places the seed points at preset intervals at the edges of the stitch-guided flow field (i.e., the polygonal outline of the interlacing area output by S2) and in areas of varying texture density (i.e., areas where the color gradient amplitude changes drastically). Initial seed points are placed at equal intervals. Among them, the seed point placement spacing The value of depends strictly on the target cable spacing. This plan is pre-set Target cable spacing Then, based on the current flow field layer level (upper or lower) and the preset embroidery thread diameter... (For example, standard 40-gauge embroidery thread typically has a diameter of 0.2mm. The corresponding pixel distance in image space, mapped according to resolution, is [value missing] in this solution.) The target ribbon cable spacing of the upper layer is dynamically determined (pixels) and preset to [value]. The lower layer, however, has already had a density attenuation coefficient applied in S3. Its local target wiring spacing is adaptively adjusted to This ensures that the spacing between the lower layers automatically increases in the center area of the intersection to avoid stitch stacking.
[0102] Then, from each initial seed point Starting from this point, the dual-channel parallel tracking units of the streamline tracing generation module track along the tangent vector directions of their respective flow fields. (corresponding to the upper layer) The lower layer corresponds to ), with a preset initial integration step size (In this scheme, the preset number of pixels is 0.5, with a value range between [0.2, 1.0] pixels.) A fourth-order Runge-Kutta (RK4) numerical integration algorithm is used for bidirectional (forward and reverse vector directions) tracking to generate continuous vector streamlines. In physical and geometric terms, a vector streamline is a continuous geometric trajectory extending on a two-dimensional image plane, where the tangent direction at any point on the curve coincides with the vector direction of the guiding flow field at that point. It is used to represent the path of embroidery stitches on the fabric. During the RK4 numerical integration process, the currently determined sampling point is used as the current tracking point. (Initially, it is the seed point) Iterative calculations are performed along the tangent direction of the flow field vector to deduce the coordinates of the next sampling point extending along the streamline in both the forward and reverse vector directions, i.e., the next tracking point. By connecting the discrete tracking points generated in the order of calculation, a vector streamline representing the continuous embroidery thread trajectory is constructed through discretization. Calculate the next tracking point The position update formula is expressed as:
[0103] ;
[0104] ;
[0105] In the formula, The current adaptively corrected flow step size (initial value is...) ), For the point The normalized tangent direction vector of the flow field obtained by bilinear interpolation. This is a fourth-order integral slope trial term, used to comprehensively evaluate the step size within the interval. The changing trend of the internal flow field direction ensures the calculated next tracking point. High-precision fit to the real flow field trajectory.
[0106] Next, during the numerical integration tracking process, the streamline tracking generation module calculates the current tracking point in real time. Minimum vertical distance between and all generated adjacent streamlines within the same layer Specifically, to ensure the efficiency and data consistency of the dual-channel parallel tracing unit during independent parallel computation, a dedicated shared memory area is allocated in the system memory. This shared memory area establishes a high-concurrency R-tree spatial index structure based on lock-free atomic operations. When the upper-level thread group and the lower-level thread group perform RK4 numerical integration independently, each time a valid streamline sampling point coordinate (i.e., the next tracking point) is generated... That is, the coordinates of the current sampling point are written using a lock-free write command. The flow line ID and its level tag (upper or lower) are appended and updated in real time to the R-tree space index in the shared memory area; the minimum vertical distance is calculated during this process. At that time, the upper-level thread (or the lower-level thread) uses the current trace point Centered on the circle, with the maximum allowable distance To determine the search radius, submit read-only concurrent queries directly to the shared memory area, searching for neighboring streamline segments already generated within the index range, and calculating the points. Calculate the vertical projection distances to each segment of the adjacent streamline, and take the minimum value among them as the minimum vertical distance to the current point. This shared memory mechanism avoids the waiting delay caused by multi-threaded competition for mutex locks, and ensures millisecond-level real-time synchronization and efficient distance retrieval of pipeline space data across threads.
[0107] Subsequently, the streamline tracing generation module calculates the minimum vertical distance. The current flow step size is adaptively adjusted based on the preset distance constraint threshold. Alternatively, the streamline structure can be adjusted, where preset distance constraint thresholds include minimum safe distances. and the maximum allowable distance Its value range is strictly based on the target row spacing of the current level. Based on this standard, the minimum safe distance is set as follows in this scheme: (The range of values in the closed interval is within) If For example, then (number of pixels), the maximum allowable distance is determined to be... (The range of values in the closed interval is within) ,correspond (pixels)
[0108] When the minimum vertical distance calculated in real time is less than the minimum safe distance (i.e.) This indicates that the current streamline is too close to the adjacent streamline, and continued tracking will lead to streamline compression or overlap. In this case, the streamline tracking generation module adopts an adaptive step size reduction strategy, reducing the current integration step size. According to the step size reduction formula Perform dynamic shortening; if the shortened step size Less than the preset minimum step size (The default value in this scheme is 0.1 pixels), or The streamline tracing generation module immediately terminates further tracing of the current streamline and marks the endpoint as the streamline endpoint;
[0109] When the minimum vertical distance calculated in real time is greater than the maximum allowable distance (i.e.) This indicates that the current streamline distribution in the region is too sparse, posing a risk of gaps in the embroidery (exposed fabric). In this case, the streamline tracking generation module triggers the seed point adaptive completion mechanism, inserting a new seed point at the midline position between the current tracking point and the adjacent streamlines. The new seed point is then pushed into the current layer's queue of seed points to be tracked. A new integral tracking process is then initiated to complete the intermediate streamlines, ensuring that the vertical distance between generated adjacent streamlines is always strictly constrained. Within the corresponding allowable range, that is, within the range of Within the target cable spacing range centered on the target.
[0110] Finally, through independent numerical integration and adaptive step size correction in the upper and lower layers by the dual-channel parallel tracking unit, the streamline tracing generation module generates vector streamline clusters that are fully covered, uniformly laid out, and do not collide or intersect in a disordered manner in the upper and lower layers respectively (each containing the upper layer vector streamline set). With the lower layer of vector streamlines Each streamline consists of a series of two-dimensional discrete sampling point coordinates arranged in integral order. The streamline tracking generation module pushes the generated vector streamline cluster data and the hierarchical labels of each sampling point in real time and writes them into the data input buffer of the next module (i.e., the step-by-step discretization and instruction generation module) to ensure the continuity of data flow and the seamless connection of algorithm execution.
[0111] S4 completes the upper and lower layer vector streamline clusters (i.e., the upper layer vector streamline set). With the lower layer of vector streamlines After generating the data and pushing it to the data input buffer of the next module in real time, the system connects to S5, which is the operation of adaptively determining the needle drop coordinates and needle step length based on the local curvature of the vector streamline cluster, the fabric deformation resistance parameters and the thread characteristic parameters, and generating the embroidery machine drive instruction set. This process is specifically implemented by the system's needle step discretization and instruction generation module. The needle step discretization and instruction generation module, serving as the system's physical parameter mapping, discrete needle drop point decision-making, and embroidery machine's underlying drive encoding unit, receives vector streamline cluster data input from the streamline tracking generation module. Through its integrated physical parameter constraint mapping unit and instruction encoding unit, it discretizes the continuous vector streamline geometric trajectory into a sequence of needle drops conforming to the physical characteristics of embroidery machinery. Simultaneously, combining the physical coverage relationship of different layer levels (upper and lower layers) and lock-stitch compensation logic, it ultimately translates this data into a binary drive instruction set that can be directly read and executed by the embroidery machine hardware controller. This module solves problems such as fabric pleating, holes, thread breaks, and pattern distortion at corners caused by fixed needle steps in traditional pattern-making algorithms. It achieves high-precision mapping from virtual geometric streamlines to physical stitches. The entire S5 process is as follows:
[0112] Please see Figure 6 As shown, firstly, after receiving the vector streamline cluster data, the needle step discretization and instruction generation module initiates the discrete needle placement point decision process. Each vector streamline in the streamline consists of a series of two-dimensional discrete sampling points arranged in integral order. The physical parameter constraint mapping unit extracts the local curvature parameters formed by the continuous sampling points along the vector streamline cluster point by point, which is used to accurately characterize the degree of bending deformation of the streamline trajectory at each sampling point. For any sampling point on the vector streamline... The physical parameter constraint mapping unit selects its immediate vicinity of discrete sampling points. and The local curvature at this point is calculated using the three-point circumcircle arc fitting method. Specifically, the formula for calculating local curvature is expressed as follows:
[0113] ;
[0114] In the formula, The determinant of a two-dimensional vector matrix is arithmetically equal to the magnitude of the cross product of the two vectors; the denominator is the product of the three sides of a triangle formed by the three points, representing the calculated local curvature. The geometric unit is the reciprocal of the pixel. The larger the curvature value, the more intense the curvature of the streamline at that point, and the denser the stitch points are needed to accurately express the texture during embroidery. Conversely, the smaller the curvature value, the straighter the streamline tends to be, and the stitch length can be appropriately increased to improve embroidery efficiency.
[0115] Then, the physical parameter constraint mapping unit retrieves physical environment and material parameters from the system's preset memory, including the set of fabric deformation resistance parameters and thread characteristic parameters. The physical parameter constraint mapping unit internally establishes deformation resistance lookup tables (LUTs) corresponding to different fabric materials. Based on the current embroidery fabric type (such as silk, pure cotton, denim, or elastic knitted fabric) input by the user in the system interface, it retrieves and calls the corresponding set of fabric deformation resistance parameters from the deformation resistance lookup table. This set mainly includes the tensile modulus of elasticity in the warp and weft directions of the fabric. (physical unit is) For example, standard pure cotton plain cloth , elastic knitted fabric ) and shear yield strength of embroidered fabric (physical unit is) The thread characteristic parameters are directly read from the preset and stored thread physical characteristic parameters in S4, including the preset embroidery thread diameter. (e.g., 0.2mm), wire thickness parameters (e.g., linear density corresponding to 40-gauge thread) (tex) and the wire's flexibility limit bending radius (The physical unit is mm, such as the limit bending radius of standard polyester embroidery thread being 0.5 mm).
[0116] Subsequently, the physical parameter constraint mapping unit performs collaborative mapping and comprehensive matching between the curvature parameters in the geometric dimension and the material parameters in the physical dimension, adaptively calculating the target needle step length corresponding to each sampling point. And it is strictly constrained within a preset limit range. The specific calculation process is as follows:
[0117] Geometric constraint range determination: based on the local curvature at the sampling point. With the wire's flexibility limit bending radius To establish a functional relationship between geometric fitting error and needle step length, in order to ensure that the maximum chord difference when approximating the curve (vector streamline) with a broken line segment (needle step) does not exceed the preset geometric accuracy tolerance. (This plan is pre-set) mm (mapped to 1.0 pixel in image space), the curvature-based geometric constraint step length is derived from the geometric chord length formula. The calculation formula is:
[0118] ;
[0119] Deformation constraint range determination: Continuous needlework creates embroidery tension on the fabric. If the stitch length is too short, dense needlework can cause fabric fiber breakage or excessive local stretching. If the stitch length is too long, the stitch rebound tension can cause the fabric to bunch and fold. The physical parameter constraint mapping unit is based on the elasticity beam bending and tension balance model, according to the warp and weft tensile modulus of elasticity in the fabric deformation resistance parameter set. and wire thickness parameters Calculate the deformation constraint stitch length to prevent fabric gathering. The formula is:
[0120] ;
[0121] In the formula, This is a dimensionless material adjustment coefficient (for stiff, inelastic fabrics such as denim). For highly elastic and soft fabrics, ).
[0122] Cooperative matching and range constraints: Physical parameter constraints on the geometric constraints of the shooting element. With deformation constraint step We perform weighted collaborative matching and take the minimum value of the two as the baseline value for the adaptive target step length, that is:
[0123] ;
[0124] Meanwhile, the system is preset with a maximum needle length limit allowed by mechanical and technological constraints. Minimum needle length limit In this scheme, the maximum needle length is determined to be... (To prevent the stitches from being too long and easily snagged or loosened, the value should be within the closed interval range.) The corresponding image space pixel value (number of pixels), minimum needle length determined as (To prevent the needles from falling too densely and puncturing the fabric, the value should be taken within the closed interval range.) The corresponding image space pixel value (pixels), the physical parameter constraint unit constrains the calculated reference value within the range Finally, the adaptive target step length corresponding to each sampling point is obtained. The formula is:
[0125] ;
[0126] Following this, after obtaining the adaptive target needle step length, the needle step discretization and command generation module performs discrete needle landing point coordinate decision-making and special needle stitch compensation on the vector streamline. Starting from the starting point of the vector streamline, the arc length is accumulated along the streamline geometric trajectory. Whenever the accumulated arc length reaches the adaptive target needle step length calculated at the current position... At this point, the coordinates of a physical needle landing point are determined and output. During the discretization process, the needle step discretization and instruction generation module monitors in real time the angle between the tangents of the polygonal line segment formed by adjacent needle placement points (i.e., the curvature of the turning angle). When the angle between two adjacent needle step vectors... Greater than the preset corner curvature threshold Time (preset in this plan) The range of the closed interval is This indicates that the embroidery needle makes a sharp turn at this point. If the needle were to proceed directly, the base material would be exposed at the corner or the thread would come loose. In this case, the instruction encoding unit automatically inserts a lock-needle compensation point containing 3 tiny matrix points (the needle step length is preset to a fixed 1.0mm) at the corner point, and repeatedly reinforces the origin point with needles to form a continuous stitch path that can express the folding shape of high-frequency texture corners and meet the constraints of fabric deformation and mechanical tension.
[0127] Finally, after all vector streamlines are discretized into a sequence of needle landing point coordinates, the instruction encoding unit, based on the physical coverage relationship between the upper and lower needle-guided flow fields determined by S3, arranges the execution order of the needle tracks: prioritizing the output of the lower vector streamline cluster. The corresponding discrete needle point sequence (i.e., the needle stitches of the lower layer) is output after all the streamline needle stitches of the lower layer are arranged in sequence. The corresponding discrete stitch sequence (i.e., the stitches of the upper layer) is used, and a thread-cutting instruction code is automatically inserted at the transition between the upper and lower layers. The instruction encoding unit digitizes this series of stitch sequence containing spatial coordinates and execution order according to the control communication protocol of the embroidery machine hardware (such as standard DST, DSB, or EXP format), and formats and encapsulates it to generate a formatted package containing the relative displacement vector of the embroidery frame. The bitmap control sequence of the embroidery head lifting embroidery pulse, automatic thread cutting control code, color changing control code, and end code ultimately constitutes a complete embroidery machine drive instruction set and is output to the hardware controller of the embroidery machine to drive the embroidery needle and embroidery frame to accurately complete the embroidery action according to the predetermined trajectory.
[0128] In summary, this invention provides a method and system for generating embroidery stitches based on texture feature extraction. By extracting multi-dimensional features from the main texture direction and color gradient of the target image, an interlacing region determination index is constructed to accurately identify and decouple texture conflict regions. A layered interlacing potential energy model is used to generate upper and lower layer stitch guide flow fields with physical covering order. Furthermore, a uniform and smooth vector streamline cluster is generated by combining the RK4 numerical integration algorithm and adaptive step size correction mechanism. Local curvature, fabric deformation resistance, and thread characteristic parameters are further integrated for collaborative mapping and discretization constraints. Finally, an embroidery machine drive instruction set with both texture expression accuracy and mechanical feasibility is generated. This effectively solves the problems of stitch stacking, holes, fabric folding, and corner distortion caused by texture intersection in traditional pattern making methods, and significantly improves the intelligence level of automated embroidery pattern making and the quality of finished embroidery products.
[0129] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a reference structure" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0130] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for generating embroidery stitches based on texture feature extraction, characterized in that: The method includes the following steps: S1: Obtain the target image to be embroidered, extract the local texture principal direction field of the target image, and calculate the color gradient feature field of the target image. The color gradient feature field includes the color gradient vector and gradient magnitude corresponding to each pixel position. S2: Based on the local texture principal direction field and color gradient feature field, construct an interlacing region determination index to characterize the interlacing relationship between texture direction and color change structure, and identify texture conflict regions with multi-directional texture competition based on the interlacing region determination index. S3: Perform hierarchical decoupling of texture conflict regions based on texture interweaving relationship, construct a layered interweaving potential energy model corresponding to the texture conflict region, determine the coverage priority relationship between different texture directions based on the layered interweaving potential energy model, and decompose the two-dimensional texture of the texture conflict region into an upper needle-guided flow field and a lower needle-guided flow field with physical coverage order. S4: In the upper and lower needle-guided flow fields, streamlines are tracked along the vector direction, and the flow step size is adaptively corrected based on the real-time vertical distance between the tracking paths. This ensures that adjacent streamlines maintain a preset line spacing and suppresses disordered intersections of streamlines at different levels, generating vector streamline clusters that correspond to different levels of texture and have a predetermined line spacing. S5: Calculate the local curvature of the vector streamline cluster at each sampling point, obtain the fabric deformation resistance parameters and thread characteristic parameters corresponding to the sampling points, perform collaborative constraints on the needle step length based on the local curvature and fabric deformation resistance parameters, adaptively determine the needle drop point coordinates and needle step length, and determine the needle execution order based on the coverage relationship between different levels of needle stitches, and generate the embroidery machine drive instruction set.
2. The embroidery stitch generation method based on texture feature extraction according to claim 1, characterized in that: The steps involved in S2 to construct the interlacing region determination index and identify texture conflict regions are as follows: S21: Calculate the principal direction vector of texture and coherence of each pixel in the target image using the structure tensor matrix; S22: Use gradient operators to calculate the color gradient vector and gradient magnitude of each pixel; S23: Calculate the directional relationship parameters between the principal texture direction vector and the color gradient vector, and combine the coherence of the principal texture direction to characterize the stability of the local texture direction; S24: The coherence, gradient magnitude and directional relationship parameters are weighted and multiplied to construct the judgment index. The boundary of the interlacing region is determined by combining the index continuity of adjacent pixels in the texture conflict region. When the judgment index is greater than the preset threshold and a continuous high index value region is formed between adjacent pixels, the corresponding region is determined to belong to the texture conflict region.
3. The embroidery stitch generation method based on texture feature extraction according to claim 1, characterized in that: The hierarchical decoupling of texture conflict regions in S3 includes the following steps: S31: Extract two intersecting texture directions with high coherence within the texture conflict region, and determine the primary direction vector and secondary direction vector respectively; S32: Based on the light and dark distribution and color connectivity of the edge of the conflict area, calculate the saliency score of the texture block corresponding to the main direction vector and the secondary direction vector respectively; S33: Based on the directional relationship between the main direction vector and the secondary direction vector, the saliency score of the corresponding texture block, the edge connectivity relationship, and the local gradient change relationship, a hierarchical interweaving potential energy model is constructed to calculate the interweaving intensity and coverage priority relationship between the texture blocks corresponding to the main direction vector and the secondary direction vector. S34: Based on the layered interlacing potential energy model, determine the coverage priority relationship, assign the texture direction with higher interlacing intensity and higher coverage priority to the upper needle guide flow field, assign the other texture direction to the lower needle guide flow field, and apply a density attenuation coefficient to the lower needle guide flow field in the region where it overlaps with the upper needle guide flow field, so that the line density of the lower streamline is gradually adjusted outward from the intersection center.
4. The embroidery stitch generation method based on texture feature extraction according to claim 1, characterized in that: The step size adaptively corrected based on real-time vertical distance and the vector streamline cluster generated in S4 includes the following steps: S41: Initial seed points are placed at equal intervals at the edges of the needle-guided flow field and in areas where texture density changes; S42: Starting from each initial seed point, perform numerical integration tracking along the tangent direction of the flow field with a preset initial step size to generate continuous streamlines; S43: During the integral tracking process, the minimum vertical distance between the current tracking point and the generated adjacent streamlines is calculated in real time, and the corresponding target line spacing is determined according to the level of the current streamline. S44: When the minimum vertical distance is less than the preset minimum safe distance, shorten the current integration step or terminate the tracking of the current streamline. When the minimum vertical distance is greater than the preset maximum allowable distance, insert a new seed point between adjacent streamlines and continue tracking so that the generated adjacent streamlines remain within the allowable range corresponding to the target streamline spacing.
5. The embroidery stitch generation method based on texture feature extraction according to claim 1, characterized in that: The adaptive determination of the needle placement point coordinates and needle step length in S5 includes the following steps: S51: Extract the local curvature parameters formed by continuous sampling points along the vector streamline cluster, and determine the degree of curvature change corresponding to each sampling point; S52: Obtain the preset set of fabric deformation resistance parameters, as well as the wire thickness and flexibility parameters; S53: Determine the geometric constraint range of the needle step length based on the local curvature parameters, and determine the deformation constraint range of the needle step length based on the set of fabric deformation resistance parameters. Perform a coordinated matching between the geometric constraint range and the deformation constraint range to obtain the adaptive target needle step length corresponding to each sampling point, and constrain the adaptive target needle step length within the preset maximum needle length and minimum needle length limit range. S54: Discretize the needle drop point coordinates on the vector streamline according to the determined target needle step length, determine the needle density according to the curvature change between adjacent needle drop points, and insert lock needle compensation points at positions where the corner curvature is greater than the preset threshold to form a needle path that satisfies the texture direction expression and fabric deformation constraints.
6. The system corresponding to the embroidery stitch generation method based on texture feature extraction according to claim 1, characterized in that: The system includes: The image feature extraction module is used to acquire the target image to be embroidered, extract the local texture principal direction field of the target image, and calculate the color gradient feature field of the target image. The conflict region identification module is used to construct interlaced region judgment index based on the local texture main direction field and color gradient feature field, and to identify texture conflict regions with multi-directional texture competition. The deep hierarchical decoupling module is used to perform hierarchical decoupling of texture conflict areas based on texture interweaving relationships. It decomposes the two-dimensional texture of the texture conflict area into an upper-layer needle-guided flow field and a lower-layer needle-guided flow field with a physical covering order. The streamline tracing generation module is used to perform streamline tracing along the vector direction in the upper and lower needle-guided flow fields, respectively, and adaptively correct the flow step size based on the real-time vertical distance between the tracing paths to generate a vector streamline cluster with hierarchical correspondence and predetermined line spacing. The needle step discretization and instruction generation module is used to calculate the local curvature of the vector streamline cluster at each sampling point, obtain the fabric deformation resistance parameters and thread characteristic parameters corresponding to the sampling points, perform collaborative constraints based on the local curvature and the fabric deformation resistance parameters, adaptively determine the needle drop point coordinates and needle step length, and determine the needle execution order based on the coverage relationship between different levels of needle stitches, and generate the embroidery machine drive instruction set.
7. The embroidery stitch generation method and system based on texture feature extraction according to claim 6, characterized in that: The system also includes a layered buffer architecture. After the deep layer decoupling module decomposes and generates the upper-layer needle-guided flow field and the lower-layer needle-guided flow field, it writes the upper-layer and lower-layer flow field data into the corresponding upper-layer layer buffer and lower-layer layer buffer in parallel.
8. The embroidery stitch generation method and system based on texture feature extraction according to claim 7, characterized in that: The streamline tracing generation module includes a dual-channel parallel tracing unit, which independently reads data from the upper layer cache area and the lower layer cache area to perform streamline tracing, and synchronizes the vertical distance data between adjacent streamlines in real time through a shared memory area.
9. The embroidery stitch generation method and system based on texture feature extraction according to claim 6, characterized in that: The needle step discretization and instruction generation module includes a physical parameter constraint mapping unit and an instruction encoding unit. The physical parameter constraint mapping unit establishes a deformation resistance lookup table corresponding to different fabric materials. The instruction encoding unit generates a bitmap control sequence containing machine head lifting pulses, embroidery frame displacement vectors, and thread cutting control codes according to the adaptive target needle step length and lock needle compensation point and the control protocol of the embroidery machine.
