Miao embroidery pattern data adaptation generation method and system
By acquiring the initial filler border, dynamic unit quantity, and gap compensation amount of Miao embroidery pattern data, the problem of automatic adaptation of Miao embroidery patterns on the carrier area was solved, realizing the uniform distribution of pattern units on the carrier and detail protection, and improving data adaptation efficiency and application feasibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 贵州轻工职业大学
- Filing Date
- 2025-12-01
- Publication Date
- 2026-05-01
AI Technical Summary
Existing digital processing methods struggle to achieve automatic and efficient layout on the target carrier area during the adaptation of Miao embroidery patterns, resulting in pattern unit overflow or distortion, failing to balance carrier adaptability, detail fidelity, and layout aesthetics.
By obtaining the initial filler border, dynamic unit quantity, and gap compensation amount of the target unit, and combining the color complexity-driven amplification mechanism, a set of coordinate points of the target filler border is generated to ensure that the pattern units are evenly distributed on the carrier and maintain the integrity of details.
It achieves strict adaptation of pattern units on the carrier, avoids overflow and distortion, forms a uniform gap distribution, and improves the data adaptation efficiency and feasibility of large-scale application of personalized customized products.
Smart Images

Figure CN121962332A_ABST
Abstract
Description
A method and system for adapting and generating Miao embroidery pattern data Technical Field
[0001] This invention relates to the field of data processing technology, specifically to a method and system for adapting and generating Miao embroidery pattern data. Background Technology
[0002] In the field of digital design and production of Miao embroidery patterns, especially when it involves the intelligent application of existing Miao embroidery patterns to modern clothing, handicrafts and other carriers, how to achieve automatic, efficient and visually coordinated adaptation and layout of complex Miao embroidery patterns on the carrier area is a research direction for those skilled in the art.
[0003] Existing digital processing methods typically employ fixed scaling ratios or mechanical arrangement rules. When the size or aspect ratio of the target carrier area (such as the placket, cuffs, or irregularly shaped decorative surfaces) varies, fixed-size pattern units either fail to fill the effective area, resulting in abrupt blank spaces, or overflow the boundaries due to forced stretching, destroying the integrity. Furthermore, Miao embroidery patterns possess rich and varied color layers. If the color complexity of the units themselves (such as high saturation or areas of multi-colored interweaving) is ignored, simply scaling by area will cause densely detailed units to become severely distorted after shrinking, losing the delicate beauty of the ethnic patterns. Finally, existing algorithms struggle to achieve a dynamic balance between the number of pattern units and their spacing. Manually adjusting the unit spacing is time-consuming and easily creates uneven grid spacing, disrupting the overall rhythm of the pattern and the harmonious unity of the carrier form. These limitations severely restrict the large-scale application of Miao embroidery patterns in personalized customized products, necessitating an automated generation method that simultaneously considers carrier adaptability, detail fidelity, and layout aesthetics. Summary of the Invention
[0004] In view of the technical problems described in the background section, the present invention provides a method and system for generating Miao embroidery pattern data adaptation.
[0005] A method for adapting and generating Miao embroidery pattern data includes: inputting a scanned image of a Miao embroidery pattern, obtaining target units and their corresponding outlines based on the scanned image, and obtaining an initial filler border based on the outlines, wherein the filler border is a rectangle with the smallest area that surrounds the entire target unit; obtaining a target carrier region, obtaining a maximum target area based on the target carrier region, obtaining a magnification factor based on the number of color types corresponding to the target unit, and obtaining a target filler border based on the magnification factor, the maximum target area, and the initial filler border; obtaining the number of dynamic units based on the target carrier region and the target filler border, and obtaining a gap compensation amount based on the number of dynamic units, the target filler border, and the target carrier region; generating a set of coordinate points for all target filler borders within the target region based on the gap compensation amount, the number of dynamic units, and the target filler border, and generating Miao embroidery pattern data including a set of coordinate points for the outlines corresponding to all target units based on the set of coordinate points for all target filler borders.
[0006] Optionally, obtaining the maximum target area based on the target carrier region includes: obtaining a single rectangular box that can be located within the target carrier region, and defining the maximum area of the rectangular box as the maximum target area.
[0007] Optionally, obtaining the magnification factor based on the number of color types corresponding to the target unit includes: obtaining the number of color types corresponding to the target unit as the base number, and obtaining a preset number threshold; if the base number exceeds the preset number threshold, dividing the difference between the base number and the preset number threshold by the preset number threshold to obtain the magnification factor; if the base number does not exceed the preset number threshold, using zero as the magnification factor.
[0008] Optionally, obtaining the target padding border based on the magnification factor, the maximum target area, and the initial padding border includes: adding 1 to the magnification factor to obtain the magnification ratio; multiplying the area of the initial padding border by the magnification ratio to obtain the target area; proportionally magnifying the initial padding border to obtain the target padding border with an area equal to the target area; if the area of the target padding border is greater than the maximum target area, then resetting the target padding border to a rectangle with an area equal to the maximum target area.
[0009] Optionally, obtaining the number of dynamic units based on the target carrier region and the target padding border includes: dividing the area of the target carrier region by the area of the target padding border and rounding down to obtain the number of dynamic units.
[0010] Optionally, obtaining the gap compensation amount based on the number of dynamic units, the target filling border, and the target carrier area includes: multiplying the number of dynamic units by the area of the target filling border to obtain the total occupied area; subtracting the total occupied area from the area of the target carrier area to obtain the gap area; dividing the gap area by the number of dynamic units to obtain the unit gap; and defining the unit gap as the gap compensation amount.
[0011] A Miao embroidery pattern data adaptation and generation system is also provided. The system includes: an acquisition module, used to input a scanned image of a Miao embroidery pattern, and acquire target units and their corresponding outlines based on the scanned image, and acquire initial filler borders based on the outlines, wherein the filler borders are rectangles with the smallest area that surround the entire target unit; a first data processing module, used to acquire a target carrier area, acquire the maximum target area based on the target carrier area, acquire a magnification factor based on the number of color types corresponding to the target unit, and acquire target filler borders based on the magnification factor, the maximum target area, and the initial filler borders; a second data processing module, used to acquire the number of dynamic units based on the target carrier area and the target filler borders, and acquire gap compensation based on the number of dynamic units, the target filler borders, and the target carrier area; and a data generation module, used to generate a set of coordinate points for all target filler borders within the target area based on the gap compensation, the number of dynamic units, and the target filler borders, and to generate Miao embroidery pattern data including a set of coordinate points for the outlines corresponding to all target units based on the set of coordinate points for all target filler borders.
[0012] Optionally, the first data processing module is further configured to: acquire a single rectangular box that can be located within the target carrier area, and define the maximum area of the rectangular box as the maximum target area.
[0013] Optionally, the first data processing module is further configured to: obtain the number of color types corresponding to the target unit as the base number, and obtain a preset number threshold; if the base number exceeds the preset number threshold, divide the difference between the base number and the preset number threshold by the preset number threshold to obtain the amplification factor; if the base number does not exceed the preset number threshold, use zero as the amplification factor.
[0014] Optionally, the first data processing module is further configured to: add 1 to the magnification factor to obtain the magnification ratio, multiply the area of the initial padding border by the magnification ratio to obtain the target area; magnify the initial padding border proportionally to obtain the target padding border with an area equal to the target area; if the area of the target padding border is greater than the maximum target area, reset the target padding border to a rectangle with an area equal to the maximum target area.
[0015] The beneficial effects of this invention are reflected in the following aspects: In the entire Miao embroidery pattern data adaptation and generation method, firstly, by utilizing the maximum target area calculation based on physical space constraints and the dynamic amplification mechanism driven by color complexity, it is ensured that the pattern unit size can strictly adapt to the carrier boundary to avoid overflow, and can automatically protect the details of high-complexity units from being compressed according to the color quantity threshold, thus eliminating to a certain extent the problems of white space, overflow, or detail distortion caused by fixed scaling in existing methods; furthermore, through the precise calculation of the number of dynamic units and the amortized gap compensation, the remaining space of the carrier is converted into unit gap amount and uniformly injected into the arrangement grid, forming a mathematically equal gap distribution while ensuring the integrity of the units, achieving visually coordinated arrangement of patterns on any carrier without manual intervention, and completely avoiding the defects of uneven gaps or rhythmic imbalance caused by mechanical arrangement; finally, with the help of the stability of the relative coordinate system and the automation of coordinate mapping, all units are efficiently converted into contour coordinate data that can directly drive production equipment while maintaining the original proportion and wrapping relationship. Attached Figure Description
[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0017] Figure 1 is a schematic diagram of the steps of the Miao embroidery pattern data adaptation and generation method of the present invention; Figure 2 is a schematic diagram of a part of the steps of S2 in the Miao embroidery pattern data adaptation and generation method of the present invention; Figure 3 is a schematic diagram of another part of the steps of S2 in the Miao embroidery pattern data adaptation and generation method of the present invention; Figure 4 is a schematic diagram of a part of the steps of S3 in the Miao embroidery pattern data adaptation and generation method of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0019] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0020] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0021] As shown in Figures 1 to 4, a method for adapting and generating Miao embroidery pattern data is provided. In one embodiment, the method includes: S1, inputting a scanned image of a Miao embroidery pattern, obtaining target units and their corresponding outlines based on the scanned image, and obtaining an initial filler border based on the outlines, wherein the filler border is a rectangle with the smallest area that surrounds the entire target unit; S2, obtaining a target carrier region, obtaining the maximum target area based on the target carrier region, obtaining a magnification factor based on the number of color types corresponding to the target unit, and obtaining a target filler border based on the magnification factor, the maximum target area, and the initial filler border; S3, obtaining the number of dynamic units based on the target carrier region and the target filler border, and obtaining a gap compensation amount based on the number of dynamic units, the target filler border, and the target carrier region; S4, generating a set of coordinate points for all target filler borders within the target region based on the gap compensation amount, the number of dynamic units, and the target filler border, and generating Miao embroidery pattern data including a set of coordinate points for the outlines corresponding to all target units based on the set of coordinate points for all target filler borders.
[0022] In this embodiment, it should be noted that in S1, a precise basic geometric reference frame is established for the subsequent adaptive layout. Its input is a digitized scanned image of the Miao embroidery pattern.
[0023] First, it is necessary to identify and separate the "target units" that serve as basic compositional elements from the image. These target units can be complete, independent patterns, such as butterfly or dragon motifs, or reusable components within a pattern with specific meaning, such as a petal or a geometric symbol. The identification process typically relies on image segmentation techniques, dividing discrete regions with clear semantic or aesthetic value from the scanned image based on color, texture, or edge features, ensuring that each target unit possesses visual integrity and reusability. Subsequently, for each identified target unit, its "contour line" needs to be precisely extracted. The contour line is a set of closed curves that clearly define the external shape and internal (if any) boundaries of the target unit. Obtaining the contour line involves tracking and vectorizing the edges of the target unit, forming one or more ordered sequences of coordinate points that precisely describe the external shape and internal structural boundaries of the target unit.
[0024] Furthermore, after successfully obtaining a clear outline of the target cell, S1 generates an initial padding bounding box around the target cell. This initial padding bounding box is defined as an axially aligned rectangle with the smallest area that can completely contain and surround the entire target cell (including the area defined by all its outlines). The goal is to find a rectangle with four sides parallel to the coordinate axes and the smallest total area, ensuring that all pixels or outline points of the target cell are located inside or on the boundary of this rectangle.
[0025] Next, instead of directly recording the absolute position coordinates of the initial filler border in the overall image coordinate system, S1 records the distance relationship between the four vertices of the rectangle and a reference point of the target unit itself (usually the geometric center point of the unit). The values of these relative distances in the horizontal and vertical directions constitute the relative coordinates of the four vertices.
[0026] This relative coordinate representation offers significant stability: regardless of where the target cell's center point is moved or positioned within the carrier region in subsequent steps (where its absolute coordinates change), the relative distances between these four vertices and the center point remain constant. This means that the initial dimensions (width and height) of the filler border and the enclosure relationship it forms around the target cell are constant, providing a fixed dimensional reference and positional offset baseline for the cell. This facilitates subsequent steps of overall movement, scaling, and array arrangement while maintaining the cell's inherent proportions and enclosure relationships.
[0027] In S2, by comprehensively evaluating the physical constraints of the carrier and the characteristics of the pattern itself, a dynamically adjusted unit bounding box (i.e., the target filling border) is determined for subsequent layout calculations.
[0028] First, the precise geometric parameters of the target carrier region need to be obtained. The target carrier region refers to the actual surface area that the embroidery pattern will ultimately fit and fill, such as the rectangular front panel of a garment or the unfolded planar diagram of a curved fabric cover. The shape boundary of this region needs to be analyzed to calculate the characteristic value of its maximum usable space. Specifically, this involves finding the rectangle with the largest area among all possible rectangles that can be built into the carrier region and defining its area as the "maximum target area." This parameter represents the maximum theoretical upper limit of space that a single pattern unit can accommodate on the carrier without trimming.
[0029] While acquiring physical constraints, S2 simultaneously analyzes the aesthetic characteristics of the pattern, namely the color complexity of the target unit. Color complexity is quantified by counting the number of independent color types appearing within the unit; for example, a butterfly pattern containing four colors—dark blue, light blue, white, and silver—has a base number of 4. An empirical threshold is preset. If the base number exceeds this threshold, it indicates that the unit has high color density (multi-color interlacing areas are prone to color mixing distortion due to shrinkage), and a magnification factor greater than 1 needs to be generated; otherwise, no magnification is needed, and the factor is zero. This solves the problem of color detail distortion to a certain extent and quantifies the degree of magnification, allowing complex units to receive reasonable and accurate protective magnification.
[0030] Furthermore, after completing the above parameter preparation, S2 adjusts the size based on the initial filler border (i.e. the reference rectangle of the smallest enclosing unit) and its relative coordinate system obtained by S1, combined with the magnification factor.
[0031] The adjustment process involves two steps: First, the actual scaling ratio is derived based on the magnification factor. When magnification is required (factor > 0), the scaling ratio equals the factor plus 1; if no magnification is needed (factor = 0), the scaling ratio is 1. Then, the area of the initial filler border is multiplied by this scaling ratio to obtain the new area value, i.e., the "target area." It is particularly important to emphasize that this scaling process strictly maintains the aspect ratio of the initial rectangle, generating a new rectangular target filler border through proportional magnification. If the magnification factor is zero, the target filler border coincides with the initial filler border. The essential function of this new border is to establish aesthetically optimized layout units for the cells: its area is limited by the maximum target area of the carrier (ensuring physical adaptability), and a color-related magnification mechanism is used to avoid over-compression of highly complex units (ensuring detail fidelity), while inheriting the relative coordinate characteristics of the initial border (maintaining a constant positional relationship between the geometric center of the unit and the border).
[0032] In S3, given the known carrier space and unit size, the number and spacing distribution of pattern units are precisely planned to achieve automated and homogeneous layout.
[0033] S3 first needs to calculate the dynamic unit number, which is the maximum integer number of target filler borders that the target carrier region can accommodate. The calculation logic is based on the geometric relationship between the total effective area of the target carrier region and the area of a single target filler border: the total area of the carrier region is divided by the area of a single unit border, and the result is rounded down. Rounding down ensures that the calculated result is an integer not exceeding the theoretical maximum value, thus preventing units from exceeding the carrier boundary. For example, when the carrier region is an irregular polygon, even if the local space can accommodate additional units, if the decimal part of the overall calculation is less than the area of a complete unit, the remainder is discarded. This conservative strategy ensures that all generated units can be completely placed within the carrier, directly addressing the issue of pattern unit overflow in the background technology. The output of the dynamic unit number provides the core constraint for subsequent gap calculation and is also a key parameter for controlling the pattern distribution density at the macro level.
[0034] Furthermore, based on the determined number of dynamic elements, S3 further calculates the gap compensation amount, which is used to ensure that a uniformly distributed gap mesh is formed between the elements.
[0035] The calculation process consists of three stages: First, based on the determined number of units, the total area occupied by all units in an ideal, gap-free state is calculated, which is the number of units multiplied by the area of a single unit's border. Second, the difference between the total area of the carrier region and this total occupied area is calculated; this difference represents the sum of unused blank areas in the carrier, i.e., the gap area. Finally, the total gap area is evenly distributed among all units. It is important to note that this distribution is not a physical division of space, but rather the division of the total gap area by the number of units to obtain the average gap value that each unit should share, defined as the gap compensation amount. For example, if the carrier has remaining long, narrow gaps, they will not be forcibly filled into specific row and column gaps, but rather abstracted as an equal buffer space to be reserved around each unit. This design ensures that the final layout fully utilizes the carrier space while eliminating the subjectivity of manual adjustments through equal distribution, guaranteeing uniform gaps and providing a spatial allocation basis for S4 to generate a set of regular coordinate points.
[0036] In S4, the spatial parameters calculated in the previous steps are transformed into executable pattern layout coordinate data, completing the final mapping from abstract calculation to entity arrangement. First, based on the dynamic unit number and gap compensation amount output in S3, and combined with the target filler border size determined in S2, a set of coordinate points for all unit bounding boxes (i.e., the target filler border) within the target carrier region is generated. The underlying logic for coordinate generation is based on a regular mesh deformation strategy: starting from a reference corner of the carrier region (such as the lower left corner), a theoretically full-coverage mesh is constructed according to the width and height of the target filler border; then, the gap compensation amount calculated in S3 is evenly injected into the row and column gaps of each unit.
[0037] For example, if the target filler border is rectangular, the grid spacing will be expanded in the row and column directions. The expansion amount is determined by the projection values of the gap compensation amount in the horizontal and vertical dimensions (the projection method depends on the carrier shape and the orientation of the arrangement axis). This injection is not a simple expansion of the cell spacing, but rather a recalculation of the absolute coordinates of the center point of each cell border, so that they are evenly distributed within the carrier space. All generated target filler borders are completely located within the carrier boundary, and the gaps between adjacent borders are strictly equal.
[0038] Furthermore, after obtaining the coordinate set of all target filler borders, S4 performs the final pattern data synthesis. This process relies on the relative coordinate system established in S1: the contour coordinates of each target unit are originally defined relative to its own geometric center point (associated with the relative coordinates of the initial filler borders). The coordinate positions of each target filler border are traversed; this position is essentially the target geometric center point of the current unit. The relative coordinates of all points on the contour line are superimposed onto the absolute coordinates of this center point, thus completing the overall translation and positioning of the contour line.
[0039] For example, the outline point coordinates inside a butterfly pattern unit originally describe the relative positional relationship between the edge of the wing and the center of the butterfly. When the unit is positioned on a certain filler border on the carrier, the original relative coordinates can be superimposed with the center point coordinates of the border to obtain the precise outline coordinates of the butterfly in the carrier coordinate system.
[0040] The final output Miao embroidery pattern data is a complete set of outline coordinates covering all units within the entire carrier area. Its characteristics include: all units strictly maintain their original proportions according to the calculated dimensions (avoiding forced stretching); high-color-complexity units have their details protected through the S2 magnification mechanism (avoiding distortion and shrinkage); and mathematically equal gaps are formed between units (maintaining rhythmic consistency). This data can directly drive CNC embroidery equipment or CAD software to generate production files, achieving a seamless transition from digital design to automated production.
[0041] In summary, the entire method for adapting and generating Miao embroidery pattern data firstly utilizes a dynamic scaling mechanism driven by color complexity and maximum target area calculation based on physical space constraints to ensure that the pattern unit size strictly adapts to the carrier boundary to avoid overflow, while automatically protecting the details of high-complexity units from compression based on color quantity thresholds. This eliminates, to some extent, the white space, overflow, or detail distortion problems caused by fixed scaling in existing methods. Furthermore, through precise calculation of the dynamic unit quantity and amortized gap compensation, the remaining space on the carrier is converted into unit gaps and evenly injected into the grid arrangement. This ensures unit integrity while forming a mathematically equal gap distribution, achieving visually coordinated arrangement of patterns on any carrier without manual intervention, completely avoiding the defects of uneven gaps or rhythmic imbalance caused by mechanical arrangement. Finally, leveraging the stability of the relative coordinate system and the automation of coordinate mapping, all units are efficiently converted into contour coordinate data that can directly drive production equipment while maintaining their original proportions and enclosing relationships. In conclusion, this method achieves one-stop, high-fidelity data output from design to production, improving the data adaptation efficiency of complex patterns on personalized carriers and the feasibility of large-scale data application.
[0042] In one implementation, obtaining the maximum target area based on the target carrier region in S2 includes: S21, obtaining a single rectangular frame that can be located within the target carrier region, and defining the maximum area of the rectangular frame as the maximum target area.
[0043] In this embodiment, it should be noted that in S21, the physical capacity of the target carrier region is accurately measured. It should be noted that the area of the target carrier region must exceed the area of the initial filler border corresponding to the target unit. If it does not exceed the area, data adaptation generation cannot be performed.
[0044] Specifically, by analyzing the shape of the carrier boundary (such as the unfolded surface of an irregularly shaped cuff or a curved cover), and under the constraint of maintaining the integrity of the rectangle, all axially aligned rectangles that can be incorporated into the region are traversed and calculated, and the rectangle with the largest area is selected. This largest rectangle area is defined as the "maximum target area", which is significant in setting an insurmountable upper limit for subsequent unit sizes.
[0045] For example, on a crescent-shaped embroidery piece, the algorithm will find the largest complete rectangle that can be placed, ensuring that all pattern units can be completely embedded in the carrier without being cut off, thus avoiding the risk of pattern overflow from the source.
[0046] In one implementation, obtaining the amplification factor based on the number of color types corresponding to the target unit in S2 includes: S22, obtaining the number of color types corresponding to the target unit as the base number, and obtaining a preset number threshold; S23, if the base number exceeds the preset number threshold, dividing the difference between the base number and the preset number threshold by the preset number threshold to obtain the amplification factor; S24, if the base number does not exceed the preset number threshold, using zero as the amplification factor.
[0047] In this embodiment, it should be noted that, in S22, the preset quantity threshold is primarily limited by the minimum identifiable color block size of the embroidery process (typically ≥0.5mm). 2 For example, when the carrier area is small (such as a cuff), the threshold needs to be increased (e.g., set to 7-9) to avoid excessive enlargement causing the unit area to exceed the carrier area. Conversely, in large carriers (such as wall hangings), the threshold can be decreased (e.g., 3-5) to enhance detail protection. This value is directly related to the precision of the embroidery stitch; flat embroidery requires a lower threshold than lockstitch. Then, through color difference tolerance experiments, it is determined that when multiple colors intertwine in a limited space, if the area of the color block is lower than a specific value (e.g., 0.8mm), the threshold is lower. 2 When the human eye cannot distinguish adjacent colors (such as dark blue and navy blue), the number of colors corresponding to this critical area is the threshold benchmark (usually 8 colors), and equipment error correction (scanner color difference ±1 color) needs to be added.
[0048] S22 extracts the number of all independent color types within the target unit (e.g., in a butterfly pattern, dark blue, light blue, silver-white, pure white, etc., counted as 10 types), and uses this as the base quantity. A preset quantity threshold is used to distinguish between ordinary units and high color density units. The statistical process can exclude colors with similar color differences less than the allowable range, ensuring that only visually significant color types are counted. This step transforms subjective aesthetic characteristics into objective numerical values, providing a data basis for the decisions in S23-S24, enabling the identification of high-risk units that are prone to distortion due to size reduction.
[0049] In S23, when the number of base elements exceeds a preset threshold, it indicates that the element has a risk of distortion due to dense details (e.g., when the threshold is 5, a dragon pattern with a base element count of 6 needs protection). At this point, the absolute difference between the base element count and the threshold is calculated, and this difference is divided by the threshold to generate an amplification factor. A larger factor value indicates a higher required protection strength. For example, when the threshold is 5 and the base element count is 7, the factor = (7-5) / 5 = 0.4. This factor design reflects the direct proportional relationship between distortion risk and the degree of color exceeding the limit, accurately linking the amplification strength with complexity and avoiding redundant amplification of low-complexity elements.
[0050] In S24, when the number of basic elements does not exceed the preset threshold (e.g., the number of basic elements is 4 and the threshold is 5), it indicates that the color composition of the unit is simple, and the reduction operation is unlikely to cause visual distortion. In this case, the magnification factor is directly set to zero. This mechanism ensures that simple units (such as solid color geometric patterns) completely skip the magnification process and maintain their original size to save carrier space. The zero coefficient output means that the initial padding border will remain unchanged in S25-S26, which not only prevents excessive intervention in simple units but also optimizes the space utilization of the overall layout, reflecting the algorithm's ability to differentiate between units of different complexities.
[0051] In one implementation, obtaining the target filler border based on the magnification factor, the maximum target area, and the initial filler border in S2 includes: S25, adding 1 to the magnification factor to obtain the magnification ratio, multiplying the area of the initial filler border by the magnification ratio to obtain the target area; S26, magnifying the initial filler border proportionally to obtain the target filler border with an area equal to the target area, and if the area of the target filler border is greater than the maximum target area, then resetting the target filler border to a rectangle with an area equal to the maximum target area.
[0052] In this embodiment, it should be noted that in S25, the magnification requirement is converted into an actual scaling instruction. First, the magnification factor output in S23 or S24 is increased by 1 to obtain a linear magnification ratio (e.g., a factor of 0.4 corresponds to a ratio of 1.4). Then, the target area is obtained by multiplying the initial padding border area by this magnification ratio. This calculation ensures that the target area visually meets the requirement: target area = initial area × (1 + factor). When the factor is zero, the target area equals the initial area. The logic for generating the target area clearly distinguishes the magnification requirement: if the factor is zero, the original size is maintained; if the factor is positive, the size is expanded proportionally, providing a precise target value for area adjustment in S26.
[0053] In S26, this operation performs a dual-constraint unit size adjustment. First, it scales up the initial filler border proportionally, ensuring the area of the newly generated rectangle is exactly equal to the target area calculated in S25, while maintaining the aspect ratio (e.g., the original aspect ratio of the butterfly pattern is 1:1.2, and it remains 1:1.2 after scaling up). Then, the resulting rectangle area is compared to the maximum target area in S21: if the scaled-up area does not exceed the space limit, it is directly output as the target filler border; if it exceeds the limit (e.g., a complex dragon pattern exceeds the cuff space after scaling up), the rectangle corresponding to the maximum target area is forcibly adopted (but the aspect ratio remains equal to the initial border). This design limits aesthetic requirements through physical space limits, ensuring the final border responds to color complexity while strictly adapting to the carrier boundary, providing a safe and reliable unit size for S3.
[0054] In one implementation, obtaining the number of dynamic units based on the target carrier region and the target filler border in S3 includes: S31, dividing the area of the target carrier region by the area of the target filler border and rounding down to obtain the number of dynamic units.
[0055] In this embodiment, it should be noted that in S31, given the known dimensions of the target filler border, the maximum number of pattern units that the carrier can accommodate is calculated. Specifically, the overall area of the target carrier region is measured and divided by the area of a single target filler border; the quotient represents the theoretical maximum unit capacity. Since the units must be completely placed within the carrier, this quotient is rounded down, discarding all decimal parts. For example, when the carrier is a trapezoidal embroidery piece, even if there are scattered gaps in the sharp corner areas, only the integer value is taken as the dynamic unit quantity, ensuring that each unit has sufficient and continuous space for complete display.
[0056] In one implementation, obtaining the gap compensation amount based on the number of dynamic units, the target filling border, and the target carrier area in S3 includes: S32, multiplying the number of dynamic units by the area of the target filling border to obtain the total occupied area; S33, subtracting the total occupied area from the area of the target carrier area to obtain the gap area, dividing the gap area by the number of dynamic units to obtain the unit gap, and defining the unit gap as the gap compensation amount.
[0057] In this embodiment, it should be noted that in S32, based on the number of dynamic units determined in S31, this step calculates the minimum theoretical area occupied by all units in an ideal, gapless arrangement. The calculation method is to multiply the number of dynamic units by the area of a single target filler border to obtain the total area when all unit borders are completely and tightly arranged, i.e., the total occupied area. For example, on a rectangular placket carrier, if 10 units are tightly arranged, the total occupied area is 10 times the area of the unit borders. This value represents the minimum space requirement for the arrangement, and the difference between this value and the actual area of the carrier is the total amount of freely allocable gap space, providing an accurate quantitative basis for the remaining space calculation in S33.
[0058] In S33, the remaining space of the carrier is converted into a uniform gap compensation amount. First, the difference between the total area of the carrier and the total occupied area in S32 is calculated to obtain the sum of the blank areas in the carrier that are not occupied by the units (gap area). Then, this gap area is divided by the number of dynamic units to obtain the average space value allocated to each unit, which is defined as the unit gap compensation amount.
[0059] For example, when there are L-shaped gaps in the carrier, instead of forcibly filling specific locations, the total amount of gaps is evenly distributed among the units as surrounding buffer space.
[0060] A Miao embroidery pattern data adaptation and generation system is also provided. The system includes: an acquisition module, used to input a scanned image of a Miao embroidery pattern, and acquire target units and their corresponding outlines based on the scanned image, and acquire initial filler borders based on the outlines, wherein the filler borders are rectangles with the smallest area that surround the entire target unit; a first data processing module, used to acquire a target carrier area, acquire the maximum target area based on the target carrier area, acquire a magnification factor based on the number of color types corresponding to the target unit, and acquire target filler borders based on the magnification factor, the maximum target area, and the initial filler borders; a second data processing module, used to acquire the number of dynamic units based on the target carrier area and the target filler borders, and acquire gap compensation based on the number of dynamic units, the target filler borders, and the target carrier area; and a data generation module, used to generate a set of coordinate points for all target filler borders within the target area based on the gap compensation, the number of dynamic units, and the target filler borders, and to generate Miao embroidery pattern data including a set of coordinate points for the outlines corresponding to all target units based on the set of coordinate points for all target filler borders.
[0061] In one implementation, the first data processing module is further configured to: acquire a single rectangular frame that can be located within the target carrier area, and define the maximum area of the rectangular frame as the maximum target area.
[0062] In one embodiment, the first data processing module is further configured to: obtain the number of color types corresponding to the target unit as the base number, and obtain a preset number threshold; if the base number exceeds the preset number threshold, divide the difference between the base number and the preset number threshold by the preset number threshold to obtain an amplification factor; if the base number does not exceed the preset number threshold, use zero as the amplification factor.
[0063] In one embodiment, the first data processing module is further configured to: add 1 to the magnification factor to obtain the magnification ratio, multiply the area of the initial padding border by the magnification ratio to obtain the target area; magnify the initial padding border proportionally to obtain the target padding border with an area equal to the target area, and if the area of the target padding border is greater than the maximum target area, reset the target padding border to a rectangle with an area equal to the maximum target area.
[0064] In this embodiment, it should be noted that the specific method of performing the above-mentioned Miao embroidery pattern data adaptation and generation system has been described in detail in the embodiments of the Miao embroidery pattern data adaptation and generation method, and will not be elaborated here.
[0065] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0066] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0067] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
[0068] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of the claims and specification of the present invention.
Claims
1. A method for generating Miao embroidery pattern data, characterized in that, include: Input a scanned image of a Miao embroidery pattern, and obtain the target unit and the outline corresponding to the target unit based on the scanned image of the Miao embroidery pattern. Obtain the initial filler border based on the outline, wherein the filler border is a rectangle with the smallest area that surrounds the entire target unit. Obtain the target carrier region, and obtain the maximum target area based on the target carrier region. Obtain the magnification factor based on the number of color types corresponding to the target unit. Obtain the target filling border based on the magnification factor, the maximum target area, and the initial filling border. Obtain the number of dynamic units based on the target carrier region and the target filling border. Obtain the gap compensation amount based on the number of dynamic units, the target filling border, and the target carrier region. Generate the coordinate point set of all target filling borders within the target region based on the gap compensation amount, the number of dynamic units, and the target filling border. Generate Miao embroidery pattern data including the coordinate point set of the outline corresponding to all target units based on the coordinate point set of all target filling borders.
2. The method for adapting and generating Miao embroidery pattern data according to claim 1, characterized in that, The step of obtaining the maximum target area based on the target carrier region includes: obtaining a single rectangular frame that can be located within the target carrier region, and defining the maximum area of the rectangular frame as the maximum target area.
3. The method for generating Miao embroidery pattern data according to claim 1, characterized in that, The step of obtaining the magnification factor based on the number of color types corresponding to the target unit includes: obtaining the number of color types corresponding to the target unit as the base number, and obtaining a preset number threshold; if the base number exceeds the preset number threshold, then dividing the difference between the base number and the preset number threshold by the preset number threshold to obtain the magnification factor; if the base number does not exceed the preset number threshold, then using zero as the magnification factor.
4. The method for generating Miao embroidery pattern data according to claim 1, characterized in that, The process of obtaining the target filler border based on the magnification factor, the maximum target area, and the initial filler border includes: adding 1 to the magnification factor to obtain the magnification ratio; multiplying the area of the initial filler border by the magnification ratio to obtain the target area; magnifying the initial filler border proportionally to obtain the target filler border with an area equal to the target area; and if the area of the target filler border is greater than the maximum target area, resetting the target filler border to a rectangle with an area equal to the maximum target area.
5. The method for adapting and generating Miao embroidery pattern data according to claim 1, characterized in that, The step of obtaining the number of dynamic units based on the target carrier region and the target filler border includes: dividing the area of the target carrier region by the area of the target filler border and rounding down to obtain the number of dynamic units.
6. The method for generating Miao embroidery pattern data according to claim 1, characterized in that, The step of obtaining the gap compensation amount based on the number of dynamic units, the target filling border, and the target carrier area includes: multiplying the number of dynamic units by the area of the target filling border to obtain the total occupied area; subtracting the total occupied area from the area of the target carrier area to obtain the gap area; dividing the gap area by the number of dynamic units to obtain the unit gap; and defining the unit gap as the gap compensation amount.
7. A Miao embroidery pattern data adaptation and generation system, characterized in that, The system includes: an acquisition module, used to input a scanned image of a Miao embroidery pattern, acquire target units and their corresponding outlines based on the scanned image, and acquire an initial filler border based on the outlines, wherein the filler border is a rectangle with the smallest area that surrounds the entire target unit; a first data processing module, used to acquire a target carrier area, acquire the maximum target area based on the target carrier area, acquire a magnification factor based on the number of color types corresponding to the target unit, and acquire a target filler border based on the magnification factor, the maximum target area, and the initial filler border; a second data processing module, used to acquire the number of dynamic units based on the target carrier area and the target filler border, and acquire a gap compensation amount based on the number of dynamic units, the target filler border, and the target carrier area; and a data generation module, used to generate a set of coordinate points for all target filler borders within the target area based on the gap compensation amount, the number of dynamic units, and the target filler border, and to generate Miao embroidery pattern data including a set of coordinate points for the outlines corresponding to all target units based on the set of coordinate points for all target filler borders.
8. The Miao embroidery pattern data adaptation and generation system according to claim 7, characterized in that, The first data processing module is further configured to: acquire a single rectangular frame that can be located within the target carrier area, and define the maximum area of the rectangular frame as the maximum target area.
9. The Miao embroidery pattern data adaptation and generation system according to claim 7, characterized in that, The first data processing module is further configured to: obtain the number of color types corresponding to the target unit as the base number, and obtain a preset number threshold; if the base number exceeds the preset number threshold, divide the difference between the base number and the preset number threshold by the preset number threshold to obtain the amplification factor; if the base number does not exceed the preset number threshold, use zero as the amplification factor.
10. The Miao embroidery pattern data adaptation and generation system according to claim 7, characterized in that, The first data processing module is further configured to: add 1 to the magnification factor to obtain the magnification ratio, multiply the area of the initial padding border by the magnification ratio to obtain the target area; magnify the initial padding border proportionally to obtain the target padding border with an area equal to the target area; if the area of the target padding border is greater than the maximum target area, reset the target padding border to a rectangle with an area equal to the maximum target area.